Archive

Author Archive

A Stata command to run ChatGPT

Artificial intelligence (AI) is a popular topic in the media these days, and ChatGPT is, perhaps, the most well-known AI tool. I recently tweeted that I had written a Stata command called chatgpt for myself that runs ChatGPT. I promised to explain how I did it, so here is the explanation. Read more…

Customizable tables in Stata 17, part 7: Saving and using custom styles and labels

In Customizable tables in Stata 17, part 5, I showed you how to use the new and improved table command to create a table of results from a logistic regression model. We are likely to create many more tables of regression results, and we will probably use the same style and labels. In this post, I will show you how to save your styles and labels so that you can use them to format future tables. I will use the Microsoft Word document that we created in part 5 as our goal. Read more…

Customizable tables in Stata 17, part 6: Tables for multiple regression models

In my last post, I showed you how to create a table of statistical tests using the command() option in the new and improved table command. In this post, I will show you how to gather information and create tables using the new collect suite of commands. Our goal is to fit three logistic regression models and create the table in the Adobe PDF document below. Read more…

Customizable tables in Stata 17, part 5: Tables for one regression model

In my last post, I showed you how to use the new and improved table command with the command() option to create a table of statistical tests. In this post, I want to show you how to use the command() option to create a table for a single regression model. Our goal is to create the table in the Microsoft Word document below. Read more…

Customizable tables in Stata 17, part 4: Table of statistical tests

In my last post, I showed you how to use the new and improved table command with the statistic() option to create a classic table 1. In this post, I want to show you how to use the command() option to create a table of statistical tests. Our goal is to create the table in the Microsoft Word document below. Read more…

Customizable tables in Stata 17, part 3: The classic table 1

In my last two posts, I showed you how to use the new-and-improved table command to create a table and how to use the collect commands to customize and export the table. In this post, I want to show you how to use these tools to create a table of descriptive statistics that is often called a “classic table 1”. Our goal is to create the table in the Microsoft Word document below. Read more…

Customizable tables in Stata 17, part 2: The new collect command

In my last post, I showed you how to use the new-and-improved table command to create a table and how to use some of the options to customize the table. In this post I want to introduce the collect commands. Many Stata commands begin with collect, and they can be used to create collections, customize table layouts, format the numbers in the tables, and export tables to documents. There are so many new collect commands that we created a new Customizable Tables and Collected Results Reference Manual. Today, I want to show you how to use some of the collect commands to customize the look of your tables. I will show you more advanced uses of collect in future posts. Read more…

Customizable tables in Stata 17, part 1: The new table command

Today, I’m going to begin a series of blog posts about customizable tables in Stata 17. We expanded the functionality of the table command. We also developed an entirely new system that allows you to collect results from any Stata command, create custom table layouts and styles, save and use those layouts and styles, and export your tables to most popular document formats. We even added a new manual to show you how to use this powerful and flexible system. Read more…

Stata/Python integration part 9: Using the Stata Function Interface to copy data from Python to Stata

In my previous post, we learned how to use the Stata Function Interface (SFI) module to copy data from Stata to Python. In this post, I will show you how to use the SFI module to copy data from Python to Stata. We will be using the yfinance module to download financial data from the Yahoo! finance website. You can install this module in your Python environment by typing pip install yfinance. Our goal is to use Python to download historical data for the Dow Jones Industrial Average (DJIA) and use Stata to create the following graph. Read more…

Categories: Programming Tags: , ,

Stata/Python integration part 8: Using the Stata Function Interface to copy data from Stata to Python

In my previous posts, I used the read_stata() method to read Stata datasets into pandas data frames. This works well when you want to read an entire Stata dataset into Python. But sometimes we wish to read a subset of the variables or observations, or both, from a Stata dataset into Python. In this post, I will introduce you to the Stata Function Interface (SFI) module and show you how to use it to read partial datasets into a pandas data frame. Read more…

Categories: Programming Tags: , ,