Академический Документы
Профессиональный Документы
Культура Документы
Basic statistics
Report some summary statistics on your variables. Among other things, report the sample mean,
the median, and the standard deviation of all variables; and the 10th and 90th percentiles of the
variable hhincome. Now report the 10th and 90th percentiles of the variable hhincome only for
households who bought insurance. (summarize, codebook, centile, table, tabulate)
Report an estimate for the population mean of hhincome, and report its standard error. Think
about the difference between this task and the previous task of reporting sample moments. It is a
possible source of confusion, so never forget that difference. Also think about the relation
between the standard deviation of hhincome in the sample that you reported in the previous step
and the standard error that you are reporting here. (mean)
Use graphics commands to plot the distribution of the variable hhincome. (histogram,
kdensity)
Advanced stuff: Report an estimate for the population mean of hhincome and of its standard
error without using the built-in Stata routine. (gen, egen)
Regressions
Run an OLS regression of variable ins on age square(age) white married poor hhincome.
(reg, gen)
What is each element of the results panel telling you? Are any of the coefficients significant? Do
these variables explain a large fraction of why an individual takes up health insurance?
Save the fitted or predicted values from your regression into a new variable. Analyse if their
distribution has some property that could question the usefulness of our linear regression model
in this application.
Find out where Stata stores the estimated regression coefficients and variance-covariance
matrix. (ereturn list, mat list)
Save the estimated regression coefficients into scalars and produce the fitted values manually.
(ereturn list, scalar)
Your do-file
Start a new “do-file” and record the commands for all the previous tasks, so that your work is
reproducible. Redo all previous steps for female only.
We want to have things more convenient. Tell Stata to keep a log file of all the results that you
produce. (log)
Advanced stuff: Take a look at the “set” options that Stata provides. Ask Stata to always report to
you how long it takes for each command to run, and rerun all of the previous steps. Turn the
report on time usage off again since it will really bother you after some time. (set, set rmsg)
Try-your-own time
Try all the things in Stata that you never dared to try, and ask if there are questions!
Check out the by and bysort command
Check out loops: foreach and forvalues
Or try problem 1 from the first problem set, if you haven’t done so yet.