Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Econometría a través de STATA

AUTOCORRELACIÓN, HETEROSCEDASTICIDAD, MULTICOLINEALIDAD, NO


LINEALIDAD Y NORMALIDAD
Ejercicio página 49 Econometría a través de STATA

. use https://www.stata-press.com/data/r17/auto.dta
(1978 automobile data)

. gen forXmpg= foreign* mpg

. reg price weight mpg forXmpg foreign

Source SS df MS Number of obs = 74


F(4, 69) = 21.22
Model 350319665 4 87579916.3 Prob > F = 0.0000
Residual 284745731 69 4126749.72 R-squared = 0.5516
Adj R-squared = 0.5256
Total 635065396 73 8699525.97 Root MSE = 2031.4

price Coefficient Std. err. t P>|t| [95% conf. interval]

weight 4.613589 .7254961 6.36 0.000 3.166263 6.060914


mpg 263.1875 110.7961 2.38 0.020 42.15527 484.2197
forXmpg -307.2166 108.5307 -2.83 0.006 -523.7294 -90.70368
foreign 11240.33 2751.681 4.08 0.000 5750.878 16729.78
_cons -14449.58 4425.72 -3.26 0.002 -23278.65 -5620.51

. rvfplot, yline(0)

. avplots

. rvpplot mpg

. predict xdist, leverage

. sum xdist, detail

Leverage

Percentiles Smallest
1% .0192852 .0192852
5% .0198324 .0195139
10% .0217658 .0198281 Obs 74
25% .0266526 .0198324 Sum of wgt. 74

50% .0491565 Mean .0675676


Largest Std. dev. .0587061
75% .0784069 .2030623
90% .1439921 .2059959 Variance .0034464
95% .2030623 .2212826 Skewness 2.411152
99% .3581521 .3581521 Kurtosis 10.38242
Econometría a través de STATA

. predict zdist, dfits

. sum zdist, detail

DFITS

Percentiles Smallest
1% -.9384231 -.9384231
5% -.2974069 -.4402165
10% -.2110095 -.2984942 Obs 74
25% -.1222725 -.2974069 Sum of wgt. 74

50% -.0499477 Mean .0364329


Largest Std. dev. .3119636
75% .1387799 .5724172
90% .3069244 .8760136 Variance .0973213
95% .5724172 .9564455 Skewness 1.330149
99% 1.356619 1.356619 Kurtosis 8.061579

. predict residuos, residuals

. predict esta, rstandar

. predict estu, rstudent

. list residuos esta estu

residuos esta estu

1. -759.3586 -.3785332 -.376171


2. -731.1284 -.3673463 -.3650317
3. 278.5821 .1402231 .1392231
4. -992.332 -.493324 -.490602
5. -494.6731 -.2488081 -.2471095

6. -1431.664 -.7133379 -.7107756


7. 1771.403 .9010705 .8998269
8. -757.7396 -.3766557 -.3743014
9. 2709.857 1.35628 1.364731
10. -2155.183 -1.071628 -1.072799

11. 2173.117 1.102038 1.103781


12. 7271.96 3.677172 4.071051
13. 5036.348 2.74021 2.881586
14. 381.4716 .1971406 .195762
15. -1080.561 -.5411388 -.5383468
Econometría a través de STATA

. estat ovtest

Ramsey RESET test for omitted variables


Omitted: Powers of fitted values of price

H0: Model has no omitted variables

F(3, 66) = 7.77


Prob > F = 0.0002

. estat hettest

Breusch–Pagan/Cook–Weisberg test for heteroskedasticity


Assumption: Normal error terms
Variable: Fitted values of price

H0: Constant variance

chi2(1) = 6.50
Prob > chi2 = 0.0108

. estat imtest

Cameron & Trivedi's decomposition of IM-test

Source chi2 df p

Heteroskedasticity 18.86 10 0.0420


Skewness 11.69 4 0.0198
Kurtosis 2.33 1 0.1273

Total 32.87 15 0.0049

. estat vif

Variable VIF 1/VIF

forXmpg 29.70 0.033671


foreign 28.36 0.035255
mpg 7.27 0.137580
weight 5.62 0.177810

Mean VIF 17.74

.
Econometría a través de STATA

doFile
use https://www.stata-press.com/data/r17/auto.dta
gen forXmpg= foreign* mpg
reg price weight mpg forXmpg foreign
rvfplot, yline(0)
avplots
rvpplot mpg
predict xdist, leverage
sum xdist, detail
predict zdist, dfits
sum zdist, detail
predict residuos, residuals
predict esta, rstandar
predict estu, rstudent
list residuos esta estu
estat ovtest
estat hettest
estat imtest
estat vif
Econometría a través de STATA

