Ejercicio de Pruebas de Normalidad

Cargando Data Frame

library(wooldridge)
data(hprice1)
#Visualizacion de las primeras 5 observaciones
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

Parte 1 - Estimacion del Modelo.

library(stargazer)
regresion_wool<-lm(formula = price~lotsize+sqrft+bdrms, data = hprice1)
stargazer(regresion_wool, title="Estimación Modelo Wool", type = "text")
## 
## Estimación Modelo Wool
## ===============================================
##                         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

Parte 2 - Literal A - Prueba JB

Tabulacion Prueba JB

library(normtest)
library(magrittr)
prueba_JB<-jb.norm.test(regresion_wool$residuals)
frame_JB<-cbind(prueba_JB$statistic, prueba_JB$p.value)%>%as.data.frame(row.names = "Prueba Jarque - Bera")
names(frame_JB)<-c("JB", "P-Value")
print(frame_JB)
##                            JB P-Value
## Prueba Jarque - Bera 32.27791   0.001

Gráfica Prueba JB

library(fastGraph)
gl<-2
Valor_Critico_JB<-qchisq(p=0.95, df=gl)
shadeDist(xshade= prueba_JB$statistic, ddist = "dchisq", parm1 = gl, lower.tail = FALSE, sub = paste("VC = " ,Valor_Critico_JB  %>% round(digits = 6), "JB = ",prueba_JB$statistic %>% round(digits = 6)), col = "blue")

Con la prueba Jarque-Bera y un nivel de significancia del 5.00% se obtiene un valor de P-Value = 0.001 siendo menor a un 0.05, de modo que no se acepta la Hipotesis Nula; no se tiene evidencia que los residuos tengan una distribucion Normal.

Parte 2 - Literal B - Prueba KS

library(nortest)
library(magrittr)
prueba_KS<-lillie.test(regresion_wool$residuals)
frame_KS<-cbind(prueba_KS$statistic, prueba_KS$p.value)%>%as.data.frame(row.names = "Prueba Kolmogorov-Smirnov")
names(frame_KS)<-c("KS", "P-Value")
print(frame_KS)
##                                  KS   P-Value
## Prueba Kolmogorov-Smirnov 0.0754392 0.2496425

Gráfica Prueba KS

library(fastGraph)
gl<-2
Valor_Critico_KS<-qchisq(p=0.95, df=gl)
shadeDist(xshade= prueba_KS$statistic, ddist = "dchisq", parm1 = gl, lower.tail = FALSE, sub = paste("VC = ", Valor_Critico_KS  %>% round(digits = 6), "KS = ",prueba_KS$statistic %>% round(digits = 6)), col = "blue")

Con la prueba Kolmogorov-Smirnov y un nivel de significancia del 5.00% se obtiene un valor de P-Value = 0.2496 siendo mayor a 0.05, de modo que no se Rechaza la Hipotesis Nula; aportando evidencia que los residuos tienen una distribucion Normal.

Parte 2 - Literal C - Prueba SW (Shapiro)

library(magrittr)
prueba_SW<-shapiro.test(regresion_wool$residuals)
frame_SW<-cbind(prueba_SW$statistic, prueba_SW$p.value)%>%as.data.frame(row.names = "Prueba Shapiro (SW)")
names(frame_SW)<-c("Shapiro", "P-Value")
print(frame_SW)
##                       Shapiro      P-Value
## Prueba Shapiro (SW) 0.9413208 0.0005937472

Gráfica Prueba SW

library(fastGraph)
gl<-2
Valor_Critico_SW<-qchisq(p=0.95, df=gl)
shadeDist(xshade= prueba_SW$statistic, ddist = "dchisq", parm1 = gl, lower.tail = FALSE, sub = paste("VC = ", Valor_Critico_SW  %>% round(digits = 6), "SW = ", prueba_SW$statistic %>% round(digits = 6)), col = "blue")

Con la prueba Shapiro y un nivel de significancia del 5.00% se obtiene un valor de P-Value = 0.0005937 siendo menor que 0.05, de modo que no se Acepta la Hipotesis Nula; no aporta la evidencia suficiente de que los residuos tienen una distribucion Normal.