* * Examples 10.4 and 10.5 * J. Wooldridge, Econometrics of Cross Section and Panel Data * * Note: The sample data files include all required data transformations. * However, in many cases we show how these data transformations would * be created in RATS from the basic data, as this is something you will * need to know how to do in practice. * cal(panelobs=3) 1987 all 157//3 open data jtrain1.raw data(format=free,org=columns) / year fcode employ sales avgsal scrap rework $ tothrs union grant d89 d88 totrain hrsemp lscrap lemploy lsales lrework $ lhrsemp lscrap_1 grant_1 clscrap cgrant clemploy clsales lavgsal clavgsal $ cgrant_1 chrsemp clhrsemp * * These SET instructions generate some required data transformations: * set allthree = %valid(scrap(%indiv(t)//1)+scrap(%indiv(t)//2)+scrap(%indiv(t)//3)) set d89 = %period(t)==3 set d88 = %period(t)==2 set lscrap = log(scrap) * * Use grant_1 as the lag for grant. grant{1} is pre-sample for the 1987 * observations and so would cause loss of a data point. But grant is known to be * zero for 1986. * set grant_1 = %if(%period(t)==1,0.0,grant{1}) * * Do random and fixed effects estimators, and test the two "grant" variables. * preg(method=random,smpl=allthree) lscrap # constant d88 d89 union grant grant_1 exclude # grant grant_1 preg(method=fixed,smpl=allthree) lscrap # d88 d89 grant grant_1 exclude # grant grant_1 * * This computes the variances of the components using the formulas in the text * linreg(noprint) lscrap # constant d88 d89 union grant grant_1 * * MCOV provides a sneaky way to compute the required sum of cross products of * residuals. With LWINDOW=PANEL, it includes all v(i,s)v(i,t) combinations. This * double counts the off-diagonal elements and also includes v(i,t)**2. By * subtracting the sum of squared residuals, and dividing by 2, we get the desired * sum. * mcov(lwindow=panel) / %resids # constant compute vindiv =(%cmom(1,1)-%rss)*.5/(54*3*(3-1)/2.-6) compute vrandom=%seesq-vindiv disp "Component variances" vrandom vindiv preg(method=random,smpl=allthree,vindiv=vindiv,vrandom=vrandom) lscrap # constant d88 d89 union grant grant_1 * * FE with robust errors (example 10.5, continued) * Again, the transformed data are included in the data set, but this shows * how to generate them directly. * panel(entry=1.0,indiv=-1.0) lscrap / clscrap panel(entry=1.0,indiv=-1.0) d88 / cd88 panel(entry=1.0,indiv=-1.0) d89 / cd89 panel(entry=1.0,indiv=-1.0) grant / cgrant panel(entry=1.0,indiv=-1.0) grant_1 / cgrant_1 * linreg(dfc=54) clscrap # cd88 cd89 cgrant cgrant_1 * * LINREG with LWINDOW=PANEL does the trick. * linreg(lwindow=panel) clscrap # cd88 cd89 cgrant cgrant_1 * * FD with robust errors (example 10.6) * diff lscrap / dscrap diff grant / dgrant diff grant_1 / dgrant_1 * linreg dscrap / resids # constant d89 dgrant dgrant_1 linreg(lwindow=panel) dscrap # constant d89 dgrant dgrant_1 * * AR1 test (example 10.6 continued) * linreg(dfc=4) resids # resids{1} * * The Hausman test is included in the output for METHOD=RANDOM. This shows how to * compute it. * preg(method=random,smpl=allthree) lscrap # constant d88 d89 grant grant_1 compute xxrandom=%xx compute brandom=%beta preg(method=fixed,smpl=allthree) lscrap # constant d88 d89 grant grant_1 * * The %xx for METHOD=FIXED needs to be scaled by the variance in order to be * comparable to METHOD=RANDOM. * compute xxfixed=%xx*%vrandom * test(title="Hausman Test",all,form=chisquared,vector=brandom,covmat=xxfixed-xxrandom)