Basic commands Flashcards
wildcards
- random string
? - one character
create a new variable
generate [new variable name] = function
DELETE A VARIABLE
drop [variable name]
CREATE A NORMALLY DISTRIBUTED VARIABLE
generate [new variable name] = rnormal()
SHOW DATA
list [variable name]
CONVERT STRING VARIABLE TO NUMERIC VARIABLE
destring [string variable name], replace|generate
DECLARE DATA SET TO BE TIME SERIES
tsset [date variable]
USE A SUBET OF THE DATA
regress … if [variable] [condition]
. indicates a missing observation and has a large value; hence, “if [variable] < .” omits missing variables
& indicates “and”
== indicates “equality”
| indicates “or”
OLS REGRESSION
regress [dependent variable] [regressor 1] [regressor 2] … [regressor N]
OLS REGRESSION WITH HETEROSKEDASTICITY CORRECTION
regress [dependent variable] [regressor 1] [regressor 2] … [regressor N], vce(hc3)
PANEL REGRESSION (GLS when using random effects)
xtreg [dependent variable] [regressor 1] [regressor 2] … [regressor N], [option]
For [option], use RE for random effects, BE for time-specific fixed effects, and FE for cross-sectional fixed effects.
Prediction
based on last run OLS
predict [new variable name]
Forecast Standard Error
based on last run OLS
predict [new variable name], stdb
Residuals
based on last run OLS
predict [new variable name], residuals
Estimated covariance matrix:
based on last run OLS
estat vce
Residual plus fixed effects (total residual)
based on last run Panel Data regression
predict [new variable name], ue
Fixed effects (individual specific residual component) (based on last run Panel Data regression)
predict [new variable name], u
Non-specific residual:
based on last run Panel Data regression
predict [new variable name], e