library(wooldridge)
data(hprice1)
head(force(hprice1), n=5)
##   price assess bdrms lotsize sqrft colonial   lprice  lassess llotsize   lsqrft
## 1   300  349.1     4    6126  2438        1 5.703783 5.855359 8.720297 7.798934
## 2   370  351.5     3    9903  2076        1 5.913503 5.862210 9.200593 7.638198
## 3   191  217.7     3    5200  1374        0 5.252274 5.383118 8.556414 7.225482
## 4   195  231.8     3    4600  1448        1 5.273000 5.445875 8.433811 7.277938
## 5   373  319.1     4    6095  2514        1 5.921578 5.765504 8.715224 7.829630
  1. Estimacion del Modelo
modelo_estimado_heterocedasticidad<-lm(formula = price~lotsize+sqrft+bdrms, data = hprice1)
library(stargazer)
stargazer(modelo_estimado_heterocedasticidad, title = "Modelo Estimado Regresion Lineal",type="html", digits=5)
Modelo Estimado Regresion Lineal
Dependent variable:
price
lotsize 0.00207***
(0.00064)
sqrft 0.12278***
(0.01324)
bdrms 13.85252
(9.01015)
Constant -21.77031
(29.47504)
Observations 88
R2 0.67236
Adjusted R2 0.66066
Residual Std. Error 59.83348 (df = 84)
F Statistic 57.46023*** (df = 3; 84)
Note: p<0.1; p<0.05; p<0.01

2.A Prueba de White para determinar la si la varianza es homocedastica

library(lmtest)
Prueba_de_White<-bptest(modelo_estimado_heterocedasticidad,~I(lotsize^2)+I(sqrft^2)+(bdrms^2)+lotsize*sqrft+bdrms, data = hprice1)
print(Prueba_de_White)
## 
##  studentized Breusch-Pagan test
## 
## data:  modelo_estimado_heterocedasticidad
## BP = 32.606, df = 6, p-value = 1.248e-05
  1. B Graficar por medio de FastGraph Calculo del Estadistico de Prueba
library(fastGraph)
LM_w<-Prueba_de_White$BP
VC<-qchisq(p = 0.95,df = 6+choose(3,2))
shadeDist(LM_w,ddist = 'dchisq',parm1 =VC,lower.tail = FALSE)

Interpretacion: el Valor LMw, que en los resultados se define como BP es mayor al X cuadrado encontrado en la tabla Chi Cuadrado, quiere decir, segun la teoria, hay existencia de heterocedasticidad en el modelo, lo que significa que la varianza de los errores de dichas variables explicativas no es constante