Estimacion del Modelo sin corregir
library(foreign)
library(stargazer)
library(equatiomatic)
datae<-read.dta("https://stats.idre.ucla.edu/stat/data/crime.dta")
modeloestimado<-lm(crime~poverty+single, data = datae)
extract_eq(modeloestimado)
\[ \operatorname{crime} = \alpha + \beta_{1}(\operatorname{poverty}) + \beta_{2}(\operatorname{single}) + \epsilon \] Modelo Corregido con Estimador HAC
library(lmtest)
library(sandwich)
estimacionomega<-NeweyWest(modeloestimado, lag = 2)
coeftest(modeloestimado, vcov. = estimacionomega)
##
## 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