****************************************************************************** * Econometrics of Panel Data * The most popular panel estimators * Pooled, FE and RE model * Jakub Muck * * As we discussed during class we use by default clustered (by company) standard errors ****************************************************************************** * 0. Data preparation clear all webuse grunfeld * 1. Pooled regression reg invest kstock mvalue, vce(cluster company) estimates store pooled * 2. FE model -- three ways to estimate FE in Stata * 2.1.1 FE model (LSDV estimator) reg invest kstock mvalue i.company * Creating individual(firm)-specific dummies * 2.1.2 FE model (LSDV estimator) tab company, gen(dummy) reg invest kstock mvalue dummy* * 2.2 FE model (within estimation) * Susbtracting individual-specific averages from all variables foreach var in invest kstock mvalue{ bysort company: egen `var'_bar=mean(`var') gen `var'_tilde=`var'-`var'_bar } reg invest_tilde kstock_tilde mvalue_tilde * 2.3 FE model (within estimator, xtreg) * Setting dataset as panel xtset company year xtreg invest kstock mvalue, fe vce(cluster company) estimates store fe * predicting fixed effects estimates predict effects_fe, u * 3. RE model xtreg invest kstock mvalue, re vce(cluster company) estimates store re * predicting random effects estimates predict effects_re, u estimates table pooled fe re, b se p *scatter effects*