** ** EXERCISE: OLS with clustered standard errors versus GLS ** ** turn the following simple code into a Monte Carlo to look at the ** performance of OLS, GLS, and OLS with clustered standard errors ** when dependent variable is highly serially correlated (as it often ** is in applied work) ** ** HINT: the code below should be one iteration of Monte Carlo ** ** QUESTIONS: ** ** - show that for low "rho" all the tests are identical ** ** - you should be able to show that for 50 states (er, panels) and 20 ** years that clustered OLS and GLS both perform fine. why would you ** prefer one over the other? can you change your Monte Carlo to ** demonstrate your answer ** ** - if obs goes down but T is constant then you should be able to show ** that even GLS and clustered OLS overreject in finite samples. what ** could we do instead? ** ** - how would you add AR(2) errors to the model? For rho1=0.95 and rho2=0.1, ** how does xtgls perform when it assumes AR(1). Note that in most samples ** rho2 will usually be very low. What does this tell us? ** ** REFERENCE: (Bertrand, Duflo, Mullainathan QJE) ** drop _all set obs 1000 local rho = .95 gen panel = 1+floor( (_n-1)/20) bys panel: gen year = 1980 + _n bys panel: gen fe = uniform() if _n == 1 bys panel: replace fe = fe[1] gen x = invnorm(uniform()) sort panel year gen e = invnorm(uniform()) if year == 1981 forvalues year = 1982/2000 { bys panel: replace e = `rho'*e[`year'-1981] + invnorm(uniform()) if year == `year' } ** make some fake "placebo laws" gen post = 0 replace post = 1 if panel > 8 & year > 1995 replace post = 1 if panel > 9 & year > 1996 replace post = 1 if panel > 10 & year > 1992 ** note that post coefficient is 0(!) gen y = 2 + fe + 2*x + 0*post + e qui xtreg y x post, i(panel) qui xtreg y x post, i(panel) cluster(panel) qui xtgls y x post, corr(ar1) i(panel) t(year) panels(iid)