Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * Example Stata script using postfile to create
- * a dataset of results from an analysis.
- * This example simulates a female wage penalty X times
- * and compares the density of estimates to the normal density.
- * parameters for simulation
- local numiterations = 50
- local samplesize = 500
- * set the simulation seed just for reproducibility of this artificial example
- set seed 6093358
- * temporary names for postfile -- you can use permanent names if you want
- tempname memhold
- tempfile results
- * initiate the post file:
- * this tells stata that the name memhold refers to the dataset results
- * this is also where you name variables in your dataset
- postfile `memhold' iteration b using "`results'"
- * run the simulation
- forvalues i = 1/`numiterations' {
- * generate some fake data
- drop _all
- set obs `samplesize'
- * generate random female indicator
- gen female = floor(2*runiform())
- * generate random wage with female wage penalty
- gen logwage = 3.1 - (0.20 * female) + rnormal(0,0.65)
- * do the analysis
- reg logwage female
- lincom female
- local b = r(estimate)
- * post the results
- post `memhold' (`i') (`b')
- }
- * close post file, which creates the dataset results
- postclose `memhold'
- * use results in some analysis
- use `results', clear
- lab var b "Estimated coefficient"
- kdensity b, normal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement