------------------------------------------------------------------------------- log: d:\bill\fall2008\econ30331\pums80.log log type: text opened on: 29 Nov 2008, 11:55:14 . *read in stata data file; . use pums80; . * get a description of variables; . * in the data set; . desc; Contains data from pums80.dta obs: 254,654 vars: 15 17 Aug 2006 12:18 size: 6,621,004 (73.3% of memory free) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- kidcount byte %9.0g number of kids morekids byte %9.0g =1 if mom had more than 2 kids boy1st byte %9.0g =1 if 1st kid was a boy boy2nd byte %9.0g =1 if 2nd kid was a boy samesex byte %9.0g =1 if 1st two kids same sex multi2nd byte %9.0g =1 if 2nd and 3rd kidss are twins agem1 byte %9.0g age of mom at census agefstm byte %9.0g moms age when she 1st gave birth black byte %9.0g =1 if mom is black hispan byte %9.0g =1 if mom is hispanic othrace byte %9.0g =1 if mom is othrace workedm byte %9.0g did mom work for pay i 1979 weeksm1 byte %9.0g moms weeks worked in 1979 hourswm byte %9.0g hours of work per week in 1979 incomem float %9.0g labor income per week, 1979, constant $ ------------------------------------------------------------------------------- Sorted by: . * generate some new variables; . gen twoboys=boy1st*boy2nd; . gen twogirls=(1-boy1st)*(1-boy2nd); . * get descriptive statistics; . * 1980 married women sample; . * these are in column 3, Table 2; . sum kidcount morekids boy1st boy2nd twoboys > twogirls samesex multi2nd agem1 agefstm > workedm weeksm1; Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- kidcount | 254654 2.507799 .7693323 2 12 morekids | 254654 .3805634 .4855263 0 1 boy1st | 254654 .5143607 .4997947 0 1 boy2nd | 254654 .5125504 .4998434 0 1 twoboys | 254654 .2662397 .4419919 0 1 -------------+-------------------------------------------------------- twogirls | 254654 .2393287 .4266745 0 1 samesex | 254654 .5055683 .49997 0 1 multi2nd | 254654 .0083172 .0908186 0 1 agem1 | 254654 30.39327 3.386447 21 35 agefstm | 254654 20.83164 2.921183 15 33 -------------+-------------------------------------------------------- workedm | 254654 .5282187 .4992041 0 1 weeksm1 | 254654 19.01833 21.86728 0 52 . * get correlation coefficient between; . * instrument and endogenous RHS variable; . * correlation coefficient is 0.0695; . corr morekids samesex; (obs=254654) | morekids samesex -------------+------------------ morekids | 1.0000 samesex | 0.0695 1.0000 . * OLS of bivariate regression; . * model assuming OLS model is correct; . * specification; . reg worked morekids; Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 1,254652) = 3237.65 Model | 796.712284 1 796.712284 Prob > F = 0.0000 Residual | 62664.0083254652 .246077032 R-squared = 0.0126 -------------+------------------------------ Adj R-squared = 0.0126 Total | 63460.7206254653 .249204685 Root MSE = .49606 ------------------------------------------------------------------------------ workedm | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- morekids | -.1152029 .0020246 -56.90 0.000 -.1191712 -.1112347 _cons | .5720607 .001249 458.02 0.000 .5696127 .5745087 ------------------------------------------------------------------------------ . * wald estimate; . * using the notation from class, if we have y,x,z,w; . * syntax for ivregress; . * ivregress 2sls y w (x=z); . * in this case, w=null,y=worked, x=morekids, z=samesex; . ivregress 2sls worked (morekids=samesex); Instrumental variables (2SLS) regression Number of obs = 254654 Wald chi2(1) = 22.33 Prob > chi2 = 0.0000 R-squared = 0.0121 Root MSE = .49618 ------------------------------------------------------------------------------ workedm | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- morekids | -.1376139 .0291242 -4.73 0.000 -.1946962 -.0805315 _cons | .5805895 .0111271 52.18 0.000 .5587807 .6023983 ------------------------------------------------------------------------------ Instrumented: morekids Instruments: samesex . * notice that ratio of OLS standard error; . * to IV std error on MOREKIDS is 0.0020246/0.0291243; . * which equals 0.0695, the rho(morekids,samesex); . * 1st stage estimates; . * married women sample; . * these numbers are in Table 6, columns 4-6; . *column (4); . reg morekids samesex agem1 agefstm black hispan othrace; Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 6,254647) = 3756.08 Model | 4880.82564 6 813.47094 Prob > F = 0.0000 Residual | 55150.0111254647 .21657436 R-squared = 0.0813 -------------+------------------------------ Adj R-squared = 0.0813 Total | 60030.8368254653 .235735832 Root MSE = .46538 ------------------------------------------------------------------------------ morekids | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- samesex | .0688381 .0018446 37.32 0.000 .0652228 .0724534 agem1 | .0304158 .0002981 102.05 0.000 .0298316 .031 agefstm | -.0435664 .0003462 -125.83 0.000 -.044245 -.0428878 black | .0680954 .0041858 16.27 0.000 .0598913 .0762995 hispan | .1261094 .0038979 32.35 0.000 .1184697 .1337491 othrace | .0478738 .0044214 10.83 0.000 .039208 .0565397 _cons | .3133116 .0091753 34.15 0.000 .2953282 .331295 ------------------------------------------------------------------------------ . * column (5); . reg morekids samesex boy1st boy2nd agem1 agefstm black hispan othrace; Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 8,254645) = 2825.70 Model | 4894.61525 8 611.826907 Prob > F = 0.0000 Residual | 55136.2215254645 .216521909 R-squared = 0.0815 -------------+------------------------------ Adj R-squared = 0.0815 Total | 60030.8368254653 .235735832 Root MSE = .46532 ------------------------------------------------------------------------------ morekids | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- samesex | .0693854 .0018456 37.59 0.000 .065768 .0730028 boy1st | -.0111225 .0018456 -6.03 0.000 -.0147398 -.0075051 boy2nd | -.0095472 .0018456 -5.17 0.000 -.0131646 -.0059298 agem1 | .0304246 .000298 102.09 0.000 .0298405 .0310087 agefstm | -.0435676 .0003462 -125.85 0.000 -.0442461 -.0428891 black | .0679715 .0041853 16.24 0.000 .0597684 .0761747 hispan | .125998 .0038974 32.33 0.000 .1183591 .1336369 othrace | .0479479 .0044209 10.85 0.000 .039283 .0566127 _cons | .3234167 .0092616 34.92 0.000 .3052642 .3415692 ------------------------------------------------------------------------------ . * column (6); . * test twoboys=twogirls, the two coefficients are the same; . * test twoboys=twogirls=0, the two coefficients equal zero; . * this second test is the also the 1st stage f-test; . reg morekids twoboys twogirls boy1st agem1 agefstm black hispan othrace; Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 8,254645) = 2825.70 Model | 4894.61525 8 611.826907 Prob > F = 0.0000 Residual | 55136.2215254645 .216521909 R-squared = 0.0815 -------------+------------------------------ Adj R-squared = 0.0815 Total | 60030.8368254653 .235735832 Root MSE = .46532 ------------------------------------------------------------------------------ morekids | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- twoboys | .0598382 .0025731 23.26 0.000 .0547951 .0648813 twogirls | .0789326 .0026467 29.82 0.000 .0737452 .08412 boy1st | -.0015753 .0026228 -0.60 0.548 -.0067158 .0035653 agem1 | .0304246 .000298 102.09 0.000 .0298405 .0310087 agefstm | -.0435676 .0003462 -125.85 0.000 -.0442461 -.0428891 black | .0679715 .0041853 16.24 0.000 .0597684 .0761747 hispan | .125998 .0038974 32.33 0.000 .1183591 .1336369 othrace | .0479479 .0044209 10.85 0.000 .039283 .0566127 _cons | .3138696 .0092684 33.86 0.000 .2957038 .3320353 ------------------------------------------------------------------------------ . test twoboys=twogirls; ( 1) twoboys - twogirls = 0 F( 1,254645) = 26.76 Prob > F = 0.0000 . test twoboys twogirls; ( 1) twoboys = 0 ( 2) twogirls = 0 F( 2,254645) = 715.13 Prob > F = 0.0000 . * demonstrate 1st stage and reduced form results for; . * exactly identified model; . * 1st stage; . reg morekids samesex boy1st boy2nd agem1 agefstm black hispan othrace; Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 8,254645) = 2825.70 Model | 4894.61525 8 611.826907 Prob > F = 0.0000 Residual | 55136.2215254645 .216521909 R-squared = 0.0815 -------------+------------------------------ Adj R-squared = 0.0815 Total | 60030.8368254653 .235735832 Root MSE = .46532 ------------------------------------------------------------------------------ morekids | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- samesex | .0693854 .0018456 37.59 0.000 .065768 .0730028 boy1st | -.0111225 .0018456 -6.03 0.000 -.0147398 -.0075051 boy2nd | -.0095472 .0018456 -5.17 0.000 -.0131646 -.0059298 agem1 | .0304246 .000298 102.09 0.000 .0298405 .0310087 agefstm | -.0435676 .0003462 -125.85 0.000 -.0442461 -.0428891 black | .0679715 .0041853 16.24 0.000 .0597684 .0761747 hispan | .125998 .0038974 32.33 0.000 .1183591 .1336369 othrace | .0479479 .0044209 10.85 0.000 .039283 .0566127 _cons | .3234167 .0092616 34.92 0.000 .3052642 .3415692 ------------------------------------------------------------------------------ . * reduced form; . * look at the t-stat on the same sex variable and compare later on; . * to the t-stat in the 2sls model; . reg worked samesex boy1st boy2nd agem1 agefstm black hispan othrace; Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 8,254645) = 845.42 Model | 1641.9059 8 205.238237 Prob > F = 0.0000 Residual | 61818.8147254645 .242764691 R-squared = 0.0259 -------------+------------------------------ Adj R-squared = 0.0258 Total | 63460.7206254653 .249204685 Root MSE = .49271 ------------------------------------------------------------------------------ workedm | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- samesex | -.0083481 .0019543 -4.27 0.000 -.0121785 -.0045178 boy1st | .0022593 .0019543 1.16 0.248 -.001571 .0060897 boy2nd | -.0036827 .0019543 -1.88 0.060 -.0075131 .0001477 agem1 | .0182747 .0003156 57.91 0.000 .0176562 .0188932 agefstm | -.0212493 .0003666 -57.97 0.000 -.0219677 -.0205308 black | .1817984 .0044317 41.02 0.000 .1731124 .1904845 hispan | -.0290676 .0041269 -7.04 0.000 -.0371561 -.020979 othrace | .0385856 .0046811 8.24 0.000 .0294107 .0477605 _cons | .4109847 .0098068 41.91 0.000 .3917636 .4302058 ------------------------------------------------------------------------------ . * ols and 2sls results; . * 1980 pums; . * married women sample; . * table 7, columns 4-6; . * ols worked for pay model; . reg workedm morekids boy1st boy2nd agem1 agefstm black hispan othrace; Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 8,254645) = 1677.51 Model | 3177.01064 8 397.126329 Prob > F = 0.0000 Residual | 60283.7099254645 .23673628 R-squared = 0.0501 -------------+------------------------------ Adj R-squared = 0.0500 Total | 63460.7206254653 .249204685 Root MSE = .48656 ------------------------------------------------------------------------------ workedm | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- morekids | -.1666381 .0020664 -80.64 0.000 -.1706882 -.162588 boy1st | .0004847 .0019294 0.25 0.802 -.0032968 .0042663 boy2nd | -.005183 .0019292 -2.69 0.007 -.0089641 -.0014019 agem1 | .0233422 .0003179 73.43 0.000 .0227192 .0239653 agefstm | -.0285071 .000373 -76.43 0.000 -.0292382 -.0277761 black | .1931062 .0043786 44.10 0.000 .1845243 .2016881 hispan | -.0080686 .0040836 -1.98 0.048 -.0160724 -.0000648 othrace | .0465627 .0046237 10.07 0.000 .0375004 .055625 _cons | .4664446 .0096667 48.25 0.000 .447498 .4853911 ------------------------------------------------------------------------------ . * 2sls worked for pay model; . * same sex as instrument; . reg workedm morekids boy1st boy2nd agem1 agefstm black hispan othrace > (samesex boy1st boy2nd agem1 agefstm black hispan othrace); Instrumental variables (2SLS) regression Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 8,254645) = 865.24 Model | 3058.04132 8 382.255165 Prob > F = 0.0000 Residual | 60402.6792254645 .237203476 R-squared = 0.0482 -------------+------------------------------ Adj R-squared = 0.0482 Total | 63460.7206254653 .249204685 Root MSE = .48704 ------------------------------------------------------------------------------ workedm | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- morekids | -.1203151 .0278412 -4.32 0.000 -.1748831 -.0657471 boy1st | .0009211 .0019489 0.47 0.636 -.0028987 .0047409 boy2nd | -.0048314 .0019425 -2.49 0.013 -.0086387 -.001024 agem1 | .0219352 .0009013 24.34 0.000 .0201686 .0237018 agefstm | -.0264911 .0012647 -20.95 0.000 -.0289699 -.0240123 black | .1899764 .0047675 39.85 0.000 .1806323 .1993205 hispan | -.0139081 .0053813 -2.58 0.010 -.0244554 -.0033609 othrace | .0443545 .0048138 9.21 0.000 .0349196 .0537893 _cons | .4498966 .0138565 32.47 0.000 .4227383 .4770549 ------------------------------------------------------------------------------ . * can also do by ivregress; . * there are 4 variables, y,x,w and z as we have defined them in class. > * the syntax is ivregress 2sls y w (x=z); . ivregress 2sls workedm boy1st boy2nd agem1 agefstm black hispan othrace > (morekids=samesex); Instrumental variables (2SLS) regression Number of obs = 254654 Wald chi2(8) = 6922.17 Prob > chi2 = 0.0000 R-squared = 0.0482 Root MSE = .48703 ------------------------------------------------------------------------------ workedm | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- morekids | -.1203151 .0278407 -4.32 0.000 -.1748818 -.0657483 boy1st | .0009211 .0019489 0.47 0.636 -.0028986 .0047409 boy2nd | -.0048314 .0019425 -2.49 0.013 -.0086386 -.0010241 agem1 | .0219352 .0009013 24.34 0.000 .0201687 .0237018 agefstm | -.0264911 .0012647 -20.95 0.000 -.0289698 -.0240124 black | .1899764 .0047674 39.85 0.000 .1806325 .1993203 hispan | -.0139081 .0053812 -2.58 0.010 -.0244551 -.0033611 othrace | .0443545 .0048137 9.21 0.000 .0349198 .0537891 _cons | .4498966 .0138562 32.47 0.000 .4227389 .4770543 ------------------------------------------------------------------------------ Instrumented: morekids Instruments: boy1st boy2nd agem1 agefstm black hispan othrace samesex . * 2sls worked for pay model; . * 2boys 2girls as instruments; . ivregress 2sls workedm boy1st agem1 agefstm black hispan othrace > (morekids=twoboys twogirls boy1st agem1 agefstm black hispan othrace); Instrumental variables (2SLS) regression Number of obs = 254654 Wald chi2(7) = 6911.04 Prob > chi2 = 0.0000 R-squared = 0.0475 Root MSE = .4872 ------------------------------------------------------------------------------ workedm | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- morekids | -.1127816 .0276854 -4.07 0.000 -.167044 -.0585193 boy1st | .0009424 .0019496 0.48 0.629 -.0028786 .0047635 agem1 | .0217057 .0008969 24.20 0.000 .0199478 .0234635 agefstm | -.0261649 .0012583 -20.79 0.000 -.0286312 -.0236987 black | .1895035 .0047653 39.77 0.000 .1801637 .1988433 hispan | -.014818 .0053707 -2.76 0.006 -.0253444 -.0042916 othrace | .0439784 .004813 9.14 0.000 .034545 .0534118 _cons | .4448388 .0137111 32.44 0.000 .4179656 .4717121 ------------------------------------------------------------------------------ Instrumented: morekids Instruments: boy1st agem1 agefstm black hispan othrace twoboys twogirls . * ols weeks worked model; . reg weeksm1 morekids boy1st boy2nd agem1 agefstm black hispan othrace; Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 8,254645) = 2378.13 Model | 8465176.09 8 1058147.01 Prob > F = 0.0000 Residual | 113304239254645 444.94979 R-squared = 0.0695 -------------+------------------------------ Adj R-squared = 0.0695 Total | 121769415254653 478.177816 Root MSE = 21.094 ------------------------------------------------------------------------------ weeksm1 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- morekids | -8.044995 .089585 -89.80 0.000 -8.22058 -7.869411 boy1st | -.0477043 .083645 -0.57 0.568 -.2116462 .1162377 boy2nd | -.1722542 .0836359 -2.06 0.039 -.3361784 -.00833 agem1 | 1.333901 .013781 96.79 0.000 1.306891 1.360912 agefstm | -1.357186 .0161703 -83.93 0.000 -1.388879 -1.325493 black | 10.83386 .189826 57.07 0.000 10.4618 11.20591 hispan | -.043496 .1770388 -0.25 0.806 -.3904874 .3034954 othrace | 2.82679 .2004528 14.10 0.000 2.433908 3.219672 _cons | 9.207843 .4190861 21.97 0.000 8.386445 10.02924 ------------------------------------------------------------------------------ . * 2sls weeks worked model; . * same sex as instrument; . reg weeksm1 morekids boy1st boy2nd agem1 agefstm black hispan othrace > (samesex boy1st boy2nd agem1 agefstm black hispan othrace); Instrumental variables (2SLS) regression Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 8,254645) = 1367.88 Model | 8077637.52 8 1009704.69 Prob > F = 0.0000 Residual | 113691778254645 446.471668 R-squared = 0.0663 -------------+------------------------------ Adj R-squared = 0.0663 Total | 121769415254653 478.177816 Root MSE = 21.13 ------------------------------------------------------------------------------ weeksm1 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- morekids | -5.401144 1.207881 -4.47 0.000 -7.768559 -3.033729 boy1st | -.0227965 .0845529 -0.27 0.787 -.1885179 .1429249 boy2nd | -.1521854 .0842763 -1.81 0.071 -.3173647 .012994 agem1 | 1.253598 .039104 32.06 0.000 1.176955 1.330241 agefstm | -1.242123 .0548684 -22.64 0.000 -1.349664 -1.134582 black | 10.65523 .2068347 51.52 0.000 10.24984 11.06062 hispan | -.3767812 .2334672 -1.61 0.107 -.8343707 .0808084 othrace | 2.700756 .2088444 12.93 0.000 2.291426 3.110085 _cons | 8.26338 .601158 13.75 0.000 7.085126 9.441634 ------------------------------------------------------------------------------ . * 2sls weeks worked model; . * 2boys 2girls as instruments; . ivreg weeksm1 boy1st agem1 agefstm black hispan othrace > (morekids=twoboys twogirls boy1st agem1 agefstm black hispan othrace); Instrumental variables (2SLS) regression Source | SS df MS Number of obs = 254654 -------------+------------------------------ F( 7,254646) = 1561.82 Model | 8003509.89 7 1143358.56 Prob > F = 0.0000 Residual | 113765906254646 446.761015 R-squared = 0.0657 -------------+------------------------------ Adj R-squared = 0.0657 Total | 121769415254653 478.177816 Root MSE = 21.137 ------------------------------------------------------------------------------ weeksm1 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- morekids | -5.163845 1.201101 -4.30 0.000 -7.517971 -2.80972 boy1st | -.0221262 .0845795 -0.26 0.794 -.1878997 .1436472 agem1 | 1.246366 .0389111 32.03 0.000 1.170102 1.322631 agefstm | -1.23185 .0545903 -22.57 0.000 -1.338845 -1.124854 black | 10.64033 .2067371 51.47 0.000 10.23513 11.04553 hispan | -.4054408 .2330026 -1.74 0.082 -.8621197 .0512381 othrace | 2.688909 .208809 12.88 0.000 2.279649 3.098169 _cons | 8.104064 .5948415 13.62 0.000 6.93819 9.269937 ------------------------------------------------------------------------------ Instrumented: morekids Instruments: boy1st agem1 agefstm black hispan othrace twoboys twogirls ------------------------------------------------------------------------------ . log close; log: d:\bill\fall2008\econ30331\pums80.log log type: text closed on: 29 Nov 2008, 11:55:23 -------------------------------------------------------------------------------