PRACTICA 6 ESTIMADOR HAC

MARIO ANTONIO HERRERA RIVERA

20 de junio de 2019

Modelo Estimado.

library(foreign)
datos_regresion<-read.dta("M:\\Econometria\\GUIA6/crime.dta")
modelo_estimado1<-lm(crime~poverty+single, data = datos_regresion)
print(modelo_estimado1)
## 
## Call:
## lm(formula = crime ~ poverty + single, data = datos_regresion)
## 
## Coefficients:
## (Intercept)      poverty       single  
##   -1368.189        6.787      166.373

Pruebas de Heterocedasticidad y Autocorrelacion.

Pruebas de Breush bagan (White).

library(lmtest)
prueba_white<-bptest(modelo_estimado1,~I(poverty^2)+I(single^2)+poverty*single, data=datos_regresion)
print(prueba_white)
## 
##  studentized Breusch-Pagan test
## 
## data:  modelo_estimado1
## BP = 10.73, df = 5, p-value = 0.057

Hay evidencia de heterocedasticidad ya que \(pvalue<0.05\)

Pruebas de Breush Godfrey

Verificando la autocorrelacion de 2do. orden.

library(lmtest)
bgtest(modelo_estimado1,order = 2)
## 
##  Breusch-Godfrey test for serial correlation of order up to 2
## 
## data:  modelo_estimado1
## LM test = 0.27165, df = 2, p-value = 0.873

NO hay evidencia de autocorrelacion de 2° orden ya que \(p value>0.05\)

Verificando la presencia de autocorrelacion de 1er. orden.

library(lmtest)
bgtest(modelo_estimado1,order = 1)
## 
##  Breusch-Godfrey test for serial correlation of order up to 1
## 
## data:  modelo_estimado1
## LM test = 0.27156, df = 1, p-value = 0.6023

NO hay evidencia de autocorrelacion de 1° orden ya que \(p value>0.05\)

Estimacion Robusta.

Usando las libreias “lmtest” y “sandwish”

library(lmtest)
library(sandwich)

#Sin corregir
coeftest(modelo_estimado1)
## 
## t test of coefficients:
## 
##               Estimate Std. Error t value  Pr(>|t|)    
## (Intercept) -1368.1887   187.2052 -7.3085 2.479e-09 ***
## poverty         6.7874     8.9885  0.7551    0.4539    
## single        166.3727    19.4229  8.5658 3.117e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Corregido.

estimacion_omega<-vcovHC(modelo_estimado1,type = "HC1")
coeftest(modelo_estimado1,vcov. = estimacion_omega)
## 
## t test of coefficients:
## 
##               Estimate Std. Error t value  Pr(>|t|)    
## (Intercept) -1368.1887   284.9180 -4.8020 1.577e-05 ***
## poverty         6.7874    10.9273  0.6211    0.5374    
## single        166.3727    26.2343  6.3418 7.519e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Estimador HAC

Si se hubiera detectado la presencia de autocorrelacion de 2do. orden se corregiria asi:

library(lmtest)
library(sandwich)

#Corregido.

estimacion_omega<-NeweyWest(modelo_estimado1,lag = 2)
coeftest(modelo_estimado1, vcov. = estimacion_omega)
## 
## t test of coefficients:
## 
##               Estimate Std. Error t value  Pr(>|t|)    
## (Intercept) -1368.1887   303.8466 -4.5029 4.280e-05 ***
## poverty         6.7874    10.5943  0.6407    0.5248    
## single        166.3727    25.9154  6.4198 5.708e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1