Cargado de datos.

options(scipen = 999999)
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

1. Estimar el modelo

library(stargazer)
modelo_price<-lm(formula = price~lotsize+sqrft, 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.133***          
##                               (0.011)          
##                                                
## Constant                       5.932           
##                              (23.512)          
##                                                
## -----------------------------------------------
## Observations                    88             
## R2                             0.663           
## Adjusted R2                    0.655           
## Residual Std. Error      60.312 (df = 85)      
## F Statistic           83.666*** (df = 2; 85)   
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01

Presente unas pequeñas instrucciones para graficar un valor crítico y un “p-value” para las distribuciones Z,T, F, chi^2 y algunos ejemplos gráficos. ## Distribucion Z

library(fastGraph)
## Warning: package 'fastGraph' was built under R version 4.0.5
shadeDist(c(0.98),"dnorm" , 0, 1, lower.tail = TRUE )

Distribucion T

library(fastGraph)
Coeficientes<-summary(modelo_price)$coefficients
T_values<-Coeficientes[,"t value"]
Etiquetas<-names(T_values)
#Gráficas Prueba T 
for(k in 2:3){
  tc<-T_values[k]
  Valores_Criticos_T<-
  shadeDist( c(-tc, tc ), 
             "dt", 13,
             sub=paste("Par. Variable:",
             Etiquetas[k]))
  print(confint(modelo_price,parm = k,level = 0.98))
}

##                  1 %        99 %
## lotsize 0.0005804874 0.003646502

##             1 %      99 %
## sqrft 0.1063397 0.1603843

Distribucion F

F_Anova<-summary(modelo_price)$fstatistic[1]
GLibertad_N<-summary(modelo_price)$fstatistic[2]
GLibertad_D<-summary(modelo_price)$fstatistic[3]
 Valores_Criticos_F<-qf(0.98,GLibertad_N,GLibertad_D,lower.tail = TRUE)
shadeDist(xshade = F_Anova,"df",GLibertad_N,GLibertad_D,lower.tail = FALSE,
          sub=paste("VC:", Valores_Criticos_F," ","Fc:",F_Anova))

Distribucion chi^2

#Chi-Cuadada
library(fastGraph)
shadeDist(qchisq(0.02,88,lower.tail = FALSE),ddist = 'dchisq',parm1 = 88,lower.tail = FALSE)