------------------------------------------------------------------------------- log: d:\www\ecoe60303\stata\psid3.log log type: text opened on: 7 Feb 2008, 23:17:45 . *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 ------------------------------------------------------------------------------ . * now estimate a model with fixed effects; . * the xi command is used to construct a series of; . * dummy variables. suppose you have a variable ; . * x2 that has four values, 1,2,3,4. i.x2 will; . * construct a set of 3 dummy variables, one for; . * x2=1, x2=3 and x2=4. > > * notice that in the within group model, you; . * must delete variables without any within-panel; . * variation. in this case, educ and black; . xi: reg wagel exp exp2 tenure tenure2 union i.id; i.id _Iid_48-9830 (naturally coded; _Iid_48 omitted) Source | SS df MS Number of obs = 3945 -------------+------------------------------ F(793, 3151) = 23.57 Model | 1025.60255 793 1.29331973 Prob > F = 0.0000 Residual | 172.870007 3151 .054861951 R-squared = 0.8558 -------------+------------------------------ Adj R-squared = 0.8195 Total | 1198.47255 3944 .303872352 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 _Iid_86 | .682228 .1504772 4.53 0.000 .3871847 .9772712 _Iid_95 | .9821343 .1496548 6.56 0.000 .6887034 1.275565 DELETE SOME RESULTS _Iid_9796 | .4389245 .1501989 2.92 0.003 .1444271 .733422 _Iid_9809 | .1902068 .1520671 1.25 0.211 -.1079537 .4883674 _Iid_9830 | -.0569339 .1485657 -0.38 0.702 -.3482291 .2343614 _cons | .8315394 .1287015 6.46 0.000 .5791923 1.083887 ------------------------------------------------------------------------------ . *sort the data by id; . sort 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) . log close; log: d:\www\ecoe60303\stata\psid3.log log type: text closed on: 7 Feb 2008, 23:18:29 -------------------------------------------------------------------------------