. clear all

. use https://www.stata-press.com/data/r17/klein.dta

. tsset yr

Time variable: yr, 1920 to 1941


Delta: 1 unit

. reg consump wagegovt

Source SS df MS Number of obs = 22


F(1, 20) = 17.72
Model 532.567711 1 532.567711 Prob > F = 0.0004
Residual 601.207167 20 30.0603584 R-squared = 0.4697
Adj R-squared = 0.4432
Total 1133.77488 21 53.9892799 Root MSE = 5.4827

consump Coefficient Std. err. t P>|t| [95% conf. interval]

wagegovt 2.50744 .5957173 4.21 0.000 1.264796 3.750085


_cons 40.84699 3.192183 12.80 0.000 34.18821 47.50577

. estat dwatson

Durbin–Watson d-statistic( 2, 22) = .3217998

. estat durbinalt

Durbin's alternative test for autocorrelation

lags(p) chi2 df Prob > chi2

1 35.035 1 0.0000

H0: no serial correlation


Econometría a través de STATA

. estat bgodfrey

Breusch–Godfrey LM test for autocorrelation

lags(p) chi2 df Prob > chi2

1 14.264 1 0.0002

H0: no serial correlation

. estat archlm, lags(1 2 3)


LM test for autoregressive conditional heteroskedasticity (ARCH)

lags(p) chi2 df Prob > chi2

1 5.543 1 0.0186
2 9.431 2 0.0090
3 9.039 3 0.0288

H0: no ARCH effects vs. H1: ARCH(p) disturbance

doFile

use https://www.stata-press.com/data/r17/auto.dta
gen forXmpg= foreign* mpg
reg price weight mpg forXmpg foreign
rvfplot, yline(0)
avplots
rvpplot mpg
predict xdist, leverage
sum xdist, detail
predict zdist, dfits
sum zdist, detail
predict residuos, residuals
predict esta, rstandar
predict estu, rstudent
list residuos esta estu
estat ovtest
estat hettest
estat imtest
estat vif
clear all
use https://www.stata-press.com/data/r17/klein.dta
tsset yr
reg consump wagegovt
estat dwatson
estat durbinalt
estat bgodfrey
estat archlm, lags (1 2 3)

Ejercicio 2.2.
Econometría a través de STATA

a)-
. clear all

. use "C:\Econometría Básica\salarios.dta"

. reg lwagelogwage expersqexper2 tenursqtenure2 educyearsofeducation smsa1iflive


> insmsa female1iffemale nonwhite1ifnonwhite married1ifmarried

Source SS df MS Number of obs = 526


F(7, 518) = 47.18
Model 57.7491698 7 8.2498814 Prob > F = 0.0000
Residual 90.580592 518 .174866008 R-squared = 0.3893
Adj R-squared = 0.3811
Total 148.329762 525 .28253288 Root MSE = .41817

lwagelogwage Coefficient Std. err. t P>|t| [95% conf. interval]

expersqexper2 .00005 .0000353 1.42 0.157 -.0000194 .0001194


tenursqtenu~2 .0004274 .0001027 4.16 0.000 .0002257 .0006292
educyearsof~n .075768 .007288 10.40 0.000 .0614504 .0900856
smsa1iflive~a .1644393 .0421344 3.90 0.000 .0816639 .2472146
female1iffe~e -.3021278 .0376665 -8.02 0.000 -.3761256 -.22813
nonwhite1if~e .0080898 .0604122 0.13 0.894 -.1105932 .1267728
married1ifm~d .1856848 .0395197 4.70 0.000 .1080461 .2633234
_cons .5264751 .101878 5.17 0.000 .3263302 .7266201

. predict res, residuals

. histogram res
(bin=22, start=-1.933759, width=.14895717)

. rvfplot, yline(0)

. estat hettest

Breusch–Pagan/Cook–Weisberg test for heteroskedasticity


Assumption: Normal error terms
Variable: Fitted values of lwagelogwage

H0: Constant variance

chi2(1) = 2.42
Prob > chi2 = 0.1200
Econometría a través de STATA

. estat imtest

Cameron & Trivedi's decomposition of IM-test

Source chi2 df p

Heteroskedasticity 42.36 31 0.0839


