Econ 326 Prof. Mariana Carrera Lab Session X [DATE]
Outline
Panel Data Dataset in which behaviors of entities (e.g., individuals, companies, countries) are observed across time. Example:
Setting up panel regressions Declare data to be panel data using xtset command. Use xtline to visualize panel data. xtline delay, overlay http://www.princeton.edu/~otorres/Panel101.pdf
Setting up time series data Declare data to be time data using tsset command. Allows you to use lead and lag operators: L. and F. L.x = x(t-1) L2.x=x(t-2) F.x=x(t+1) F2.x=x(t+2) Two declaration syntaxes: Straight time series data http://www.princeton.edu/~otorres/Panel101.pdf Cross-sectional time series data
Fixed effects models in Stata 3 Stata commands for estimating linear FE models: xi: reg xtreg areg
Fixed effects (xi: reg) Example syntax: Predictor variable Dependent variable xi: tells Stata to allow for factor variables i.variable creates dummies for categorical variable varname reg: basic OLS regression
Fixed effects (xi: reg) Example output N-1 entity-specific intercepts
Fixed effects (xtreg) Example syntax: Fixed effects option
Fixed effects (xtreg) Example output: # of entities identical to xi results
Fixed Effects (areg) Example syntax: absorb(varname) includes variable varname as a series of dummy variables in regression
Fixed Effects (areg) Example output: identical to xi results # of entities
Clustering standard errors Example syntax Accounts for w/in county correlation of error term
Outreg2 (basics) Used to create publication-style tables. Install with: ssc install outreg2 Basic syntax: Can export to word, excel, latex
Replace, append, model titles) Create new file or replace existing one
Use variable labels
Reporting significance levels Add tstat to replace standard errors w/t-statistics
Decimal places Decimal places for SEs Decimal places for coefficients
Showing selected coefficients Use drop() or keep() to select variables Use nocons option to drop Constant from table.
Ordering coefficients Re-order when running regression E.g., to show year above population: To specify ordering for multiple models: Use sortvar() to order rows of table
Adding model stats w/addstat To see what stats are saved by Stata. Write name of statistic r() or e() scalars