Importacion de datos

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

Estimacion del modelo

modelo_estimado<-lm(formula = price~lotsize+sqrft+bdrms,data = hprice1)
stargazer::stargazer(modelo_estimado, type = "text", title = "Modelo Estimado")
## 
## Modelo Estimado
## ===============================================
##                         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

Coeficiente de desviacion P value

library(fastGraph)
options(scipen = 999999999)
# Matriz de coeficientes
M_coeficientes<-summary(modelo_estimado)$coefficients
t_valores<-M_coeficientes[, "t value"]
etiquetas<-names(t_valores)

Prueba distribucion Z

library(fastGraph)
shadeDist()

Prueba distribucion t

library(fastGraph)
for (j in 2:4) {
  tc<-t_valores[j]
  t_vc<-shadeDist(c(tc),"dt",3,col = c("black","blue"),
                  sub=paste("Parametro de la variable:",etiquetas[j]))
  print(confint(modelo_estimado,parm = j,level = 0.95))
}

##               2.5 %      97.5 %
## lotsize 0.000790769 0.003344644

##            2.5 %    97.5 %
## sqrft 0.09645415 0.1491022

##           2.5 %   97.5 %
## bdrms -4.065141 31.77018

Prueba distribubion F

options(scipen = 999999999)
library(fastGraph)
F_anova<-summary(modelo_estimado)$fstatistic[1]
gl_nm<-summary(modelo_estimado)$fstatistic[2]
gl_dn<-summary(modelo_estimado)$fstatistic[3]
F_vc<-qf(0.95,gl_nm,gl_dn,lower.tail = TRUE)
         shadeDist(xshade = F_anova,"df",gl_nm,gl_dn,lower.tail = FALSE,col=c("black","blue"), sub=paste("VC:",F_vc," ","Fc:",F_anova))

Valor Critico (Grafica)

library(fastGraph)
shadeDist(qchisq(0.05,88,lower.tail = FALSE),ddist = "dchisq",parm1=88,lower.tail=FALSE)

P value (Grafica)

library(fastGraph)
shadeDist(88,ddist = "dchisq",parm1 = 88,lower.tail = FALSE,col = c("black","purple"),sub=paste(c(qchisq(0.05,88,lower.tail = FALSE))))