Skewness 2.56 7 0.9226
Kurtosis 2.02 1 0.1555

Total 46.94 39 0.1791

. estat imtest, white

White's test
H0: Homoskedasticity
Ha: Unrestricted heteroskedasticity

chi2(31) = 42.36
Prob > chi2 = 0.0839

Cameron & Trivedi's decomposition of IM-test

Source chi2 df p

Heteroskedasticity 42.36 31 0.0839


Skewness 2.56 7 0.9226
Kurtosis 2.02 1 0.1555

Total 46.94 39 0.1791

b)-
. estat ovtest

Ramsey RESET test for omitted variables


Omitted: Powers of fitted values of lwagelogwage

H0: Model has no omitted variables

F(3, 515) = 4.70


Prob > F = 0.0030
Econometría a través de STATA

. estat ovtest, rhs

Ramsey RESET test for omitted variables


Omitted: Powers of independent variables

H0: Model has no omitted variables

F(9, 509) = 7.82


Prob > F = 0.0000

. estat ovtest, rhs

Ramsey RESET test for omitted variables


Omitted: Powers of independent variables

H0: Model has no omitted variables

F(9, 509) = 7.82


Prob > F = 0.0000

. Linktest
command Linktest not defined by Linktest.ado
r(199);

. linktest

Source SS df MS Number of obs = 526


F(2, 523) = 174.03
Model 59.2707822 2 29.6353911 Prob > F = 0.0000
Residual 89.0589795 523 .170284856 R-squared = 0.3996
Adj R-squared = 0.3973
Total 148.329762 525 .28253288 Root MSE = .41266

lwagelogwage Coefficient Std. err. t P>|t| [95% conf. interval]

_hat -.0544517 .3569017 -0.15 0.879 -.7555887 .6466853


_hatsq .3214321 .1075289 2.99 0.003 .1101904 .5326738
_cons .8293946 .2916788 2.84 0.005 .2563887 1.4024
Econometría a través de STATA

. estat ovtest, rhs

Ramsey RESET test for omitted variables


Omitted: Powers of independent variables

H0: Model has no omitted variables

F(9, 509) = 7.82


Prob > F = 0.0000

. Linktest
command Linktest not defined by Linktest.ado
r(199);

. linktest

Source SS df MS Number of obs = 526


F(2, 523) = 174.03
Model 59.2707822 2 29.6353911 Prob > F = 0.0000
Residual 89.0589795 523 .170284856 R-squared = 0.3996
Adj R-squared = 0.3973
Total 148.329762 525 .28253288 Root MSE = .41266

lwagelogwage Coefficient Std. err. t P>|t| [95% conf. interval]

_hat -.0544517 .3569017 -0.15 0.879 -.7555887 .6466853


_hatsq .3214321 .1075289 2.99 0.003 .1101904 .5326738
_cons .8293946 .2916788 2.84 0.005 .2563887 1.4024

c)-
. avplot educyearsofeducation

d)-
. kdensity res, normal
Econometría a través de STATA

. swilk res

Shapiro–Wilk W test for normal data

Variable Obs W V z Prob>z

res 526 0.98720 4.507 3.627 0.00014

. sktest res

Skewness and kurtosis tests for normality


Joint test
Variable Obs Pr(skewness) Pr(kurtosis) Adj chi2(2) Prob>chi2

res 526 0.1322 0.0008 12.23 0.0022

e)-
Econometría a través de STATA

doFile
clear all
use "C:\Econometría Básica\salarios.dta"
regress lwagelogwage educyearsofeducation experyearspotentialexperience expersqexper2
northcen1ifliveinnorthcentralus married1ifmarried female1iffemale smsa1ifliveinsmsa
regress lwagelogwage educyearsofeducation experyearspotentialexperience expersqexper2
northcen1ifliveinnorthcentralus married1ifmarried female1iffemale smsa1ifliveinsmsa
predict res, residuals
histogram res
rvfplot, yline (0)
estat hettest
estat imtest
clear all
use "C:\Econometría Básica\salarios.dta"
reg lwagelogwage expersqexper2 tenursqtenure2 educyearsofeducation smsa1ifliveinsmsa female1iffemale
nonwhite1ifnonwhite married1ifmarried
predict res, residuals
histogram res
rvfplot, yline (0)
estat hettest
estat imtest
estat imtest, white
estat ovtest
estat ovtest, rhs
linktest
avplot educyearsofeducation
kdensity res, normal
swilk res
sktest res

You might also like