mini stata commands Flashcards
hypothesis test for mean of variable being x
ttest varname == x
hypothesis test for difference in means
ttest outcome, by (binaryvarname)
hypothesis test for linear combination
lincom 2var1+3var2 for example
basically just lincom and then the combination
hypothesis test for multiple hypotheses
test (varname = x) (varname = y)
normal regression
reg outcome var1 var2, robust
how to export a regression
reg command
outreg2 using namedoc.doc, sdec(4) bdec(4)
how to run a regression within a range
reg outcome var1 var2, robust, if inrange(varname, lowerbound, upperbound)
how to run fixed effects regression
egen panel_id = group(var1 var2)
xtset panel_id timevariableid
xtreg outcome interactionvarname i.timeidvariable, fe robust
iv regression command
ivregress 2sls outcome (fake_regressor = z1 z2), robust
predicted values
predict namethevar
predicted residuals
predict residual, resid
how to standardise
gen varname_standardised = varname/r(sd)
how to log a variable
gen varname_log = ln(varname)
scatter with line through
twoway (lfit outcome regressor) (scatter outcome regressor)
regression discontinuity
gen fake_over = fake_regressor -1
gen over_one = fake_regressor >1
gen interact_RD = over_one * fake_over
reg outcome fake_over over_one interact_rd, robust