Estimación del Modelo
library(foreign)
library(haven)
library(stargazer)
crime <- read_dta("https://stats.idre.ucla.edu/stat/data/crime.dta")
modelo_crime<-lm(crime~poverty+single,data = crime)
stargazer(modelo_crime, type = "html", title = "Modelo Estimado")| Dependent variable: | |
| crime | |
| poverty | 6.787 |
| (8.989) | |
| single | 166.373*** |
| (19.423) | |
| Constant | -1,368.189*** |
| (187.205) | |
| Observations | 51 |
| R2 | 0.707 |
| Adjusted R2 | 0.695 |
| Residual Std. Error | 243.610 (df = 48) |
| F Statistic | 57.964*** (df = 2; 48) |
| Note: | p<0.1; p<0.05; p<0.01 |
Stargazer para Modelos Robustos (autocorrelación de 1º orden)
library(lmtest)
library(stargazer)
library(sandwich)
estimacion.omega <- vcovHC(modelo_crime,type = "HC1")
Robusto <- sqrt(diag(estimacion.omega))
stargazer(modelo_crime, modelo_crime, se = list(NULL, Robusto),
column.labels = c("Por Defecto", "Calculo Robusto"), align = T,
type = "html",
title="Errores Robustos: Autocorrelación de Primer Orden")| Dependent variable: | ||
| crime | ||
| Por Defecto | Calculo Robusto | |
| (1) | (2) | |
| poverty | 6.787 | 6.787 |
| (8.989) | (10.927) | |
| single | 166.373*** | 166.373*** |
| (19.423) | (26.234) | |
| Constant | -1,368.189*** | -1,368.189*** |
| (187.205) | (284.918) | |
| Observations | 51 | 51 |
| R2 | 0.707 | 0.707 |
| Adjusted R2 | 0.695 | 0.695 |
| Residual Std. Error (df = 48) | 243.610 | 243.610 |
| F Statistic (df = 2; 48) | 57.964*** | 57.964*** |
| Note: | p<0.1; p<0.05; p<0.01 | |
Stargazer para Modelos Robustos (autocorrelación de 2º orden)
estimacion.omega.2 <- NeweyWest(modelo_crime,lag = 2)
Robusto.2 <- sqrt(diag(estimacion.omega.2))
stargazer(modelo_crime,modelo_crime, se = list(NULL, Robusto.2),
column.labels = c("Por defecto", "Robusto Segundo Orden"), align = T,
type = "html",
title="Errores Robustos: Autocorrelación de Segundo Orden")| Dependent variable: | ||
| crime | ||
| Por defecto | Robusto Segundo Orden | |
| (1) | (2) | |
| poverty | 6.787 | 6.787 |
| (8.989) | (10.594) | |
| single | 166.373*** | 166.373*** |
| (19.423) | (25.915) | |
| Constant | -1,368.189*** | -1,368.189*** |
| (187.205) | (303.847) | |
| Observations | 51 | 51 |
| R2 | 0.707 | 0.707 |
| Adjusted R2 | 0.695 | 0.695 |
| Residual Std. Error (df = 48) | 243.610 | 243.610 |
| F Statistic (df = 2; 48) | 57.964*** | 57.964*** |
| Note: | p<0.1; p<0.05; p<0.01 | |