-------------------------------------------------------------------------------------------------------------------- name: log: /Users/denisardalves/Documents/Cap7Wooldridge.txt log type: text opened on: 13 Jun 2017, 12:02:06 . . . ****USO DE DUMMIES NA REG. LINAR MULTIPLA**** . . ***Regressão com uma Informação Qualitatiiva*** . . **Exemplo 7.1: Hourly Wage Equation** . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/WAGE1.DTA", clear . . . . reg wage female educ exper tenure Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(4, 521) = 74.40 Model | 2603.10658 4 650.776644 Prob > F = 0.0000 Residual | 4557.30771 521 8.7472317 R-squared = 0.3635 -------------+---------------------------------- Adj R-squared = 0.3587 Total | 7160.41429 525 13.6388844 Root MSE = 2.9576 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | -1.810852 .2648252 -6.84 0.000 -2.331109 -1.290596 educ | .5715048 .0493373 11.58 0.000 .4745802 .6684293 exper | .0253959 .0115694 2.20 0.029 .0026674 .0481243 tenure | .1410051 .0211617 6.66 0.000 .0994323 .1825778 _cons | -1.567939 .7245511 -2.16 0.031 -2.991339 -.144538 ------------------------------------------------------------------------------ . . *Salário médio das mulheres* . . reg wage female Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(1, 524) = 68.54 Model | 828.220467 1 828.220467 Prob > F = 0.0000 Residual | 6332.19382 524 12.0843394 R-squared = 0.1157 -------------+---------------------------------- Adj R-squared = 0.1140 Total | 7160.41429 525 13.6388844 Root MSE = 3.4763 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | -2.51183 .3034092 -8.28 0.000 -3.107878 -1.915782 _cons | 7.099489 .2100082 33.81 0.000 6.686928 7.51205 ------------------------------------------------------------------------------ . . *Usando o teste de restrições lineares nos coeficientes: . . lincom female + _cons ( 1) female + _cons = 0 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 4.587659 .2189834 20.95 0.000 4.157466 5.017852 ------------------------------------------------------------------------------ . . ***Exemplo 7.2: Effects of Computer Ownership on College GPA . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/gpa1.dta",clear . reg colGPA PC hsGPA ACT Source | SS df MS Number of obs = 141 -------------+---------------------------------- F(3, 137) = 12.83 Model | 4.25741863 3 1.41913954 Prob > F = 0.0000 Residual | 15.1486808 137 .110574313 R-squared = 0.2194 -------------+---------------------------------- Adj R-squared = 0.2023 Total | 19.4060994 140 .138614996 Root MSE = .33253 ------------------------------------------------------------------------------ colGPA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- PC | .1573092 .0572875 2.75 0.007 .0440271 .2705913 hsGPA | .4472417 .0936475 4.78 0.000 .2620603 .632423 ACT | .008659 .0105342 0.82 0.413 -.0121717 .0294897 _cons | 1.26352 .3331255 3.79 0.000 .6047871 1.922253 ------------------------------------------------------------------------------ . . reg colGPA PC Source | SS df MS Number of obs = 141 -------------+---------------------------------- F(1, 139) = 7.31 Model | .970092892 1 .970092892 Prob > F = 0.0077 Residual | 18.4360066 139 .132633141 R-squared = 0.0500 -------------+---------------------------------- Adj R-squared = 0.0432 Total | 19.4060994 140 .138614996 Root MSE = .36419 ------------------------------------------------------------------------------ colGPA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- PC | .1695168 .0626805 2.70 0.008 .0455864 .2934472 _cons | 2.989412 .0395018 75.68 0.000 2.91131 3.067514 ------------------------------------------------------------------------------ . . ***Exemplo 7.3: Effects of Training Grants on Hours of Training in 1988. . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/jtrain.dta", clear . . reg hrsemp grant lsales lemploy if year==1988 Source | SS df MS Number of obs = 105 -------------+---------------------------------- F(3, 101) = 10.44 Model | 18622.7268 3 6207.57559 Prob > F = 0.0000 Residual | 60031.0921 101 594.367249 R-squared = 0.2368 -------------+---------------------------------- Adj R-squared = 0.2141 Total | 78653.8189 104 756.28672 Root MSE = 24.38 ------------------------------------------------------------------------------ hrsemp | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- grant | 26.2545 5.591765 4.70 0.000 15.16194 37.34705 lsales | -.9845809 3.539903 -0.28 0.781 -8.006797 6.037635 lemploy | -6.069871 3.882893 -1.56 0.121 -13.77249 1.632744 _cons | 46.66508 43.4121 1.07 0.285 -39.45284 132.783 ------------------------------------------------------------------------------ . . ***Exemplo 7.4: Housing Price Regression . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/HPRICE1.DTA", clear . . reg lprice llotsize lsqrft bdrms colonial Source | SS df MS Number of obs = 88 -------------+---------------------------------- F(4, 83) = 38.38 Model | 5.20397919 4 1.3009948 Prob > F = 0.0000 Residual | 2.81362433 83 .033899088 R-squared = 0.6491 -------------+---------------------------------- Adj R-squared = 0.6322 Total | 8.01760352 87 .092156362 Root MSE = .18412 ------------------------------------------------------------------------------ lprice | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- llotsize | .1678189 .0381807 4.40 0.000 .0918791 .2437587 lsqrft | .7071931 .092802 7.62 0.000 .5226138 .8917725 bdrms | .0268305 .0287236 0.93 0.353 -.0302995 .0839605 colonial | .0537962 .0447732 1.20 0.233 -.035256 .1428483 _cons | -1.349589 .651041 -2.07 0.041 -2.644483 -.0546947 ------------------------------------------------------------------------------ . . ***Example 7.5: Log Hourly Wage Equation . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/WAGE1.DTA", clear . . reg lwage female educ exper expersq tenure tenursq Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(6, 519) = 68.18 Model | 65.3791009 6 10.8965168 Prob > F = 0.0000 Residual | 82.9506505 519 .159827843 R-squared = 0.4408 -------------+---------------------------------- Adj R-squared = 0.4343 Total | 148.329751 525 .28253286 Root MSE = .39978 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | -.296511 .0358055 -8.28 0.000 -.3668524 -.2261696 educ | .0801967 .0067573 11.87 0.000 .0669217 .0934716 exper | .0294324 .0049752 5.92 0.000 .0196585 .0392063 expersq | -.0005827 .0001073 -5.43 0.000 -.0007935 -.0003719 tenure | .0317139 .0068452 4.63 0.000 .0182663 .0451616 tenursq | -.0005852 .0002347 -2.49 0.013 -.0010463 -.0001241 _cons | .416691 .0989279 4.21 0.000 .2223425 .6110394 ------------------------------------------------------------------------------ . . ***Difference between woman's and man's wage*** . . . di exp(_b[female]*1)-1 -.25659255 . . . *Agora vamos criar interações entre variáveis, co exemploe seguinte, . *tb usando expressõesw para se criar dummies . . **Exemplo 7.6: Log Hourly Wage Equation . . drop single male marrmale marrfem singfem . *Formas de se criar Dummies no Stata . . . gen male = 0 . replace male = 1 if female==0 (274 real changes made) . . *Mas, missing values podem ocorer temos de cuidar deles: . . drop male . . gen male = 0 . replace male = 1 if female==0 (274 real changes made) . replace male = . if missing(female) (0 real changes made) . *ou . drop male . gen male = female==1 if !missing(female) . *ou . . drop male . gen male = (!female) . gen single = (~married) . gen marrmale = (married & ~female) . gen marrfem = (married & female) . gen singfem = (female & ~married) . gen singmale = (~female & ~married) . reg lwage marrmale marrfem singfem educ exper expersq tenure tenursq Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(8, 517) = 55.25 Model | 68.3617623 8 8.54522029 Prob > F = 0.0000 Residual | 79.9679891 517 .154676961 R-squared = 0.4609 -------------+---------------------------------- Adj R-squared = 0.4525 Total | 148.329751 525 .28253286 Root MSE = .39329 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- marrmale | .2126757 .0553572 3.84 0.000 .103923 .3214284 marrfem | -.1982676 .0578355 -3.43 0.001 -.311889 -.0846462 singfem | -.1103502 .0557421 -1.98 0.048 -.219859 -.0008414 educ | .0789103 .0066945 11.79 0.000 .0657585 .092062 exper | .0268006 .0052428 5.11 0.000 .0165007 .0371005 expersq | -.0005352 .0001104 -4.85 0.000 -.0007522 -.0003183 tenure | .0290875 .006762 4.30 0.000 .0158031 .0423719 tenursq | -.0005331 .0002312 -2.31 0.022 -.0009874 -.0000789 _cons | .3213781 .100009 3.21 0.001 .1249041 .5178521 ------------------------------------------------------------------------------ . . *Difference in lwage between married and single women . . lincom singfem-marrfem ( 1) - marrfem + singfem = 0 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .0879174 .0523481 1.68 0.094 -.0149238 .1907586 ------------------------------------------------------------------------------ . . reg lwage marrmale singmale singfem educ exper expersq tenure tenursq Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(8, 517) = 55.25 Model | 68.3617623 8 8.54522029 Prob > F = 0.0000 Residual | 79.9679891 517 .154676961 R-squared = 0.4609 -------------+---------------------------------- Adj R-squared = 0.4525 Total | 148.329751 525 .28253286 Root MSE = .39329 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- marrmale | .4109433 .0457709 8.98 0.000 .3210234 .5008631 singmale | .1982676 .0578355 3.43 0.001 .0846462 .311889 singfem | .0879174 .0523481 1.68 0.094 -.0149238 .1907586 educ | .0789103 .0066945 11.79 0.000 .0657585 .092062 exper | .0268006 .0052428 5.11 0.000 .0165007 .0371005 expersq | -.0005352 .0001104 -4.85 0.000 -.0007522 -.0003183 tenure | .0290875 .006762 4.30 0.000 .0158031 .0423719 tenursq | -.0005331 .0002312 -2.31 0.022 -.0009874 -.0000789 _cons | .1231105 .1057937 1.16 0.245 -.0847279 .3309488 ------------------------------------------------------------------------------ . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/NEdata", clear . *calculo da média da renda disponivel percapta de cada estado: . . . mean dpipc, over(state) Mean estimation Number of obs = 120 CT: state = CT MA: state = MA ME: state = ME NH: state = NH RI: state = RI VT: state = VT -------------------------------------------------------------- Over | Mean Std. Err. [95% Conf. Interval] -------------+------------------------------------------------ dpipc | CT | 22.32587 1.413766 19.52647 25.12527 MA | 19.77681 1.298507 17.20564 22.34798 ME | 15.17391 .9571251 13.27871 17.06911 NH | 18.66835 1.193137 16.30582 21.03088 RI | 17.26529 1.045117 15.19586 19.33473 VT | 15.73786 1.020159 13.71784 17.75788 -------------------------------------------------------------- . . *Existem diferenças, mas serão significantes? . . * Segunda forma de se gerar dummies,agora grupos de dummies: . . tabulate state, generate(NE) state | Freq. Percent Cum. ------------+----------------------------------- CT | 20 16.67 16.67 MA | 20 16.67 33.33 ME | 20 16.67 50.00 NH | 20 16.67 66.67 RI | 20 16.67 83.33 VT | 20 16.67 100.00 ------------+----------------------------------- Total | 120 100.00 . regress dpipc NE2-NE6 Source | SS df MS Number of obs = 120 -------------+---------------------------------- F(5, 114) = 5.27 Model | 716.218512 5 143.243702 Prob > F = 0.0002 Residual | 3099.85511 114 27.1917115 R-squared = 0.1877 -------------+---------------------------------- Adj R-squared = 0.1521 Total | 3816.07362 119 32.0678456 Root MSE = 5.2146 ------------------------------------------------------------------------------ dpipc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- NE2 | -2.549057 1.648991 -1.55 0.125 -5.815695 .7175814 NE3 | -7.151959 1.648991 -4.34 0.000 -10.4186 -3.88532 NE4 | -3.65752 1.648991 -2.22 0.029 -6.924158 -.3908815 NE5 | -5.060575 1.648991 -3.07 0.003 -8.327214 -1.793937 NE6 | -6.588007 1.648991 -4.00 0.000 -9.854646 -3.321369 _cons | 22.32587 1.166013 19.15 0.000 20.01601 24.63573 ------------------------------------------------------------------------------ . . *Exemplo com tabulate . . sysuse auto, clear (1978 Automobile Data) . describe Contains data from /Applications/Stata/ado/base/a/auto.dta obs: 74 1978 Automobile Data vars: 12 13 Apr 2016 17:45 size: 3,182 (_dta has notes) -------------------------------------------------------------------------------------------------------------------- storage display value variable name type format label variable label -------------------------------------------------------------------------------------------------------------------- make str18 %-18s Make and Model price int %8.0gc Price mpg int %8.0g Mileage (mpg) rep78 int %8.0g Repair Record 1978 headroom float %6.1f Headroom (in.) trunk int %8.0g Trunk space (cu. ft.) weight int %8.0gc Weight (lbs.) length int %8.0g Length (in.) turn int %8.0g Turn Circle (ft.) displacement int %8.0g Displacement (cu. in.) gear_ratio float %6.2f Gear Ratio foreign byte %8.0g origin Car type -------------------------------------------------------------------------------------------------------------------- Sorted by: foreign . sum rep78 Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- rep78 | 69 3.405797 .9899323 1 5 . * Um comando do Stata que faz a regressão com bloco de dummies é o areg, como vemos a seguir: . . areg price weight length, absorb(rep78) Linear regression, absorbing indicators Number of obs = 69 F( 2, 62) = 22.98 Prob > F = 0.0000 R-squared = 0.4341 Adj R-squared = 0.3793 Root MSE = 2294.5106 ------------------------------------------------------------------------------ price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- weight | 5.478309 1.158582 4.73 0.000 3.162337 7.794281 length | -109.5065 39.26104 -2.79 0.007 -187.9882 -31.02482 _cons | 10154.62 4270.525 2.38 0.021 1617.96 18691.27 -------------+---------------------------------------------------------------- rep78 | F(4, 62) = 2.079 0.094 (5 categories) . . tabulate rep78, gen(rep78) Repair | Record 1978 | Freq. Percent Cum. ------------+----------------------------------- 1 | 2 2.90 2.90 2 | 8 11.59 14.49 3 | 30 43.48 57.97 4 | 18 26.09 84.06 5 | 11 15.94 100.00 ------------+----------------------------------- Total | 69 100.00 . . reg price weight length rep782-rep785 Source | SS df MS Number of obs = 69 -------------+---------------------------------- F(6, 62) = 7.93 Model | 250380669 6 41730111.5 Prob > F = 0.0000 Residual | 326416290 62 5264778.86 R-squared = 0.4341 -------------+---------------------------------- Adj R-squared = 0.3793 Total | 576796959 68 8482308.22 Root MSE = 2294.5 ------------------------------------------------------------------------------ price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- weight | 5.478309 1.158582 4.73 0.000 3.162337 7.794281 length | -109.5065 39.26104 -2.79 0.007 -187.9882 -31.02482 rep782 | 1149.134 1821.448 0.63 0.530 -2491.889 4790.157 rep783 | 1322.082 1677.64 0.79 0.434 -2031.472 4675.637 rep784 | 2310.734 1714.842 1.35 0.183 -1117.186 5738.654 rep785 | 3545.927 1793.553 1.98 0.052 -39.33398 7131.187 _cons | 8278.473 4525.821 1.83 0.072 -768.5151 17325.46 ------------------------------------------------------------------------------ . . test rep782 rep783 rep784 rep785 ( 1) rep782 = 0 ( 2) rep783 = 0 ( 3) rep784 = 0 ( 4) rep785 = 0 F( 4, 62) = 2.08 Prob > F = 0.0942 . . ** Regressão com Duas Variáveis Qualitativas** . . * Dados do National Longitudinal Survey . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/nlsw88.dta", clear (NLSW, 1988 extract) . . keep if !missing(wage+race+union) (368 observations deleted) . . gen lwage=log(wage) . sum wage race unio tenure Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- wage | 1,878 7.565423 4.168369 1.151368 39.23074 race | 1,878 1.292332 .4822417 1 3 union | 1,878 .2454739 .4304825 0 1 tenure | 1,868 6.571065 5.640675 0 25.91667 . . tabulate race, generate(R) race | Freq. Percent Cum. ------------+----------------------------------- white | 1,353 72.04 72.04 black | 501 26.68 98.72 other | 24 1.28 100.00 ------------+----------------------------------- Total | 1,878 100.00 . . reg lwage R1 R2 union Source | SS df MS Number of obs = 1,878 -------------+---------------------------------- F(3, 1874) = 38.73 Model | 29.3349228 3 9.77830761 Prob > F = 0.0000 Residual | 473.119209 1,874 .252464893 R-squared = 0.0584 -------------+---------------------------------- Adj R-squared = 0.0569 Total | 502.454132 1,877 .267690001 Root MSE = .50246 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- R1 | -.0349326 .1035125 -0.34 0.736 -.2379444 .1680793 R2 | -.2133924 .1049954 -2.03 0.042 -.4193126 -.0074721 union | .239083 .0270353 8.84 0.000 .1860606 .2921054 _cons | 1.913178 .1029591 18.58 0.000 1.711252 2.115105 ------------------------------------------------------------------------------ . . test R1 R2 ( 1) R1 = 0 ( 2) R2 = 0 F( 2, 1874) = 23.25 Prob > F = 0.0000 . . *Supomos independência dos efeitos raça e sindicalização sobre lwage. . * Mas, será? . *Logo fazemos interação entre os efeitos: . . *lwage=b1+b2R1+b3R2 2+b4union+b5(R1xunion)+b6(R2xunion)+ u . . gen R1u=R1*union . gen R2u=R2*union . reg lwage R1 R2 union R1u R2u Source | SS df MS Number of obs = 1,878 -------------+---------------------------------- F(5, 1872) = 26.63 Model | 33.3636017 5 6.67272035 Prob > F = 0.0000 Residual | 469.09053 1,872 .250582548 R-squared = 0.0664 -------------+---------------------------------- Adj R-squared = 0.0639 Total | 502.454132 1,877 .267690001 Root MSE = .50058 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- R1 | -.1818955 .1260945 -1.44 0.149 -.4291962 .0654051 R2 | -.4152863 .1279741 -3.25 0.001 -.6662731 -.1642995 union | -.2375316 .2167585 -1.10 0.273 -.6626452 .187582 R1u | .4232627 .2192086 1.93 0.054 -.0066561 .8531816 R2u | .6193578 .2221704 2.79 0.005 .1836302 1.055085 _cons | 2.07205 .1251456 16.56 0.000 1.82661 2.317489 ------------------------------------------------------------------------------ . test R1u R2u ( 1) R1u = 0 ( 2) R2u = 0 F( 2, 1872) = 8.04 Prob > F = 0.0003 . . * Quantitativo e qualitativo . . gen uTen=union*tenure (10 missing values generated) . reg lwage R1 R2 union tenure uTen Source | SS df MS Number of obs = 1,868 -------------+---------------------------------- F(5, 1862) = 69.27 Model | 77.726069 5 15.5452138 Prob > F = 0.0000 Residual | 417.861297 1,862 .224415304 R-squared = 0.1568 -------------+---------------------------------- Adj R-squared = 0.1546 Total | 495.587366 1,867 .265445831 Root MSE = .47372 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- R1 | -.0715443 .0976332 -0.73 0.464 -.2630264 .1199377 R2 | -.2638742 .0990879 -2.66 0.008 -.4582093 -.0695391 union | .2380442 .0409706 5.81 0.000 .157691 .3183975 tenure | .0309616 .0023374 13.25 0.000 .0263774 .0355458 uTen | -.0068913 .0043112 -1.60 0.110 -.0153467 .001564 _cons | 1.766484 .0977525 18.07 0.000 1.574768 1.9582 ------------------------------------------------------------------------------ . . ***MODELO LINEAR DE PTOBABILIDADE*** . . *Participação da Mulher no Mercado de Trabalho** . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/MROZ.DTA", clear . . reg inlf nwifeinc educ exper expersq age kidslt6 kidsge6 Source | SS df MS Number of obs = 753 -------------+---------------------------------- F(7, 745) = 38.22 Model | 48.8080578 7 6.97257969 Prob > F = 0.0000 Residual | 135.919698 745 .182442547 R-squared = 0.2642 -------------+---------------------------------- Adj R-squared = 0.2573 Total | 184.727756 752 .245648611 Root MSE = .42713 ------------------------------------------------------------------------------ inlf | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- nwifeinc | -.0034052 .0014485 -2.35 0.019 -.0062488 -.0005616 educ | .0379953 .007376 5.15 0.000 .023515 .0524756 exper | .0394924 .0056727 6.96 0.000 .0283561 .0506287 expersq | -.0005963 .0001848 -3.23 0.001 -.0009591 -.0002335 age | -.0160908 .0024847 -6.48 0.000 -.0209686 -.011213 kidslt6 | -.2618105 .0335058 -7.81 0.000 -.3275875 -.1960335 kidsge6 | .0130122 .013196 0.99 0.324 -.0128935 .0389179 _cons | .5855192 .154178 3.80 0.000 .2828442 .8881943 ------------------------------------------------------------------------------ . . . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/WAGE1.DTA", clear . reg wage female educ exper tenure Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(4, 521) = 74.40 Model | 2603.10658 4 650.776644 Prob > F = 0.0000 Residual | 4557.30771 521 8.7472317 R-squared = 0.3635 -------------+---------------------------------- Adj R-squared = 0.3587 Total | 7160.41429 525 13.6388844 Root MSE = 2.9576 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | -1.810852 .2648252 -6.84 0.000 -2.331109 -1.290596 educ | .5715048 .0493373 11.58 0.000 .4745802 .6684293 exper | .0253959 .0115694 2.20 0.029 .0026674 .0481243 tenure | .1410051 .0211617 6.66 0.000 .0994323 .1825778 _cons | -1.567939 .7245511 -2.16 0.031 -2.991339 -.144538 ------------------------------------------------------------------------------ . . . reg wage female Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(1, 524) = 68.54 Model | 828.220467 1 828.220467 Prob > F = 0.0000 Residual | 6332.19382 524 12.0843394 R-squared = 0.1157 -------------+---------------------------------- Adj R-squared = 0.1140 Total | 7160.41429 525 13.6388844 Root MSE = 3.4763 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | -2.51183 .3034092 -8.28 0.000 -3.107878 -1.915782 _cons | 7.099489 .2100082 33.81 0.000 6.686928 7.51205 ------------------------------------------------------------------------------ . . . *Average wage for women . . lincom female+_cons ( 1) female + _cons = 0 ------------------------------------------------------------------------------ wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 4.587659 .2189834 20.95 0.000 4.157466 5.017852 ------------------------------------------------------------------------------ . . *Example 7.2: Effects of Computer Ownership on College GPA . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/gpa1.dta", clear . reg colGPA PC hsGPA ACT Source | SS df MS Number of obs = 141 -------------+---------------------------------- F(3, 137) = 12.83 Model | 4.25741863 3 1.41913954 Prob > F = 0.0000 Residual | 15.1486808 137 .110574313 R-squared = 0.2194 -------------+---------------------------------- Adj R-squared = 0.2023 Total | 19.4060994 140 .138614996 Root MSE = .33253 ------------------------------------------------------------------------------ colGPA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- PC | .1573092 .0572875 2.75 0.007 .0440271 .2705913 hsGPA | .4472417 .0936475 4.78 0.000 .2620603 .632423 ACT | .008659 .0105342 0.82 0.413 -.0121717 .0294897 _cons | 1.26352 .3331255 3.79 0.000 .6047871 1.922253 ------------------------------------------------------------------------------ . . . *Example 7.3: Effects of Training Grants on Hours of Training in 1988 . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/jtrain.dta", clear . reg hrsemp grant lsales lemploy if year==1988 Source | SS df MS Number of obs = 105 -------------+---------------------------------- F(3, 101) = 10.44 Model | 18622.7268 3 6207.57559 Prob > F = 0.0000 Residual | 60031.0921 101 594.367249 R-squared = 0.2368 -------------+---------------------------------- Adj R-squared = 0.2141 Total | 78653.8189 104 756.28672 Root MSE = 24.38 ------------------------------------------------------------------------------ hrsemp | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- grant | 26.2545 5.591765 4.70 0.000 15.16194 37.34705 lsales | -.9845809 3.539903 -0.28 0.781 -8.006797 6.037635 lemploy | -6.069871 3.882893 -1.56 0.121 -13.77249 1.632744 _cons | 46.66508 43.4121 1.07 0.285 -39.45284 132.783 ------------------------------------------------------------------------------ . . *Example 7.4: Housing Price Regression . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/HPRICE1.DTA", clear . reg lprice llotsize lsqrft bdrms colonial Source | SS df MS Number of obs = 88 -------------+---------------------------------- F(4, 83) = 38.38 Model | 5.20397919 4 1.3009948 Prob > F = 0.0000 Residual | 2.81362433 83 .033899088 R-squared = 0.6491 -------------+---------------------------------- Adj R-squared = 0.6322 Total | 8.01760352 87 .092156362 Root MSE = .18412 ------------------------------------------------------------------------------ lprice | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- llotsize | .1678189 .0381807 4.40 0.000 .0918791 .2437587 lsqrft | .7071931 .092802 7.62 0.000 .5226138 .8917725 bdrms | .0268305 .0287236 0.93 0.353 -.0302995 .0839605 colonial | .0537962 .0447732 1.20 0.233 -.035256 .1428483 _cons | -1.349589 .651041 -2.07 0.041 -2.644483 -.0546947 ------------------------------------------------------------------------------ . . *Example 7.5: Log Hourly Wage Equation . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/WAGE1.DTA", clear . reg lwage female educ exper expersq tenure tenursq Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(6, 519) = 68.18 Model | 65.3791009 6 10.8965168 Prob > F = 0.0000 Residual | 82.9506505 519 .159827843 R-squared = 0.4408 -------------+---------------------------------- Adj R-squared = 0.4343 Total | 148.329751 525 .28253286 Root MSE = .39978 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | -.296511 .0358055 -8.28 0.000 -.3668524 -.2261696 educ | .0801967 .0067573 11.87 0.000 .0669217 .0934716 exper | .0294324 .0049752 5.92 0.000 .0196585 .0392063 expersq | -.0005827 .0001073 -5.43 0.000 -.0007935 -.0003719 tenure | .0317139 .0068452 4.63 0.000 .0182663 .0451616 tenursq | -.0005852 .0002347 -2.49 0.013 -.0010463 -.0001241 _cons | .416691 .0989279 4.21 0.000 .2223425 .6110394 ------------------------------------------------------------------------------ . . . *Difference between woman's and man's wage . . di exp(_b[female]*1)-1 -.25659255 . . *Example 7.6: Log Hourly Wage Equation . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/WAGE1.DTA", clear . . drop single male marrmale marrfem singfem . . gen male = (!female) . gen single = (~married) . gen marrmale = (married & ~female) . gen marrfem = (married & female) . gen singfem = (female & ~married) . gen singmale = (~female & ~married) . reg lwage marrmale marrfem singfem educ exper expersq tenure tenursq Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(8, 517) = 55.25 Model | 68.3617623 8 8.54522029 Prob > F = 0.0000 Residual | 79.9679891 517 .154676961 R-squared = 0.4609 -------------+---------------------------------- Adj R-squared = 0.4525 Total | 148.329751 525 .28253286 Root MSE = .39329 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- marrmale | .2126757 .0553572 3.84 0.000 .103923 .3214284 marrfem | -.1982676 .0578355 -3.43 0.001 -.311889 -.0846462 singfem | -.1103502 .0557421 -1.98 0.048 -.219859 -.0008414 educ | .0789103 .0066945 11.79 0.000 .0657585 .092062 exper | .0268006 .0052428 5.11 0.000 .0165007 .0371005 expersq | -.0005352 .0001104 -4.85 0.000 -.0007522 -.0003183 tenure | .0290875 .006762 4.30 0.000 .0158031 .0423719 tenursq | -.0005331 .0002312 -2.31 0.022 -.0009874 -.0000789 _cons | .3213781 .100009 3.21 0.001 .1249041 .5178521 ------------------------------------------------------------------------------ . . *Difference in lwage between married and single women . . lincom singfem-marrfem ( 1) - marrfem + singfem = 0 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .0879174 .0523481 1.68 0.094 -.0149238 .1907586 ------------------------------------------------------------------------------ . . . *Example 7.8: Effects of Law School Rankings on Starting Salaries . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/lawsch85.dta", clear . gen r61_100 = (rank>60 & rank<101) . reg lsalary top10 r11_25 r26_40 r41_60 r61_100 LSAT GPA llibvol lcost Source | SS df MS Number of obs = 136 -------------+---------------------------------- F(9, 126) = 143.20 Model | 9.45224101 9 1.050249 Prob > F = 0.0000 Residual | .924110799 126 .007334213 R-squared = 0.9109 -------------+---------------------------------- Adj R-squared = 0.9046 Total | 10.3763518 135 .076861865 Root MSE = .08564 ------------------------------------------------------------------------------ lsalary | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- top10 | .6995659 .053492 13.08 0.000 .5937069 .8054249 r11_25 | .5935433 .03944 15.05 0.000 .5154926 .671594 r26_40 | .3750763 .0340812 11.01 0.000 .3076305 .442522 r41_60 | .262819 .0279621 9.40 0.000 .2074829 .3181551 r61_100 | .1315949 .0210419 6.25 0.000 .0899537 .1732361 LSAT | .0056909 .003063 1.86 0.066 -.0003707 .0117525 GPA | .0137257 .0741919 0.19 0.854 -.1330979 .1605494 llibvol | .0363619 .0260165 1.40 0.165 -.015124 .0878478 lcost | .0008411 .025136 0.03 0.973 -.0489024 .0505846 _cons | 9.165294 .4114243 22.28 0.000 8.351098 9.979491 ------------------------------------------------------------------------------ . . *Diferença no salário inicial entre escolas "top 10"e ""below 100" . . di exp(_b[top10]*1)-1 1.0128787 . . reg lsalary rank LSAT GPA llibvol lcost Source | SS df MS Number of obs = 136 -------------+---------------------------------- F(5, 130) = 138.23 Model | 8.73362207 5 1.74672441 Prob > F = 0.0000 Residual | 1.64272974 130 .012636383 R-squared = 0.8417 -------------+---------------------------------- Adj R-squared = 0.8356 Total | 10.3763518 135 .076861865 Root MSE = .11241 ------------------------------------------------------------------------------ lsalary | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- rank | -.0033246 .0003485 -9.54 0.000 -.004014 -.0026352 LSAT | .0046965 .0040105 1.17 0.244 -.0032378 .0126308 GPA | .2475239 .090037 2.75 0.007 .0693964 .4256514 llibvol | .0949932 .0332543 2.86 0.005 .0292035 .160783 lcost | .0375538 .0321061 1.17 0.244 -.0259642 .1010718 _cons | 8.343226 .5325192 15.67 0.000 7.2897 9.396752 ------------------------------------------------------------------------------ . . *Example 7.10: Log Hourly Wage Equation . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/WAGE1.DTA", clear . gen femed = female*educ . reg lwage female educ femed exper expersq tenure tenursq Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(7, 518) = 58.37 Model | 65.4081534 7 9.34402192 Prob > F = 0.0000 Residual | 82.921598 518 .160080305 R-squared = 0.4410 -------------+---------------------------------- Adj R-squared = 0.4334 Total | 148.329751 525 .28253286 Root MSE = .4001 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- female | -.2267886 .1675394 -1.35 0.176 -.5559289 .1023517 educ | .0823692 .0084699 9.72 0.000 .0657296 .0990088 femed | -.0055645 .0130618 -0.43 0.670 -.0312252 .0200962 exper | .0293366 .0049842 5.89 0.000 .019545 .0391283 expersq | -.0005804 .0001075 -5.40 0.000 -.0007916 -.0003691 tenure | .0318967 .006864 4.65 0.000 .018412 .0453814 tenursq | -.00059 .0002352 -2.51 0.012 -.001052 -.000128 _cons | .388806 .1186871 3.28 0.001 .1556388 .6219732 ------------------------------------------------------------------------------ . . *Example 7.11: Effects of Race on Baseball Player Salaries . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/mlb1.dta",clear . reg lsalary years gamesyr bavg hrunsyr rbisyr runsyr fldperc allstar black hispan blckpb hispph Source | SS df MS Number of obs = 330 -------------+---------------------------------- F(12, 317) = 46.48 Model | 283.782162 12 23.6485135 Prob > F = 0.0000 Residual | 161.2793 317 .508767508 R-squared = 0.6376 -------------+---------------------------------- Adj R-squared = 0.6239 Total | 445.061462 329 1.3527704 Root MSE = .71328 ------------------------------------------------------------------------------ lsalary | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- years | .0673458 .0128915 5.22 0.000 .0419822 .0927094 gamesyr | .0088778 .0033837 2.62 0.009 .0022205 .0155352 bavg | .0009451 .0015133 0.62 0.533 -.0020322 .0039225 hrunsyr | .0146206 .0164522 0.89 0.375 -.0177488 .04699 rbisyr | .0044938 .007575 0.59 0.553 -.0104098 .0193974 runsyr | .0072029 .0045671 1.58 0.116 -.0017827 .0161885 fldperc | .0010865 .0021195 0.51 0.609 -.0030835 .0052566 allstar | .0075307 .0028735 2.62 0.009 .0018771 .0131842 black | -.198008 .1254968 -1.58 0.116 -.4449199 .0489038 hispan | -.1900089 .1530902 -1.24 0.215 -.4912101 .1111923 blckpb | .0124513 .0049628 2.51 0.013 .0026872 .0222154 hispph | .0200863 .0097933 2.05 0.041 .0008182 .0393543 _cons | 10.34368 2.182538 4.74 0.000 6.049594 14.63777 ------------------------------------------------------------------------------ . . *Diferença em lwage entre negros e brancos em cidades com 10% de blacks . . lincom _b[black]+_b[blckpb]*10 ( 1) black + 10*blckpb = 0 ------------------------------------------------------------------------------ lsalary | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | -.0734953 .0997916 -0.74 0.462 -.2698328 .1228422 ------------------------------------------------------------------------------ . . *Diferença em lwage entre negros e brancos em cidades com 20% de blacks . . lincom _b[black]+_b[blckpb]*20 ( 1) black + 20*blckpb = 0 ------------------------------------------------------------------------------ lsalary | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .0510174 .0953577 0.54 0.593 -.1365965 .2386313 ------------------------------------------------------------------------------ . . . *Porcentagem de hispanicos quando salários de hispanicos e brancos são iguais . . di _b[hispan]*-1/_b[hispph] 9.4596496 . . . . *Example 7.12: A Linear Probability Model of Arrests . . use "/Users/denisardalves/Desktop/EAE 324 2017/DATA SET/crime1.dta", clear . . . . gen arr86=(~narr86) . . reg arr86 pcnv avgsen tottime ptime86 qemp86 Source | SS df MS Number of obs = 2,725 -------------+---------------------------------- F(5, 2719) = 27.03 Model | 25.8452455 5 5.16904909 Prob > F = 0.0000 Residual | 519.971268 2,719 .191236215 R-squared = 0.0474 -------------+---------------------------------- Adj R-squared = 0.0456 Total | 545.816514 2,724 .20037317 Root MSE = .43731 ------------------------------------------------------------------------------ arr86 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- pcnv | .1624448 .0212368 7.65 0.000 .120803 .2040866 avgsen | -.0061127 .006452 -0.95 0.344 -.018764 .0065385 tottime | .0022616 .0049781 0.45 0.650 -.0074997 .0120229 ptime86 | .0219664 .0046349 4.74 0.000 .0128781 .0310547 qemp86 | .0428294 .0054046 7.92 0.000 .0322319 .0534268 _cons | .5593846 .0172329 32.46 0.000 .5255937 .5931754 ------------------------------------------------------------------------------ . . * Impacto na probabilidade de ser preso se se pcnv aumentarv em .5 . . lincom _b[pcnv]*.5 ( 1) .5*pcnv = 0 ------------------------------------------------------------------------------ arr86 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .0812224 .0106184 7.65 0.000 .0604015 .1020433 ------------------------------------------------------------------------------ . . *Impacto na probabilidade de ser preso se ptime86 aumentasse para 6 . . lincom _b[ptime86]*6 ( 1) 6*ptime86 = 0 ------------------------------------------------------------------------------ arr86 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .1317984 .0278095 4.74 0.000 .0772686 .1863282 ------------------------------------------------------------------------------ . . *Impacto na probabilidade de ser preso se ptime86 aumentasse para 12 . . lincom _b[_cons]- _b[ptime86]*12 ( 1) - 12*ptime86 + _cons = 0 ------------------------------------------------------------------------------ arr86 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .2957878 .061983 4.77 0.000 .1742492 .4173264 ------------------------------------------------------------------------------ . . *Impacto na probabilidade de ser preso se qemp86 aumentasse em 4 . . . lincom _b[qemp86]*4 ( 1) 4*qemp86 = 0 ------------------------------------------------------------------------------ arr86 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .1713175 .0216182 7.92 0.000 .1289277 .2137073 ------------------------------------------------------------------------------ . . *Impacto de Dummies de raça na Probailiudade de ser preso . . reg arr86 pcnv avgsen tottime ptime86 qemp86 black hispan Source | SS df MS Number of obs = 2,725 -------------+---------------------------------- F(7, 2717) = 28.41 Model | 37.2205275 7 5.31721822 Prob > F = 0.0000 Residual | 508.595986 2,717 .187190278 R-squared = 0.0682 -------------+---------------------------------- Adj R-squared = 0.0658 Total | 545.816514 2,724 .20037317 Root MSE = .43265 ------------------------------------------------------------------------------ arr86 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- pcnv | .152062 .0210655 7.22 0.000 .1107561 .193368 avgsen | -.0046191 .0063888 -0.72 0.470 -.0171465 .0079083 tottime | .0025619 .0049259 0.52 0.603 -.0070969 .0122207 ptime86 | .0236954 .0045948 5.16 0.000 .0146858 .032705 qemp86 | .0384737 .0054016 7.12 0.000 .0278821 .0490653 black | -.1697631 .0236738 -7.17 0.000 -.2161836 -.1233426 hispan | -.0961866 .0207105 -4.64 0.000 -.1367965 -.0555766 _cons | .6195717 .0187272 33.08 0.000 .5828507 .6562927 ------------------------------------------------------------------------------ . . test black hispan ( 1) black = 0 ( 2) hispan = 0 F( 2, 2717) = 30.38 Prob > F = 0.0000 . . *Teste LM de restrições . reg arr86 pcnv avgsen tottime ptime86 qemp86 Source | SS df MS Number of obs = 2,725 -------------+---------------------------------- F(5, 2719) = 27.03 Model | 25.8452455 5 5.16904909 Prob > F = 0.0000 Residual | 519.971268 2,719 .191236215 R-squared = 0.0474 -------------+---------------------------------- Adj R-squared = 0.0456 Total | 545.816514 2,724 .20037317 Root MSE = .43731 ------------------------------------------------------------------------------ arr86 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- pcnv | .1624448 .0212368 7.65 0.000 .120803 .2040866 avgsen | -.0061127 .006452 -0.95 0.344 -.018764 .0065385 tottime | .0022616 .0049781 0.45 0.650 -.0074997 .0120229 ptime86 | .0219664 .0046349 4.74 0.000 .0128781 .0310547 qemp86 | .0428294 .0054046 7.92 0.000 .0322319 .0534268 _cons | .5593846 .0172329 32.46 0.000 .5255937 .5931754 ------------------------------------------------------------------------------ . predict res1, residuals . reg res1 pcnv avgsen tottime ptime86 qemp86 black hispan Source | SS df MS Number of obs = 2,725 -------------+---------------------------------- F(7, 2717) = 8.68 Model | 11.3752819 7 1.62504027 Prob > F = 0.0000 Residual | 508.595981 2,717 .187190277 R-squared = 0.0219 -------------+---------------------------------- Adj R-squared = 0.0194 Total | 519.971263 2,724 .190885192 Root MSE = .43265 ------------------------------------------------------------------------------ res1 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- pcnv | -.0103828 .0210655 -0.49 0.622 -.0516888 .0309231 avgsen | .0014936 .0063888 0.23 0.815 -.0110338 .014021 tottime | .0003003 .0049259 0.06 0.951 -.0093585 .0099591 ptime86 | .001729 .0045948 0.38 0.707 -.0072806 .0107386 qemp86 | -.0043557 .0054016 -0.81 0.420 -.0149473 .006236 black | -.1697631 .0236738 -7.17 0.000 -.2161836 -.1233426 hispan | -.0961866 .0207105 -4.64 0.000 -.1367965 -.0555766 _cons | .0601871 .0187272 3.21 0.001 .0234661 .0969081 ------------------------------------------------------------------------------ . scalar LM = e(N)*e(r2) . di LM 59.614147 . scalar pvalue = chi2tail(2,LM) . di pvalue 1.135e-13 . /* Como a varável dependente arr86 não tem distribuição normal, > o uso do teste de F é precario, pois a distribuição da estatística > F, não é uma distribuição F, mas, pelo Teorema do Limite Central, o > estimador OLS converge para uma distribuição assintótica normal, > o teste de LM tem distribuição assintótica Chi2, e neste caso > é ele que deve ser usado ao invés do teste de F para se testar as restrições impostas no modelo*/ . . . log close name: log: /Users/denisardalves/Documents/Cap7Wooldridge.txt log type: text closed on: 13 Jun 2017, 12:02:06 --------------------------------------------------------------------------------------------------------------------