library(wooldridge)
data(hprice1)
head(force(hprice1), n=5) #mostrar las primeras 5 observaciones
## 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
library(stargazer)
modelo_price<-lm(formula = price~lotsize+sqrft+bdrms, data = hprice1)
stargazer(modelo_price, title="Estimación Modelo Price", type = "text")
##
## Estimación Modelo Price
## ===============================================
## Dependent variable:
## ---------------------------
## price
## -----------------------------------------------
## lotsize 0.002***
## (0.001)
##
## sqrft 0.123***
## (0.013)
##
## bdrms 13.853
## (9.010)
##
## Constant -21.770
## (29.475)
##
## -----------------------------------------------
## Observations 88
## R2 0.672
## Adjusted R2 0.661
## Residual Std. Error 59.833 (df = 84)
## F Statistic 57.460*** (df = 3; 84)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
#Tabulación de prueba JB.
library(normtest)
Prueba_JB<-jb.norm.test(modelo_price$residuals)
print(Prueba_JB)
##
## Jarque-Bera test for normality
##
## data: modelo_price$residuals
## JB = 32.278, p-value < 0.00000000000000022
#Grafica de la prueba JB.
library(fastGraph)
GL_JB<-2
VC_JB<-qchisq(p=0.95, df=GL_JB)
shadeDist(xshade = Prueba_JB$statistic,
ddist = "dchisq",
parm1= GL_JB, lower.tail = FALSE,
sub=paste("VC=", VC_JB, "JB=", Prueba_JB$statistic))
Se rechaza la H0, por lo tanto no se tiene evidencia que los residuos tengan distribución normal, ya que el p-value<0.05 (el nivel de p-value es 0.001)
#Tabulacion de la prueba KS.
library(nortest)
Prueba_KS<-lillie.test(modelo_price$residuals)
print(Prueba_KS)
##
## Lilliefors (Kolmogorov-Smirnov) normality test
##
## data: modelo_price$residuals
## D = 0.075439, p-value = 0.2496
#Grafica de la prueba KS
library(fastGraph)
GL_KS<-2
VC_KS<-qchisq(p=0.95, df=GL_KS)
shadeDist(xshade = Prueba_KS$statistic,
ddist = "dchisq",
parm1= GL_KS, lower.tail = FALSE,
sub=paste("VC=", VC_KS, "KS=", Prueba_KS$statistic))
No se rechaza la H0, por lo tanto hay evidencia que los residuos tienen distribución normal, ya que el p-value>0.05 (el p-value es 0.2496)
#Tabulacion de la Prueba SW.
library(fastGraph)
Prueba_SW<-shapiro.test(modelo_price$residuals)
print(Prueba_SW)
##
## Shapiro-Wilk normality test
##
## data: modelo_price$residuals
## W = 0.94132, p-value = 0.0005937
#Grafica de prueba SW.
library(fastGraph)
GL_SW<-2
VC_SW<-qchisq(p=0.95, df=GL_SW)
shadeDist(xshade = Prueba_SW$statistic,
ddist = "dchisq",
parm1= GL_SW, lower.tail = FALSE,
sub=paste("VC=", VC_JB, "SW=", Prueba_SW$statistic))
Se rechaza la H0, por lo tanto no hay evidencia de que los residuos tengan distribución normal, ya que el p-value<0.05 (el p-value es 0.0005937)