Below is the Stata code that can be used to merge the NSAF data files. set more off * NOTE: Commands such as renames, renvars and tablist may have to…
Read More
Search Results for: stata
Permutation Tests in Stata 9
* read your data into Stata use https://stats.idre.ucla.edu/stat/stata/notes/hsb2, clear generate goodread = (read > 60) * run logistic predicting "goodread" from "write" logit goodread female * run permutation test for…
Read More
Creating a pyramid plot by subgroup | Stata Code Fragments
use https://stats.idre.ucla.edu/stat/stata/notes/hsb2, clear egen writegroup= cut(write), group(10) label tab writegroup sort female writegroup ses contract female writegroup ses rename _freq count reshape wide count, i(writegroup female) j(ses) gen c1 =…
Read More
How can I read binary data in Stata? | Stata Code Fragments
In this example, we show how to read a binary file into Stata. The original binary file can be downloaded following the link. The zip file here contains data file,…
Read More
Random sampling with replacement | Stata Code Fragments
Sampling with replacement is easy to do while sampling without replacemant can be a bit trickier. We will perform sampling with replacement using several Mata functions. The dataset used in…
Read More
Šidák-Holm Adjusted p-values | Stata Code Fragments
Consider the 15 p-values shown below derived from a series of hypothesis tests. Following the p-values are the commands for computing the Šidák-Holm adjusted p-values. Also shown are the Bonferroni…
Read More
Spaghetti Plots in Stata
Here are a couple of examples of making spaghetti plots. Here is a basic spaghetti plot that looks at "alcuse" over time (age_14) showing one regression line per person (see…
Read More
Simple linear and nonlinear models using Stata’s ml command | Stata Code Fragments
This code fragment page is designed to show how a number of simple linear and nonlinear models can be programmed using Stata’s ml command. These programs are not complete estimation…
Read More
Running a simulation | Stata Code Fragments
Below are two examples of running simulations using Stata. Both examples involve running a regression. The difference between them is the way the data for the regression are generated. The…
Read More
A Program for computing “spells” | Stata Code Fragments
* make a fake data file clear input id month var1 1 1 0 1 2 0 1 3 1 1 4 0 1 5 0 1 6 0 1…
Read More
