------------------------------------------------------------------------------- log: d:\bill\fall2008\ecoe60303\psid1.log log type: text opened on: 9 Sep 2008, 21:48:28 . *read in state data; . use psid1; . * generate new variables; . gen exp=age-educ-5; . gen exp2=exp*exp; . gen wage=laborinc/hours; . gen wagel=log(wage); . gen tenure2=tenure*tenure; . * label variables; . label var exp "potential experience"; . label var exp2 "experience squared"; . label var wage "hourly wage rate (earn/hours)"; . label var wagel "log hourly wage rate"; . label var tenure2 "tenure squared"; . * get descriptive statistics; . sum; Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- id | 3945 4528.692 2716.94 48 9830 age | 3945 36.68466 8.081979 19 55 educ | 3945 13.109 2.125806 5 16 union | 3945 .2458809 .4306628 0 1 laborinc | 3945 27809.51 19904.65 2478 352113 -------------+-------------------------------------------------------- hours | 3945 2217.089 441.0947 1016 3995 tenure | 3945 8.35782 7.446887 0 37 mnjob | 3945 386.0532 253.7452 1 999 year | 3945 1985 1.414393 1983 1987 black | 3945 .1761724 .381015 0 1 -------------+-------------------------------------------------------- prof | 3945 .2283904 .4198487 0 1 manager | 3945 .1997465 .3998604 0 1 Sales | 3945 .0494297 .2167909 0 1 clerk | 3945 .0496831 .217317 0 1 craft | 3945 .2253485 .4178646 0 1 -------------+-------------------------------------------------------- operator | 3945 .0839037 .2772784 0 1 trans | 3945 .0656527 .2477055 0 1 service | 3945 .0370089 .1888074 0 1 exp | 3945 18.57567 8.400257 2 44 exp2 | 3945 415.6018 352.3121 4 1936 -------------+-------------------------------------------------------- wage | 3945 12.70048 8.941168 2.027792 191.3658 wagel | 3945 2.384165 .5512462 .7069476 5.254187 tenure2 | 3945 125.2952 185.8456 0 1369 . * get OLS estimates; . reg wagel exp exp2 tenure tenure2 union educ black; Source | SS df MS Number of obs = 3945 -------------+------------------------------ F( 7, 3937) = 304.13 Model | 420.623659 7 60.0890942 Prob > F = 0.0000 Residual | 777.848895 3937 .197574015 R-squared = 0.3510 -------------+------------------------------ Adj R-squared = 0.3498 Total | 1198.47255 3944 .303872352 Root MSE = .44449 ------------------------------------------------------------------------------ wagel | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .0336411 .0040166 8.38 0.000 .0257663 .0415159 exp2 | -.0004232 .0000975 -4.34 0.000 -.0006144 -.0002319 tenure | .0306286 .0029329 10.44 0.000 .0248785 .0363787 tenure2 | -.0007432 .0001199 -6.20 0.000 -.0009783 -.0005082 union | .128554 .0174446 7.37 0.000 .0943526 .1627553 educ | .1215151 .0037243 32.63 0.000 .1142134 .1288167 black | -.2091378 .0195349 -10.71 0.000 -.2474374 -.1708382 _cons | .1845671 .0608496 3.03 0.002 .0652674 .3038669 ------------------------------------------------------------------------------ . * define the dimensions of the effects; . iis id; . * get fixed-effect estimate by absorbing data by id; . * treats data as deviations from means to reduce number; . * of parameters to be estimated; . areg wagel exp exp2 tenure tenure2 union, absorb(id); Linear regression, absorbing indicators Number of obs = 3945 F( 5, 3151) = 46.61 Prob > F = 0.0000 R-squared = 0.8558 Adj R-squared = 0.8195 Root MSE = .23423 ------------------------------------------------------------------------------ wagel | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .0552342 .006575 8.40 0.000 .0423426 .0681259 exp2 | -.0006522 .000164 -3.98 0.000 -.0009737 -.0003307 tenure | .0177614 .0032438 5.48 0.000 .0114013 .0241215 tenure2 | -.0005063 .0001417 -3.57 0.000 -.0007841 -.0002285 union | .0520794 .0236024 2.21 0.027 .0058018 .098357 _cons | 1.531382 .0654104 23.41 0.000 1.403131 1.659633 -------------+---------------------------------------------------------------- id | F(788, 3151) = 20.592 0.000 (789 categories) . * get the same fixed-effect estimates by using xtreg; . xtreg wagel exp exp2 tenure tenure2 union black educ, fe; Fixed-effects (within) regression Number of obs = 3945 Group variable: id Number of groups = 789 R-sq: within = 0.0689 Obs per group: min = 5 between = 0.0654 avg = 5.0 overall = 0.0633 max = 5 F(5,3151) = 46.61 corr(u_i, Xb) = -0.2536 Prob > F = 0.0000 ------------------------------------------------------------------------------ wagel | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .0552342 .006575 8.40 0.000 .0423426 .0681259 exp2 | -.0006522 .000164 -3.98 0.000 -.0009737 -.0003307 tenure | .0177614 .0032438 5.48 0.000 .0114013 .0241215 tenure2 | -.0005063 .0001417 -3.57 0.000 -.0007841 -.0002285 union | .0520794 .0236024 2.21 0.027 .0058018 .098357 black | (dropped) educ | (dropped) _cons | 1.531382 .0654104 23.41 0.000 1.403131 1.659633 -------------+---------------------------------------------------------------- sigma_u | .50755741 sigma_e | .23422628 rho | .82442854 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(788, 3151) = 13.99 Prob > F = 0.0000 . * store thefixed-effect estimates; . estimates store fixed; . * get the random effects estimator; . xtreg wagel exp exp2 tenure tenure2 union black educ, re; Random-effects GLS regression Number of obs = 3945 Group variable: id Number of groups = 789 R-sq: within = 0.0651 Obs per group: min = 5 between = 0.3937 avg = 5.0 overall = 0.3428 max = 5 Random effects u_i ~ Gaussian Wald chi2(7) = 733.33 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ wagel | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .0457623 .0051667 8.86 0.000 .0356357 .0558888 exp2 | -.0006163 .0001265 -4.87 0.000 -.0008643 -.0003683 tenure | .0211529 .0029131 7.26 0.000 .0154433 .0268624 tenure2 | -.0005285 .0001244 -4.25 0.000 -.0007722 -.0002847 union | .0818419 .0198846 4.12 0.000 .0428688 .1208151 black | -.1912595 .0383901 -4.98 0.000 -.2665027 -.1160163 educ | .1236157 .0071699 17.24 0.000 .1095629 .1376684 _cons | .0727456 .1087702 0.67 0.504 -.1404401 .2859314 -------------+---------------------------------------------------------------- sigma_u | .37808923 sigma_e | .23422628 rho | .72265808 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . * get hausman test statistic; . hausman fixed .; ---- Coefficients ---- | (b) (B) (b-B) sqrt(diag(V_b-V_B)) | fixed . Difference S.E. -------------+---------------------------------------------------------------- exp | .0552342 .0457623 .009472 .0040664 exp2 | -.0006522 -.0006163 -.0000359 .0001043 tenure | .0177614 .0211529 -.0033914 .0014268 tenure2 | -.0005063 -.0005285 .0000222 .0000679 union | .0520794 .0818419 -.0297625 .0127151 ------------------------------------------------------------------------------ b = consistent under Ho and Ha; obtained from xtreg B = inconsistent under Ha, efficient under Ho; obtained from xtreg Test: Ho: difference in coefficients not systematic chi2(5) = (b-B)'[(V_b-V_B)^(-1)](b-B) = 30.40 Prob>chi2 = 0.0000 . * for completeness, get between group estimates; . xtreg wagel exp exp2 tenure tenure2 union black educ, be; Between regression (regression on group means) Number of obs = 3945 Group variable: id Number of groups = 789 R-sq: within = 0.0504 Obs per group: min = 5 between = 0.4065 avg = 5.0 overall = 0.3505 max = 5 F(7,781) = 76.43 sd(u_i + avg(e_i.))= .3923313 Prob > F = 0.0000 ------------------------------------------------------------------------------ wagel | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .0308177 .008397 3.67 0.000 .0143344 .047301 exp2 | -.0003687 .0002037 -1.81 0.071 -.0007687 .0000312 tenure | .0342018 .0065999 5.18 0.000 .0212463 .0471574 tenure2 | -.0008466 .0002666 -3.18 0.002 -.0013698 -.0003233 union | .1365755 .0376218 3.63 0.000 .0627237 .2104272 black | -.2136727 .0386318 -5.53 0.000 -.2895071 -.1378383 educ | .1214292 .0073865 16.44 0.000 .1069296 .1359289 _cons | .1974229 .1222502 1.61 0.107 -.042555 .4374007 ------------------------------------------------------------------------------ . end of do-file . log close log: d:\bill\fall2008\ecoe60303\psid1.log log type: text closed on: 9 Sep 2008, 21:49:05 -------------------------------------------------------------------------------