Índice de ejercicios resueltos
Capitulo 6. Análisis de Regresión Múltiple: Temas adicionales
*Ejercicio C6.1 Kielmc
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\kielmc.csv ", comma
clear
i.
. regress lprice
ldist
Source | SS
df MS Number of obs = 321
-------------+------------------------------ F(
1, 319) = 43.48
Model |
7.36918646 1 7.36918646 Prob > F =
0.0000
Residual |
54.0697165 319 .169497544 R-squared =
0.1199
-------------+------------------------------ Adj R-squared = 0.1172
Total |
61.4389029 320 .191996572 Root MSE =
.4117
------------------------------------------------------------------------------
lprice | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
ldist
| .3172188 .0481095
6.59 0.000 .2225668
.4118708
_cons
| 8.257505 .4738306
17.43 0.000 7.325277
9.189733
------------------------------------------------------------------------------
*Esperaria un signo positivo del coeficiente, a
mayor dist desde el incinerador, esperaría un mayor precio
ii.
. regress lprice
ldist lintst larea lland rooms baths age
Source |
SS df
MS Number of obs
= 321
-------------+------------------------------ F(
7, 313) = 65.02
Model |
36.4034046 7 5.20048637 Prob > F =
0.0000
Residual |
25.0354984 313 .079985618 R-squared =
0.5925
-------------+------------------------------ Adj R-squared = 0.5834
Total |
61.4389029 320 .191996572 Root MSE =
.28282
------------------------------------------------------------------------------
lprice | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
ldist
| .0282041 .0532129
0.53 0.596 -.0764961
.1329044
lintst
| -.0438027 .0424357
-1.03 0.303 -.1272981
.0396927
larea
| .5124036 .0698228
7.34 0.000 .3750222 .649785
lland
| .0782203 .0337208
2.32 0.021
.0118723 .1445684
rooms
| .0503139 .0235113
2.14 0.033 .0040538 .096574
baths
| .107054 .0352303
3.04 0.003 .0377358
.1763723
age
| -.0035631 .0005774
-6.17 0.000 -.0046992
-.002427
_cons
| 6.299629 .5960532
10.57 0.000 5.126851
7.472406
------------------------------------------------------------------------------
*ahora el efecto de la distancia hasta el
incinerador es claramente no significativo (b=0) al momento de explicar el
precio de la vivienda. Desde mi parecer podría deberse a un efecto contrario en
el aumento del precio que inicie a cierta distancia del incinerador, es decir
desde aquellas viviendas que están más cerca un distanciamiento le provocaría
un aumento del precio pero a partir de cierta distancia este efecto podría cambiar
de signo.
iii.
. gen lintst2=(ln(intst))^2
. regress lprice ldist lintst lintst2 larea lland
rooms baths age
Source | SS
df MS Number of obs = 321
-------------+------------------------------ F(
8, 312) = 63.03
Model |
37.9535257 8 4.74419071 Prob > F =
0.0000
Residual |
23.4853772 312 .075273645 R-squared =
0.6177
-------------+------------------------------ Adj R-squared = 0.6079
Total |
61.4389029 320 .191996572 Root MSE =
.27436
------------------------------------------------------------------------------
lprice | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
ldist |
.1897245 .0627031 3.03
0.003 .0663502 .3130988
lintst |
1.901933 .43074 4.42
0.000 1.054411 2.749456
lintst2 |
-.112811 .0248594 -4.54
0.000 -.1617242 -.0638978
larea |
.5137757 .0677356 7.59
0.000 .3804993 .6470521
lland |
.1068575 .0333156 3.21
0.001 .0413059 .1724091
rooms |
.0494484 .022809 2.17
0.031 .0045694 .0943273
baths |
.0898612 .0343862 2.61
0.009 .022203 .1575194
age |
-.0035691 .0005602 -6.37
0.000 -.0046713 -.0024669
_cons |
-3.787966 2.296906 -1.65
0.100 -8.307351 .7314191
------------------------------------------------------------------------------
*Ahora ldist vuelve a ser significativa. La forma
funcionar permite controlar el efecto marginal decreciente que genera la
distancia hasta la carretera insterestatal en el precio de las viviendas.
iv.
. gen ldist2=(ln(dist))^2
. regress lprice ldist
ldist2 lintst lintst2 larea lland rooms baths age
Source | SS
df MS Number of obs = 321
-------------+------------------------------ F(
9, 311) = 56.20
Model |
38.045506 9 4.22727845 Prob > F =
0.0000
Residual |
23.3933969 311 .075219926 R-squared =
0.6192
-------------+------------------------------ Adj R-squared = 0.6082
Total |
61.4389029 320 .191996572 Root MSE =
.27426
------------------------------------------------------------------------------
lprice | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
ldist |
2.112716 1.740116 1.21
0.226 -1.311174 5.536606
ldist2 |
-.1027457 .0929143 -1.11
0.270 -.2855658 .0800744
lintst |
1.518856 .5526416 2.75
0.006 .4314669 2.606245
lintst2 |
-.0887897 .0330064 -2.69
0.008 -.1537339 -.0238456
larea |
.5062592 .0680518 7.44
0.000 .3723591 .6401594
lland |
.0969085 .0344976 2.81
0.005 .0290303 .1647866
rooms |
.0477291 .0228538 2.09
0.038 .0027614 .0926968
baths |
.0893745 .0343768 2.60
0.010 .0217341 .157015
age |
-.0035226 .0005615 -6.27
0.000 -.0046274 -.0024177
_cons |
-11.1091 7.007451 -1.59
0.114 -24.89711 2.678908
------------------------------------------------------------------------------
*no
*Ejercicio C6.2 wage1
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 exper2 = exper^2
. regress lwage educ
exper exper2
Source | SS
df MS Number of obs = 526
-------------+------------------------------ F(
3, 522) = 74.67
Model |
44.5393691 3 14.8464564 Prob > F =
0.0000
Residual |
103.790392 522 .198832168 R-squared =
0.3003
-------------+------------------------------ Adj R-squared = 0.2963
Total |
148.329761 525 .282532878 Root MSE =
.44591
------------------------------------------------------------------------------
lwage | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
educ
| .0903658 .007468
12.10 0.000 .0756948
.1050368
exper
| .0410089 .0051965
7.89 0.000 .0308002
.0512175
exper2
| -.0007136 .0001158
-6.16 0.000 -.000941
-.0004861
_cons
| .1279975 .1059323
1.21 0.227 -.0801085
.3361035
------------------------------------------------------------------------------
ii.
si
iii.
*efecto del segundo año adicional
. display 100*(_b[exper]+(2*_b[exper2]))
3.9581755
*Efecto del vigésimo ano adicional
. display 100*(_b[exper]+(2*_b[exper2]*10))
2.673771
iv.
. display abs(_b[exper]/(2*_b[exper2]))
28.735483
*se genera un dummy que cuente como 1 cuando se
cumpla
. gen experm = exper>28.735483
. tab experm
experm | Freq.
Percent Cum.
------------+-----------------------------------
0
| 405 77.00 77.00
1
| 121 23.00 100.00
------------+-----------------------------------
Total
| 526 100.00
*121 personas que representan el 23% de la muestra
*Ejercicio C6.3 wage2**
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\wage2.csv ", comma
clear
i.
. gen educ_exper = educ*exper
. regress lwage educ
exper educ_exper
. regress lwage educ
exper educ_exper
Source | SS
df MS Number of obs = 935
-------------+------------------------------ F(
3, 931) = 48.41
Model |
22.3529774 3 7.45099246 Prob > F =
0.0000
Residual |
143.303317 931 .153924078 R-squared =
0.1349
-------------+------------------------------ Adj R-squared = 0.1321
Total |
165.656294 934 .177362199 Root MSE =
.39233
------------------------------------------------------------------------------
lwage | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
educ |
.0440498 .0173911 2.53
0.011 .0099195 .0781801
exper |
-.0214959 .0199783 -1.08
0.282 -.0607036 .0177118
educ_exper | .003203
.0015292 2.09 0.036
.000202 .006204
_cons |
5.949455 .2408264 24.70
0.000 5.476829 6.42208
------------------------------------------------------------------------------
*B1 ya no muestra el rendimiento adicional de un año
más de educación, porque no es lógico mantener constante las demás variables
como educ_exper. La forma funcional indica que B1 es el efecto de la educación para
una persona con 0 años de experiencia.
ii.
la alternativa seria a que tiene un efecto positivo.
H1; B3>0
iii.
*para probar esta hipótesis (educ sobre exper) es
necesario redefinir el modelo:
* regress lwage educ
exper educ_exper
El efecto del rendimiento de la educacion sobre la
experiencia es:
. summ educ
. display _b[educ]+(_b[educ_exper]*r(mean))
.08718889
*?? Significa que un aumento del del 1% en la
experiencia incrementa en 8% el rendimiento de la educacion. Para saber si es estadísticamente
distinta de cero, se vuelve a correr el modelo:
. gen educ_exper2 =
(educ-r(mean))*exper
. regress lwage educ
exper educ_exper2
Source | SS
df MS Number of obs = 935
-------------+------------------------------ F(
3, 931) = 48.41
Model |
22.3529775 3 7.45099249 Prob > F =
0.0000
Residual |
143.303317 931 .153924078 R-squared =
0.1349
-------------+------------------------------ Adj R-squared = 0.1321
Total |
165.656294 934 .177362199 Root MSE =
.39233
------------------------------------------------------------------------------
lwage |
Coef. Std. Err. t
P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ |
.0440498 .0173911 2.53
0.011 .0099195 .0781801
exper |
.0216432 .0034148 6.34
0.000 .0149415 .0283448
educ_exper2 | .003203
.0015292 2.09 0.036
.000202 .006204
_cons |
5.949455 .2408265 24.70
0.000 5.476829 6.42208
------------------------------------------------------------------------------
. display (_b[educ]+(_b[educ_exper]*r(mean)))/_se[educ_exper2]
57.017351
*se concluye
claramente que la experiencia, tiene un efecto positive sobre el rendimiento de
la educacion.
iv.
. regress lwage educ
exper educ_exper
. scalar theta1=_b[educ]+10*_b[educ_exper]
. display theta1
.07607954
*se reescribe la ecuación, redefiniendo educ_exper
para poder obtener theta1
. gen educ_exper10 = (educ-10)*exper
. regress lwage educ
exper educ_exper10
*de esta ecuacion si se puede llamar el interval de
confianza
. display "Conf. Interval: ["
tetha1-1.96*_se[educ_exper10] ", " tetha1+1.96*_se[educ_exper10]
"]"
Conf. Interval: [.07308238, .0790767]
*Ejercicio C6.4 gpa2
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\gpa2.csv ", comma clear
i.
. gen hsize2=hsize^2
. regress sat hsize
hsize2
Source | SS
df MS Number of obs = 4137
-------------+------------------------------ F(
2, 4134) = 15.93
Model |
614822.113 2 307411.057 Prob > F =
0.0000
Residual |
79759024.2 4134 19293.4263 R-squared =
0.0076
-------------+------------------------------ Adj R-squared = 0.0072
Total |
80373846.3 4136 19432.7481 Root MSE =
138.9
------------------------------------------------------------------------------
sat | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
hsize
| 19.81446 3.990666
4.97 0.000 11.99061
27.63831
hsize2
| -2.130606 .549004
-3.88 0.000 -3.206949 -1.054263
_cons
| 997.9805 6.203448
160.88 0.000 985.8184
1010.143
------------------------------------------------------------------------------
*Si, es significativo
ii.***
*los betas indican un efecto marginal decreciente,
por lo que el máximo se encontrara en donde esta curva (que captura el efecto
marginal) alcance su máximo. Este punto se obtiene en:
. display abs(_b[hsize]/(2*_b[hsize2]))
4.6499584
iii.***
. gen hsize_opt= hsize<4.6499584
hsize_opt | Freq.
Percent Cum.
------------+-----------------------------------
0 | 640 15.47 15.47
1 | 3,497 84.53 100.00
------------+-----------------------------------
Total | 4,137
100.00
*este grupo representa el 15.5% de la muestra
*Ejercicio C6.5 hprice1**
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\hprice1.csv ", comma
clear
i.
. gen lbdrms=ln( bdrms)
. regress lprice
llotsize lsqrft lbdrms
Source | SS
df MS Number of obs = 88
-------------+------------------------------ F(
3, 84) = 49.64
Model |
5.12621077 3 1.70873692 Prob > F =
0.0000
Residual |
2.89139213 84 .034421335 R-squared =
0.6394
-------------+------------------------------ Adj R-squared = 0.6265
Total |
8.0176029 87 .092156355 Root MSE =
.18553
------------------------------------------------------------------------------
lprice | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
llotsize |
.1695374 .0384877
4.40 0.000 .0930004
.2460744
lsqrft
| .7168688 .0934546
7.67 0.000 .5310242
.9027135
lbdrms
| .0992446 .1020059
0.97 0.333 -.1036053
.3020946
_cons
| -1.428815 .6400267
-2.23 0.028 -2.701578
-.1560515
------------------------------------------------------------------------------
ii.***
. display _b[_cons]+_b[llotsize]*20000+_b[lsqrft]*2500+_b[lbdrms]*4
5181.8886
iii.
. regress price
lotsize sqrft bdrms
Source | SS
df MS Number of obs = 88
-------------+------------------------------ F(
3, 84) = 57.46
Model |
617130.701 3 205710.234 Prob > F =
0.0000
Residual |
300723.805 84 3580.0453 R-squared = 0.6724
-------------+------------------------------ Adj R-squared = 0.6607
Total |
917854.506 87 10550.0518 Root MSE =
59.833
------------------------------------------------------------------------------
price | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
-------------+----------------------------------------------------------------
lotsize |
.0020677 .0006421 3.22
0.002 .0007908 .0033446
sqrft |
.1227782 .0132374 9.28
0.000 .0964541 .1491022
bdrms |
13.85252 9.010145 1.54
0.128 -4.065141 31.77018
_cons |
-21.77031 29.47504 -0.74
0.462 -80.38466 36.84405
------------------------------------------------------------------------------
*Ejercicio C6.6 vote1**
insheet using
"C:\Users\Nerys\Documents\Biblioteca\Econometria, libos ebooks\Solucion a
ejercicios de econometria\Base de datos wooldridge\vote1.csv ", comma
clear
i.***
. gen expendAExpendB= expenda*expendb
. regress votea
prtystra expenda expendb expendAExpendB
Source | SS
df MS Number of obs = 173
-------------+------------------------------ F(
4, 168) = 55.86
Model |
27660.966 4 6915.2415 Prob > F =
0.0000
Residual |
20796.2826 168 123.787396 R-squared =
0.5708
-------------+------------------------------ Adj R-squared = 0.5606
Total |
48457.2486 172 281.728189 Root MSE =
11.126
--------------------------------------------------------------------------------
votea | Coef.
Std. Err. t P>|t|
[95% Conf. Interval]
---------------+----------------------------------------------------------------
prtystra
| .3419406 .0879928
3.89 0.000 .1682266
.5156547
expenda
| .038281 .00496
7.72 0.000 .0284891
.0480729
expendb
| -.0317238 .0045875
-6.92 0.000 -.0407805
-.0226672
expendAExpendB |
-6.63e-06 7.19e-06 -0.92
0.358 -.0000208 7.56e-06
_cons
| 32.11731 4.591145
7.00 0.000 23.05354
41.18109
--------------------------------------------------------------------------------
*Efecto parcial de ExpendB sobre vote A
: display _b[expendb]+(_b[expendAExpendB]*expenda)
*Efecto parcial de ExpendA sobre vote A
: display _b[expenda]+(_b[expendAExpendB]*expendb)
ii.
No, no es significativo
iii.
. ci expenda
Variable | Obs Mean
Std. Err. [95%
Conf. Interval]
-------------+---------------------------------------------------------------
expenda
| 173 310.6111
21.36295 268.4438 352.7784