#Exercise 13, Ch08 (Wooldridge)
Use the data in FERTIL2 to answer these questions.
children = b0 +b1age + b2age^2 + b3educ +b4electric+ b5urban + u
children=number of living children age=age in years educ=years of education electric = 1 if has electricity urban=1 if live in urban area
and report the usual and heteroskedasticity-robust standard errors. Are the robust standard errors always bigger than the nonrobust ones?
library(wooldridge)
library(sandwich)
library(lmtest)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
data=fertil2
Modelxd=lm(children~age+age^2+educ+electric+urban,data=fertil2)
summary(Modelxd)
##
## Call:
## lm(formula = children ~ age + age^2 + educ + electric + urban,
## data = fertil2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.6563 -0.6734 -0.0760 0.7540 7.0503
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.999655 0.096612 -20.698 < 2e-16 ***
## age 0.176652 0.002727 64.780 < 2e-16 ***
## educ -0.075611 0.006369 -11.872 < 2e-16 ***
## electric -0.303370 0.069795 -4.347 1.41e-05 ***
## urban -0.171306 0.046953 -3.648 0.000267 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.469 on 4353 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.5634, Adjusted R-squared: 0.563
## F-statistic: 1404 on 4 and 4353 DF, p-value: < 2.2e-16
Algunos son más pequeños, que sus respectivos errores estandares
bptest(Modelxd)
##
## studentized Breusch-Pagan test
##
## data: Modelxd
## BP = 1041.5, df = 4, p-value < 2.2e-16
#Ho: No hay heteroskedasticity H1: Hay heteroskedasticity
El valor de p, es menor que el valor de alfa, con cl (95%), por ende, no hay evidencia suficiente, para rechazar ho, por lo tanto, hayheteroskedasticity
#Ho: no hay heteroskedasticity H1: Hay heteroskedasticity
usqr=(summary(Modelxd)$residual)^2
yhat=Modelxd$fitted.values
yhatsqr=Modelxd$fitted.values^2
ModelxdWT=summary(lm(usqr~yhat+yhatsqr,data=fertil2))$r.squared
ModelxdWT*4361
## [1] 1093.183
1-pchisq(1093.183,2)
## [1] 0
El valor de p.value, es menor que alfa, con un 95% de confianza, por lo tanto, no se puede rechazar HO, por ende, hay heteroskedasticity