Índice de ejercicios resueltos
insheet using "C:\Users\Nerys\Documents\Biblioteca\Econometria,
libos ebooks\Solucion a ejercicios de econometria\Base de datos wooldridge\gpa1.csv
", comma clear
i.
. regress colgpa pc
hsgpa act mothcoll fathcoll
Source | SS
df MS Number of obs = 141
-------------+------------------------------ F(
5, 135) = 7.71
Model |
4.31210399 5 .862420797 Prob > F =
0.0000
Residual |
15.0939955 135 .111807374 R-squared = 0.2222
-------------+------------------------------ Adj R-squared = 0.1934
Total |
19.4060994 140 .138614996 Root MSE =
.33438
------------------------------------------------------------------------------
colgpa | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
pc
| .1518539 .0587161
2.59 0.011 .0357316
.2679763
hsgpa
| .4502203 .0942798
4.78 0.000 .2637639
.6366767
act
| .0077242 .0106776
0.72 0.471 -.0133929
.0288413
mothcoll
| -.0037579 .0602701
-0.06 0.950 -.1229535
.1154377
fathcoll
| .0417999 .0612699
0.68 0.496 -.079373
.1629728
_cons
| 1.255554 .3353918
3.74 0.000 .5922526
1.918856
------------------------------------------------------------------------------
*el efecto del coeficiente se reduce levemente y
aunque la variable deja de ser significativa al 1%, continua siéndolo al 5%.
ii.
eststo clear
estimates store mz24,
title(Model No_Rest)
regress
colgpa pc hsgpa act
estimates store mz26,
title(Model Rest)
regress
colgpa pc hsgpa act mothcoll fathcoll
estout mz26 mz24, cells(b(star
fmt(4)) se(par fmt(4))) legend label varlabels(_cons constant) stats(N r2 rss)title(Models
tenencia de computadora)
Models tenencia de computadora
----------------------------------------------------
Model Rest Model No_R~t
b/se b/se
----------------------------------------------------
PC 0.1573** 0.1519*
(0.0573) (0.0587)
hsGPA 0.4472*** 0.4502***
(0.0936)
(0.0943)
ACT 0.0087 0.0077
(0.0105) (0.0107)
mothcoll -0.0038
(0.0603)
fathcoll 0.0418
(0.0613)
constant 1.2635*** 1.2556***
(0.3331) (0.3354)
----------------------------------------------------
N 141.0000 141.0000
r2 0.2194 0.2222
rss 15.1487 15.0940
----------------------------------------------------
* p<0.05, **
p<0.01, *** p<0.001
. scalar F=((15.1487-15.0940)/2)/( 15.0940/(141-5-1))
. scalar pvalue=Ftail(2,135,F)
. display "F-value:
" F ", F-tabla: " invF(2,135,.95) ", P-value: " pvalue
F-value: .24461707,
F-tabla: 3.0632039, P-value: .78335062
*en base a los valores obtenidos no se puede
rechazar la hipotesis nula.
iii.***
. gen hs_gpa2= hsgpa^2
. regress colgpa pc
hsgpa hs_gpa2 act mothcoll fathcoll
Source | SS
df MS Number of obs = 141
-------------+------------------------------ F(
6, 134) = 6.90
Model |
4.58264958 6 .76377493 Prob > F =
0.0000
Residual |
14.8234499 134 .11062276 R-squared =
0.2361
-------------+------------------------------ Adj R-squared = 0.2019
Total |
19.4060994 140 .138614996 Root MSE =
.3326
------------------------------------------------------------------------------
colgpa | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
pc | .1404458 .058858
2.39 0.018 .0240349
.2568567
hsgpa |
-1.802523 1.443551 -1.25
0.214 -4.657616 1.052569
hs_gpa2 | .337341
.2157104 1.56 0.120
-.0892966 .7639787
act |
.0047856 .0107859 0.44
0.658 -.016547 .0261181
mothcoll |
.0030906 .0601096 0.05
0.959 -.1157958 .121977
fathcoll |
.0627613 .0624009 1.01
0.316 -.0606569 .1861795
_cons |
5.040334 2.443037 2.06
0.041 .2084322 9.872236
------------------------------------------------------------------------------
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\wage2.csv ", comma
clear
i.
. regress lwage educ
exper tenure married black south urban
Source | SS
df MS Number of obs = 935
-------------+------------------------------ F(
7, 927) = 44.75
Model |
41.8377677 7 5.97682396 Prob > F =
0.0000
Residual |
123.818527 927 .133569069 R-squared =
0.2526
-------------+------------------------------ Adj R-squared = 0.2469
Total |
165.656294 934 .177362199 Root MSE =
.36547
------------------------------------------------------------------------------
lwage | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
educ |
.0654307 .0062504 10.47
0.000 .0531642 .0776973
exper | .014043
.0031852 4.41 0.000
.007792 .020294
tenure |
.0117473 .002453 4.79
0.000 .0069333 .0165613
married |
.1994171 .0390502 5.11
0.000 .1227801 .2760541
black |
-.1883499 .0376666 -5.00
0.000 -.2622717 -.1144282
south | -.0909036
.0262485 -3.46 0.001
-.142417 -.0393903
urban
| .1839121 .0269583
6.82 0.000 .1310056
.2368185
_cons
| 5.395497 .113225
47.65 0.000 5.17329
5.617704
------------------------------------------------------------------------------
*los negros ganan aproxidamente 18% menos.
. display exp(_b[black])-1
-.17167519
*la diferencia es estadísticamente significativa
ii.
*Se estima el modelo y se hace la prueba F
. gen exper2= exper^2
. gen tenure2= tenure^2
eststo clear
estimates store mmz2,
title(Model No_Rest)
regress
lwage educ exper tenure married black south urban
estimates store mmz3,
title(Model Rest)
regress
lwage educ exper exper2 tenure tenure2 married black south urban
estout mmz2 mmz3, cells(b(star
fmt(4)) se(par fmt(4))) legend label varlabels(_cons constant) stats(N r2 rss)title(Models
Salario)
Models Salario
----------------------------------------------------
Model No_R~t Model Rest
b/se b/se
----------------------------------------------------
educ 0.0643*** 0.0654***
(0.0063)
(0.0063)
exper 0.0172 0.0140***
(0.0126) (0.0032)
exper2 -0.0001
(0.0005)
tenure 0.0249** 0.0117***
(0.0081) (0.0025)
tenure2 -0.0008
(0.0005)
married 0.1985*** 0.1994***
(0.0391) (0.0391)
black -0.1907*** -0.1883***
(0.0377) (0.0377)
south -0.0912*** -0.0909***
(0.0262) (0.0262)
urban 0.1854*** 0.1839***
(0.0270) (0.0270)
constant 5.3587*** 5.3955***
(0.1259) (0.1132)
----------------------------------------------------
N 935.0000 935.0000
r2 0.2550 0.2526
rss 123.4210 123.8185
----------------------------------------------------
* p<0.05, **
p<0.01, *** p<0.001
. scalar F=((123.8185-123.4210)/2)/( 123.4210/(935-9-1))
. scalar pvalue=Ftail(2,925,F)
. display "F-value:
" F ", F-tabla: " invF(2,925,.95) ", P-value: " pvalue
F-value: 1.4895662,
F-tabla: 3.0054553, P-value: .22601077
iii.
*Considerando el modelo del inciso i como el
original, se verifica la significancia de la variable black
iv.
*Creando grupos
Label: married=0 “solteros”; 1 “casado”
black=0 “no negro”; 1 “negro”
. gen casado_negro
= married==1 & black==1
. gen casado_nonegro
= married==1 & black==0
. gen soltero_negro
= married==0 & black==1
. gen soltero_nonegro = married==0 & black==0
*grupo base (casado_nonegro)
Source | SS
df MS Number of obs = 935
-------------+------------------------------ F( 10, 924) =
31.66
Model |
42.2778219 10 4.22778219 Prob > F =
0.0000
Residual |
123.378472 924 .133526485 R-squared =
0.2552
-------------+------------------------------ Adj R-squared = 0.2472
Total |
165.656294 934 .177362199 Root MSE =
.36541
---------------------------------------------------------------------------------
lwage | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
----------------+----------------------------------------------------------------
educ | .0643052
.006314 10.18 0.000
.0519137 .0766967
exper | .0176937
.012647 1.40 0.162
-.0071264 .0425138
exper2 | -.0001306
.0005329 -0.25 0.806
-.0011764 .0009152
tenure | .0247263
.0081406 3.04 0.002
.0087501 .0407025
tenure2 | -.0007886
.0004714 -1.67 0.095
-.0017137 .0001366
south | -.0922414
.0263082 -3.51 0.000
-.1438722 -.0406105
urban | .1858281 .026978
6.89 0.000 .1328828
.2387733
casado_negro | -.1821526 .0406209
-4.48 0.000 -.2618726
-.1024327
soltero_negro | -.4291383 .0881483
-4.87 0.000 -.6021324
-.2561441
soltero_nonegro |
-.1886477 .0428802 -4.40
0.000 -.2728015 -.1044938
_cons
| 5.553743 .1207473
45.99 0.000 5.316773
5.790714
---------------------------------------------------------------------------------
*Por tanto un casado negro gana aproximadamente -16.65%
menos, respecto a los casados blancos, los casados negros representan solo el
10.9% de la muestra, mientras que los casados no negros el 78.40%.
. display exp(_b[casado_negro])-1
-.16652589
. mean casado_negro casado_nonegro soltero_negro
soltero_nonegro
Mean estimation Number of obs =
935
-----------------------------------------------------------------
| Mean
Std. Err. [95% Conf. Interval]
----------------+------------------------------------------------
casado_negro | .1090909 .0102009
.0890716 .1291102
casado_nonegro | .7839572
.0134661 .7575299 .8103846
soltero_negro | .0192513 .0044961
.0104277 .028075
soltero_nonegro |
.0877005 .0092554 .0695367 .1058644
-----------------------------------------------------------------
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\mlb1.csv ", comma clear
. regress lsalary
years gamesyr bavg hrunsyr rbisyr runsyr fldperc allstar frstbase scndbase
thrdbase shrtstop catcher
Source | SS
df MS Number of obs = 353
-------------+------------------------------ F( 13, 339) =
49.19
Model |
321.656007 13 24.7427698 Prob > F =
0.0000
Residual |
170.519561 339 .503007556 R-squared =
0.6535
-------------+------------------------------ Adj R-squared = 0.6403
Total |
492.175568 352 1.39822605 Root MSE =
.70923
------------------------------------------------------------------------------
lsalary | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
years |
.0584177 .0122732 4.76
0.000 .0342766 .0825589
gamesyr | .009767
.0033776 2.89 0.004
.0031232 .0164107
bavg |
.0004814 .0011411 0.42
0.673 -.0017631
.0027259
hrunsyr | .019146
.0159638 1.20 0.231
-.0122546 .0505466
rbisyr |
.0017875 .0074755 0.24
0.811 -.0129167 .0164917
runsyr |
.0118707 .0045264 2.62
0.009 .0029673 .0207741
fldperc |
.0002833 .0023078 0.12
0.902 -.0042562 .0048227
allstar |
.0063351 .0028828 2.20
0.029 .0006647 .0120055
frstbase |
-.1328005 .1309243 -1.01
0.311 -.3903269 .1247258
scndbase | -.1611007
.1414296 -1.14 0.255
-.4392908 .1170895
thrdbase |
.0145262 .1430352 0.10
0.919 -.266822 .2958745
shrtstop |
-.0605662 .130203 -0.47
0.642 -.3166738 .1955414
catcher |
.2535598 .1313128 1.93
0.054 -.0047307 .5118503
_cons |
11.12956 2.304454 4.83
0.000 6.596731 15.66239
------------------------------------------------------------------------------
i.
*Como jardinero es el grupo base, el beta de cátcher
captura la diferencia promedio, por ende la hipótesis seria que b(cátcher)=0.
Tiene un t de 1.93 por lo que se rechaza la hipótesis nula de que ganen lo
mismo debido a que el beta es distinto de cero.
*la magnitud de esta diferencia se puede obtener de:
. display exp(_b[catcher])-1
.28860445
*por tanto se concluye que en promedio los cátcher
ganen un 28% mas
ii.
*aquí hay que probar que todos los betas que
corresponden a posiciones de jugadores, son iguales a cero, si uno es diferente
de cero ya no se puede probar. Individualmente se muestra (P>|t|) que salvo
cátcher las demás coeficientes de las demás posiciones no son estadísticamente
diferentes de cero.
------------------------------------------------------------------------------
lsalary | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
frstbase
| -.1328005 .1309243
-1.01 0.311 -.3903269 .1247258
scndbase
| -.1611007 .1414296
-1.14 0.255 -.4392908 .1170895
thrdbase
| .0145262 .1430352
0.10 0.919 -.266822
.2958745
shrtstop
| -.0605662 .130203
-0.47 0.642 -.3166738 .1955414
catcher
| .2535598 .1313128
1.93 0.054 -.0047307
.5118503
------------------------------------------------------------------------------
*Sin embargo, como la prueba t no permite testear la
significancia conjunta de las variables, es necesario realizar la prueba F,
para evaluar la significancia conjunta de las variables.
eststo clear
estimates store mod1,
title(Model No_Rest)
regress
lsalary years gamesyr bavg hrunsyr rbisyr runsyr fldperc allstar frstbase
scndbase thrdbase shrtstop catcher
estimates store mod2,
title(Model Rest)
regress
lsalary years gamesyr bavg hrunsyr rbisyr runsyr fldperc allstar
estout mod1 mod2, cells(b(star
fmt(4)) se(par fmt(4))) legend label varlabels(_cons constant) stats(N r2 rss)title(Models
Salario de MLB por posiciones)
Models Salario de MLB por posiciones
----------------------------------------------------
Model Rest Model No_R~t
b/se b/se
----------------------------------------------------
years 0.0629*** 0.0584***
(0.0122) (0.0123)
gamesyr 0.0092** 0.0098**
(0.0032) (0.0034)
bavg 0.0004 0.0005
(0.0011) (0.0011)
hrunsyr 0.0195 0.0191
(0.0159) (0.0160)
rbisyr 0.0027 0.0018
(0.0073) (0.0075)
runsyr 0.0096* 0.0119**
(0.0043) (0.0045)
fldperc 0.0012 0.0003
(0.0020) (0.0023)
allstar 0.0069* 0.0063*
(0.0028) (0.0029)
frstbase -0.1328
(0.1309)
scndbase -0.1611
(0.1414)
thrdbase 0.0145
(0.1430)
shrtstop -0.0606
(0.1302)
catcher 0.2536
(0.1313)
constant 10.3277*** 11.1296***
(2.0019) (2.3045)
----------------------------------------------------
N 353.0000 353.0000
r2 0.6445 0.6535
rss 174.9899 170.5196
----------------------------------------------------
* p<0.05, **
p<0.01, *** p<0.001
. scalar F=((174.9899-170.5196)/5)/(170.5196/(353-8-1))
. display "F-value:
" F ", F-tabla: " invF(5,344,.95)
F-value: 1.8036439,
F-tabla: 2.2402283
iii.
*Comparando el valor crítico con el f de table, no
se piede rechazar la h0. Lo anterior es contradictorio con lo obtenido en el
inciso i, es decir cuando se testea una de las variables individualmente se
rechaza la no significancia pero al testear el conjunto no se rechaza la
hipótesis nula.(el 14.3% de la muestra es catcher)… Razones???
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\gpa2.csv ", comma clear
i.
colgpa = b0 +b1*hsize
+b2*hsize2 +b3*hsperc +b4*sat +b5*female +b6*athlete
hsize:espero un signo negativo, grupos mas grandes
esperaria en promedio menor calificacion
hsperc: positivo, un percentile mayor es un
indicador de major estudiante
sat: positivo, razones parecidas a la anterior
female: positivo pero no estaria totalmetne seguro
*athlete: negativo, los atletas tienen a dedicar
menos horas a estudiar, aunque no estaria *totalmente seguto del signo
ii.
. gen hsize2 =
hsize^2
. regress colgpa
hsize hsize2 hsperc sat female athlete
Source | SS
df MS Number of obs = 4137
-------------+------------------------------ F(
6, 4130) = 284.59
Model |
524.819305 6 87.4698841 Prob > F =
0.0000
Residual |
1269.37637 4130 .307355053 R-squared =
0.2925
-------------+------------------------------ Adj R-squared = 0.2915
Total |
1794.19567 4136 .433799728 Root MSE =
.5544
------------------------------------------------------------------------------
colgpa | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
hsize |
-.0568543 .0163513 -3.48
0.001 -.0889117 -.0247968
hsize2 |
.0046754 .0022494 2.08
0.038 .0002654 .0090854
hsperc |
-.0132126 .0005728 -23.07
0.000 -.0143355 -.0120896
sat |
.0016464 .0000668 24.64
0.000 .0015154 .0017774
female |
.1548814 .0180047 8.60
0.000 .1195826 .1901802
athlete | .1693064
.0423492 4.00 0.000
.0862791 .2523336
_cons
| 1.241365 .0794923
15.62 0.000
1.085517 1.397212
------------------------------------------------------------------------------
*los atletas obtienen mayor calificación, siendo
esta diferencia significativa en términos estadísticos.
. display
exp(_b[athlete])-1
.18448296
iii.
. regress colgpa
hsize hsize2 hsperc female athlete
Source | SS
df MS Number of obs = 4137
-------------+------------------------------ F(
5, 4131) = 191.92
Model |
338.217123 5 67.6434245 Prob > F =
0.0000
Residual |
1455.97855 4131 .35245184 R-squared =
0.1885
-------------+------------------------------ Adj R-squared = 0.1875
Total |
1794.19567 4136 .433799728 Root MSE =
.59368
------------------------------------------------------------------------------
colgpa | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
hsize |
-.0534038 .0175092 -3.05
0.002 -.0877313 -.0190762
hsize2 |
.0053228 .0024086 2.21
0.027 .0006007 .010045
hsperc |
-.0171365 .0005892 -29.09
0.000 -.0182916 -.0159814
female |
.0581231 .0188162 3.09
0.002 .0212333 .095013
athlete |
.0054487 .0447871 0.12
0.903 -.0823582 .0932556
_cons |
3.047698 .0329148 92.59
0.000 2.983167 3.112229
------------------------------------------------------------------------------
. display
exp(_b[athlete])-1
.00546358
*la diferencia no es significativamente diferente de
cero. Se ha eliminado la puntuación obtenida en la prueba combinada de admisión
a la universidad. ¿por qué?
iv.
. gen mujer_atleta =
athlete* female
. regress colgpa
hsize hsize2 hsperc sat female athlete mujer_atleta
Source | SS
df MS Number of obs = 4137
-------------+------------------------------ F(
7, 4129) = 243.88
Model |
524.821271 7 74.9744673 Prob > F =
0.0000
Residual |
1269.3744 4129 .307429015 R-squared =
0.2925
-------------+------------------------------ Adj R-squared = 0.2913
Total |
1794.19567 4136 .433799728 Root MSE =
.55446
------------------------------------------------------------------------------
colgpa | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
hsize |
-.0568006 .0163671 -3.47
0.001 -.0888889 -.0247124
hsize2 |
.0046699 .0022507 2.07
0.038 .0002573 .0090825
hsperc |
-.0132114 .000573 -23.06
0.000 -.0143349 -.012088
sat |
.0016462 .0000669 24.62
0.000 .0015151 .0017773
female |
.1546151 .0183122 8.44
0.000 .1187133 .1905168
athlete | .1674185
.0484877 3.45 0.001
.0723564 .2624806
mujer_atleta |
.0076921 .0961748 0.08
0.936 -.1808623 .1962466
_cons
| 1.241575 .0795453
15.61 0.000 1.085623
1.397526
------------------------------------------------------------------------------
*en base al estadístico t, no se rechaza la nula de
que b7 sea igual a cero y por tanto no haya diferencia a partir del sexo en el
hecho de ser atletas
v.
. gen sat_female=
sat*female
. regress colgpa
hsize hsize2 hsperc sat female sat_female
athlete
Source | SS
df MS Number of obs = 4137
-------------+------------------------------ F(
7, 4129) = 243.91
Model |
524.867644 7 74.9810919 Prob > F =
0.0000
Residual |
1269.32803 4129 .307417784 R-squared =
0.2925
-------------+------------------------------ Adj R-squared = 0.2913
Total |
1794.19567 4136 .433799728 Root MSE =
.55445
------------------------------------------------------------------------------
colgpa | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
hsize |
-.0569121 .0163537 -3.48
0.001 -.0889741 -.0248501
hsize2 |
.0046864 .0022498 2.08
0.037 .0002757
.0090972
hsperc |
-.013225 .0005737 -23.05
0.000 -.0143497 -.0121003
sat |
.0016255 .0000852 19.09
0.000 .0014585 .0017924
female |
.1023066 .1338023 0.76
0.445 -.1600179 .3646311
sat_female | .0000512
.0001291 0.40 0.692
-.000202 .0003044
athlete
| .1677568 .0425334
3.94 0.000 .0843684
.2511452
_cons
| 1.263743 .0974952
12.96 0.000 1.0726
1.454887
------------------------------------------------------------------------------
*Aunque las mujeres obtienen una calificación
levemente superior, la diferencia no se estadísticamente significativa.
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\ceosal1.csv ", comma
clear
*generando variables
. gen rosneg
= ros<=0
. gen lsalary= ln( salary)
. gen lsales = ln(sales)
. regress lsalary
lsales roe rosneg
Source | SS
df MS Number of obs = 209
-------------+------------------------------ F(
3, 205) = 28.81
Model |
19.7902019 3 6.59673397 Prob > F =
0.0000
Residual |
46.9319613 205 .228936397 R-squared =
0.2966
-------------+------------------------------ Adj R-squared = 0.2863
Total |
66.7221632 208 .320779631 Root MSE =
.47847
------------------------------------------------------------------------------
lsalary | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
lsales
| .2883868 .0336172
8.58 0.000 .222107
.3546665
roe
| .0166571 .0039681
4.20 0.000 .0088336
.0244806
rosneg
| -.225675 .109338
-2.06 0.040 -.4412462
-.0101038
_cons
| 4.297602 .2932526
14.65 0.000 3.719425 4.87578
------------------------------------------------------------------------------
*Interpretacion: dada las demas variables
independientes, los CEO que obtivieron res negative ganan en promedio 22.6%
menos que los demás. En términos de significancia, es significativo a niveles
superiores al 5%.
insheet using "C:\Users\Nerys\Documents\Biblioteca\Econometria,
libos ebooks\Solucion a ejercicios de econometria\Base de datos wooldridge\sleep75.csv
", comma clear
*Ecuacion de interés
. gen age2=age^2
. regress sleep
totwrk educ age age2 yngkid
Source | SS
df MS Number of obs = 706
-------------+------------------------------ F(
5, 700) = 18.14
Model |
15972384.7 5 3194476.94 Prob > F =
0.0000
Residual |
123267451 700 176096.359 R-squared =
0.1147
-------------+------------------------------ Adj R-squared = 0.1084
Total |
139239836 705 197503.313 Root MSE =
419.64
------------------------------------------------------------------------------
sleep | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
totwrk |
-.1460463 .0168809 -8.65
0.000 -.1791896 -.1129031
educ |
-11.13772 5.890168 -1.89
0.059 -22.70223 .4267914
age |
-8.123949 11.37049 -0.71
0.475 -30.4483 14.2004
age2 | .126287
.135186 0.93 0.351
-.1391317 .3917057
yngkid |
17.15441 50.00839 0.34
0.732 -81.02999 115.3388
_cons |
3825.375 240.2585 15.92
0.000 3353.661 4297.088
------------------------------------------------------------------------------
i.
eststo clear
estimates store modelo3,
title(Model Hombres)
regress
sleep totwrk educ age age2 yngkid if male==1
estimates store modelo4, title(Model Mujeres)
regress sleep totwrk educ age age2 yngkid if male==0
estout modelo3
modelo4, cells(b(star fmt(4)) se(par fmt(4))) legend label varlabels(_cons
constant) stats(N r2 rss)title(Models Horas de sueño)
Models Horas de sueño
----------------------------------------------------
Model Muje~s Model Homb~s
b/se b/se
----------------------------------------------------
totwrk -0.1399*** -0.1821***
(0.0277) (0.0245)
educ -10.2051 -13.0524
(9.5888) (7.4142)
age -30.3566 7.1566
(18.5309) (14.3204)
age2 0.3679 -0.0448
(0.2233) (0.1684)
yngkid -118.2826 60.3802
(93.1876) (59.0228)
constant 4238.7293*** 3648.2083***
(384.8923) (310.0393)
----------------------------------------------------
N 306.0000 400.0000
r2 0.0977 0.1562
rss
57288575.9410 63763978.9893
----------------------------------------------------
* p<0.05, ** p<0.01, *** p<0.001
*el signo de los coeficientes age, age2 y yngkid
difiere entre los grupos, ademas la magnitud de los coeficientes, visualmente,
son diferentes. La significancia de las variables puede mostrar t muy
diferentes, pero tienen a rechazarse la significatividad estadísticas de las
mismas variables.
ii.
. gen male_totwrk =
male*totwrk
. gen male_yngkid =
male*yngkid
. regress sleep
totwrk educ age age2 yngkid male male_totwrk male_yngkid
Source | SS
df MS Number of obs = 706
-------------+------------------------------ F(
8, 697) = 12.58
Model | 17564732
8 2195591.5 Prob > F =
0.0000
Residual |
121675104 697 174569.733 R-squared =
0.1261
-------------+------------------------------ Adj R-squared = 0.1161
Total |
139239836 705 197503.313 Root MSE =
417.82
------------------------------------------------------------------------------
sleep | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
totwrk |
-.1443479 .026332 -5.48
0.000 -.1960474 -.0926484
educ |
-11.42488 5.875073 -1.94
0.052 -22.95984 .1100792
age |
-9.365377 11.33877 -0.83
0.409 -31.62761 12.89685
age2 |
.1335546 .1348172 0.99
0.322 -.1311419 .3982511
yngkid |
-84.66258 86.88302 -0.97
0.330 -255.2464 85.92124
male |
155.1322 83.84413 1.85
0.065 -9.485119 319.7496
male_totwrk |
-.0387553 .0363742 -1.07
0.287 -.1101715 .0326608
male_yngkid |
121.9443 102.2713 1.19
0.234 -78.85236 322.741
_cons |
3829.378 241.6613 15.85
0.000 3354.907 4303.85
------------------------------------------------------------------------------
. regress sleep
totwrk educ age age2 yngkid if male==0
. scalar Rss0 =
e(rss)
. regress sleep
totwrk educ age age2 yngkid if male==1
. scalar Rss1 =
e(rss)
. regress sleep
totwrk educ age age2 yngkid male male_totwrk male_yngkid
. scalar Rssp = e(rss)
*Validar resultados
. scalar Stat_Chow =
((Rssp-(Rss0+Rss1))/(Rss0+Rss1))*(( e(N)-(2*(e(df_m)+1)))/( e(df_m)+1))
. display Stat_Chow
.39313834
. display “grados de libertad:” e(N)-(2*(e(df_m)+1))
grados de libertad:688
iii.
*hacer la prueba F, comparando los residuales del
modelo, con y sin los términos de iteración.
iv.***
Si se rechaza la significancia conjunta (h0, sus
betas=0) el midelo correcto seria el que no tiene las variables, en caso que se
rechace la nula, el modelo correcto será el que mantiene los términos de
iteraciones.
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\wage1.csv ", comma clear
i.
. gen female_educ =
female*educ
. gen exper2=exper^2
. gen
tenure2=tenure^2
. regress lwage
female educ female_educ exper exper2 tenure tenure2
Source | SS
df MS Number of obs = 526
-------------+------------------------------ F(
7, 518) = 58.37
Model |
65.4081523 7 9.34402176 Prob > F =
0.0000
Residual |
82.9216085 518 .160080325 R-squared =
0.4410
-------------+------------------------------ Adj R-squared = 0.4334
Total |
148.329761 525 .282532878 Root MSE =
.4001
------------------------------------------------------------------------------
lwage | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
female |
-.2267887 .1675394 -1.35
0.176 -.555929 .1023516
educ |
.0823692 .0084699 9.72
0.000 .0657296
.0990088
female_educ |
-.0055645 .0130618 -0.43
0.670 -.0312252 .0200962
exper |
.0293366 .0049842 5.89
0.000 .019545 .0391283
exper2 |
-.0005804 .0001075 -5.40
0.000 -.0007916 -.0003691
tenure |
.0318967 .006864 4.65
0.000 .018412 .0453814
tenure2 | -.00059
.0002352 -2.51 0.012
-.001052 -.000128
_cons |
.3888061 .1186871 3.28
0.001 .1556389 .6219733
------------------------------------------------------------------------------
*educ==0***
display _b[female]
-.22678872
*educ==12.5***
display _b[female]+(_b[female_educ]*12.5)
-.29634502
ii.
. gen
female_educ15=educ*(educ-12.5)
. regress lwage
female educ female_educ15 exper exper2
tenure tenure2
Source | SS
df MS Number of obs = 526
-------------+------------------------------ F(
7, 518) = 61.99
Model |
67.6129722 7 9.65899602 Prob > F =
0.0000
Residual |
80.7167887 518 .155823916 R-squared =
0.4558
-------------+------------------------------ Adj R-squared = 0.4485
Total |
148.329761 525 .282532878 Root MSE =
.39475
-------------------------------------------------------------------------------
lwage | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
--------------+----------------------------------------------------------------
female |
-.2803473 .0356109 -7.87
0.000 -.3503069 -.2103877
educ | .0291068
.0150529 1.93 0.054
-.0004654 .058679
female_educ15 | .004626
.0012218 3.79 0.000
.0022257 .0070262
exper | .0306464
.0049229 6.23 0.000
.0209751 .0403177
exper2 | -.0006187
.0001064 -5.82 0.000
-.0008277 -.0004098
tenure
| .0305469 .0067659
4.51 0.000 .0172549
.0438389
tenure2
| -.0005484 .0002319
-2.36 0.018 -.0010041
-.0000928
_cons
| 1.011217 .1849251
5.47 0.000 .6479217
1.374512
-------------------------------------------------------------------------------
*Interptreta female: Es el efecto estimado cuando el
nivel de educacion es 12.5 años de escolaridad.***
iii.
*Si, en el inciso ii. female es significativo. Mientras que en el primer
inciso no lo era.
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\loanapp.csv ", comma
clear
i.
*Si existe discriminación se esperaría que B1[white]
sea positivo, distinto de cero. Es decir que ser blanco afecta positivamente la
probabilidad de que le concedan el préstamo.
ii.
. regress approve
white
Source | SS
df MS Number of obs = 1989
-------------+------------------------------ F(
1, 1987) = 102.23
Model |
10.4743407 1 10.4743407 Prob > F =
0.0000
Residual |
203.59303 1987 .102462521 R-squared =
0.0489
-------------+------------------------------ Adj R-squared = 0.0485
Total | 214.067371 1988
.107679764 Root MSE =
.3201
------------------------------------------------------------------------------
approve | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
white | .2005957
.01984 10.11 0.000 .1616864 .239505
_cons
| .7077922 .0182393
38.81 0.000 .6720221
.7435623
------------------------------------------------------------------------------
*Es significativa y grande en sentido práctico. Ser
blanco incrementa la posibilidad de que te concedan un préstamo alrededor del
20%.
iii.
. regress approve
white hrat obrat loanprc unem male married dep sch cosign chist pubrec mortlat1
mortlat2 vr
Source | SS
df MS Number of obs = 1971
-------------+------------------------------ F( 15, 1955) =
25.86
Model |
35.4004767 15 2.36003178 Prob > F =
0.0000
Residual |
178.393536 1955 .091249891 R-squared =
0.1656
-------------+------------------------------ Adj R-squared = 0.1592
Total |
213.794013 1970 .10852488 Root MSE =
.30208
------------------------------------------------------------------------------
approve | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
white | .1288196 .0197317
6.53 0.000 .0901223
.1675169
hrat | .001833
.0012632 1.45 0.147
-.0006444 .0043104
obrat |
-.0054318 .0011018 -4.93
0.000 -.0075926 -.003271
loanprc | -.1473
.0375159 -3.93 0.000
-.2208754 -.0737245
unem |
-.0072989 .003198 -2.28
0.023 -.0135708 -.0010271
male |
-.0041441 .0188644 -0.22
0.826 -.0411405 .0328523
married |
.0458241 .0163077 2.81
0.005 .0138418 .0778064
dep |
-.0068274 .0067013 -1.02
0.308 -.0199699 .0063151
sch |
.0017525 .0166498 0.11
0.916 -.0309006 .0344057
cosign |
.0097722 .0411394 0.24
0.812 -.0709094 .0904538
chist |
.1330268 .0192627 6.91
0.000 .0952492 .1708043
pubrec |
-.2419268 .0282274 -8.57
0.000 -.2972858 -.1865678
mortlat1 |
-.0572511 .050012 -1.14
0.252 -.1553336 .0408314
mortlat2 |
-.1137234 .0669838 -1.70
0.090 -.2450905 .0176438
vr |
-.0314408 .0140313 -2.24
0.025 -.0589586 -.0039229
_cons | .9367311
.0527354 17.76 0.000
.8333076 1.040155
------------------------------------------------------------------------------
*El cociente, sigue siendo significativo lo que
evidencia discriminación a favor de los blancos, pero su efecto parcial se
reduce considerablemente.
. gen
white_obrat=white*obrat
. regress approve
white hrat obrat white_obrat loanprc
unem male married dep sch cosign chist pubrec mortlat1 mortlat2 vr
Source | SS
df MS Number of obs = 1971
-------------+------------------------------ F( 16, 1954) =
25.17
Model |
36.531805 16 2.28323781 Prob > F =
0.0000
Residual |
177.262208 1954 .090717609 R-squared =
0.1709
-------------+------------------------------ Adj R-squared = 0.1641
Total |
213.794013 1970 .10852488 Root MSE =
.30119
------------------------------------------------------------------------------
approve | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
white |
-.1459751 .080263 -1.82
0.069 -.3033851 .011435
hrat |
.0017897 .0012596 1.42
0.156 -.0006806 .0042599
obrat |
-.0122262 .0022155 -5.52
0.000 -.0165713 -.0078812
white_obrat |
.0080879 .0022903 3.53
0.000 .0035963 .0125796
loanprc |
-.1525355 .0374357 -4.07
0.000 -.2259536 -.0791174
unem |
-.0075281 .0031893 -2.36
0.018 -.0137829 -.0012733
male |
-.0060154 .0188167 -0.32
0.749 -.0429184 .0308875
married |
.0455358 .0162603 2.80
0.005 .0136465 .0774251
dep | -.00763
.0066856 -1.14 0.254
-.0207417 .0054817
sch |
.0017766 .0166011 0.11
0.915 -.0307812 .0343344
cosign |
.0177091 .0410807 0.43
0.666 -.0628576 .0982757
chist |
.1298548 .0192274 6.75
0.000 .0921464 .1675632
pubrec |
-.240325 .0281486 -8.54
0.000 -.2955296 -.1851205
mortlat1 |
-.0627819 .0498906 -1.26
0.208 -.1606262 .0350624
mortlat2 | -.1268446
.0668914 -1.90 0.058
-.2580306 .0043414
vr
| -.0305396 .0139926
-2.18 0.029 -.0579816
-.0030975
_cons
| 1.180648 .0868076
13.60 0.000 1.010403
1.350894
------------------------------------------------------------------------------
*Si es signicativo y positivo, lo que indica que las
personas blancas en la muestra tienen mayor porcentaje de los ingresos.
iv.
. display
_b[white]+_b[white_obrat]*32
. display
_b[white]+_b[white_obrat]*32
.11283819
*para continuar corer la ecuacion del inciso iii. Pero
cambiendo la iteración por:
. gen
white_obrat32=white*(obrat-32)
Luego se corre la ecuacion con este termino de error
y de ahi se obtiene el error standar para crear el interval que seria:
beta(estimado)+-1.96*E.S
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\401ksubs.csv ", comma
clear
i.
*El 39.13% de la poblacion
. ci e401k
Variable | Obs Mean
Std. Err. [95% Conf.
Interval]
-------------+---------------------------------------------------------------
e401k | 9275
.3921294 .0050698 .3821916 .4020672
ii.
. gen inc2=inc^2
. gen age2=age^2
. reg e401k inc inc2
age age2 male
Source | SS
df MS Number of obs = 9275
-------------+------------------------------ F(
5, 9269) = 192.96
Model |
208.430869 5 41.6861738 Prob > F =
0.0000
Residual |
2002.39458 9269 .216031349 R-squared =
0.0943
-------------+------------------------------ Adj R-squared = 0.0938
Total |
2210.82544 9274 .238389632 Root MSE =
.46479
------------------------------------------------------------------------------
e401k | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
inc
| .0124464 .0005929
20.99 0.000 .0112843
.0136086
inc2
| -.0000616 4.73e-06
-13.03 0.000 -.0000709
-.0000524
age
| .0265061 .0039225
6.76 0.000 .0188173 .034195
age2
| -.0003053 .000045
-6.78 0.000 -.0003935
-.000217
male
| -.0035328 .012084
-0.29 0.770 -.0272202
.0201545
_cons
| -.5062895 .0810961
-6.24 0.000 -.6652556
-.3473233
------------------------------------------------------------------------------
iii.
*No, los coeficientes relacionados con edad y
ingreso son estadísticamente significativo, lo que no permite aceptar la
hipótesis nula de que estos no afectan la elegibilidad del plan.
*En el caso del género, no se rechaza la hipótesis
de que el efecto sea nulo. Esto porque es muy probable que el sexo no sea una
variable de peso al momento de elegir personas para el plan.
iv.