--------------------------------------------------------------------------------------------------------------- log: /Users/jwalker/Work/ps2.log log type: text opened on: 10 Dec 2007, 15:04:08 . infile caseid year firm grp y using vctest.dat (15000 observations read) . compress caseid was float now int year was float now byte firm was float now byte grp was float now int . save vctest , replace file vctest.dta saved . . sum y, detail y ------------------------------------------------------------- Percentiles Smallest 1% -3.801925 -6.54169 5% -2.68644 -6.328892 10% -2.109073 -6.068696 Obs 15000 25% -1.104151 -5.947643 Sum of Wgt. 15000 50% .0727825 Mean .0755198 Largest Std. Dev. 1.715693 75% 1.246118 5.910426 90% 2.312204 5.978642 Variance 2.943602 95% 2.908397 5.980018 Skewness .0269152 99% 4.039303 6.810177 Kurtosis 2.908424 . *Record variance of y for future use. . scalar define var_y = r(Var) . . *Now recover estimate of the variance of the transitory component . egen mg = mean(y), by(grp) . gen dg = y - mg . . sum dg, detail dg ------------------------------------------------------------- Percentiles Smallest 1% -2.111425 -3.203313 5% -1.493781 -3.138394 10% -1.169652 -3.092287 Obs 15000 25% -.6004642 -2.986183 Sum of Wgt. 15000 50% .0014804 Mean 2.38e-10 Largest Std. Dev. .9011704 75% .6005392 3.282832 90% 1.143927 3.308813 Variance .8121081 95% 1.484322 3.318286 Skewness .0054814 99% 2.099428 3.594743 Kurtosis 3.00173 . . *variance of dg equals Variance of transitory component, epsilon . *store this estimate for subsequent use . scalar define var_eps = r(Var) . . * collapse data file to firm person observations, averaging across . * time periods . . collapse (mean) y , by(caseid firm) . . * create cross product terms to form Wooldridge's estimator . * cross products of different firms recovers variance of . * individual component. Notice exclude own product . gen y1 = y[_n-1] if caseid == caseid[_n-1] (1000 missing values generated) . gen y2 = y[_n-2] if caseid == caseid[_n-2] (2000 missing values generated) . gen a = y*y1 (1000 missing values generated) . gen b = y*y2 (2000 missing values generated) . . *sum across periods to gather cross products then sum across . *individuals. missing values treated as zeros. . * . egen ssq = rowtotal(a b) . sum ssq , detail ssq ------------------------------------------------------------- Percentiles Smallest 1% -3.585646 -10.08237 5% -1.432561 -9.334759 10% -.6508919 -8.130392 Obs 3000 25% 0 -7.778816 Sum of Wgt. 3000 50% 0 Mean .9432132 Largest Std. Dev. 2.71497 75% 1.136436 19.60847 90% 3.903668 21.24195 Variance 7.371063 95% 6.200994 22.05335 Skewness 2.783689 99% 11.53966 25.73206 Kurtosis 16.14628 . scalar define var_alpha = r(sum)/r(N) . . *Variance of the match specific component is the residual . scalar define var_mu = var_y - var_alpha - var_eps . . scalar list _all var_mu = 1.1882802 var_alpha = .94321324 var_eps = .81210813 var_y = 2.9436016 . . end of do-file . exit no; data in memory would be lost r(4); . exit, clear