#1 carga de datos

library(wooldridge)
## Warning: package 'wooldridge' was built under R version 4.0.5
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

#2

library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
modelo_regresion<-lm(formula = price~assess+lotsize, data = hprice1)
stargazer(modelo_regresion, title = "Modelo regresion", type = "text")
## 
## Modelo regresion
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                                price           
## -----------------------------------------------
## assess                       0.956***          
##                               (0.052)          
##                                                
## lotsize                        0.001           
##                              (0.0005)          
##                                                
## Constant                      -13.317          
##                              (16.272)          
##                                                
## -----------------------------------------------
## Observations                    88             
## R2                             0.822           
## Adjusted R2                    0.818           
## Residual Std. Error      43.800 (df = 85)      
## F Statistic           196.720*** (df = 2; 85)  
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01

distribucion Z

library(fastGraph)
## Warning: package 'fastGraph' was built under R version 4.0.5
shadeDist(qnorm(0.75), "dnorm", 0, 1, col = c("lightblue", "blue"))

shadeDist(qnorm(0.95), lower.tail=FALSE, col = c("lightblue", "red"))

# Distribucion T

library(fastGraph)
#Matriz de Coeficientes desviación P-Value
coeficientes<-summary(modelo_regresion)$coefficients
t_Value<-coeficientes[,"t value"]
nombres<-names(t_Value)
for(t in 2:3)
  {
    t_critico<-t_Value[t]
    #Valores Criticos
    print(confint(modelo_regresion, parm = t,level = 0.90))
    #Graficacion Distribucion T
     t_Valor_Critico<- shadeDist( c(-t_critico, t_critico ), "dt", 13,col=c("lightblue","green"),sub=paste("Parámetro de la Variable:",nombres[t]))
  }
##              5 %     95 %
## assess 0.8689829 1.042448

##                   5 %        95 %
## lotsize -0.0002461614 0.001378908

distribucion F

library(fastGraph)
F_Anova<-summary(modelo_regresion)$fstatistic[1]
grados_Libertad_num<-summary(modelo_regresion)$fstatistic[2]
grados_Libertad_denom<-summary(modelo_regresion)$fstatistic[3]
F_Valor_Critico<-qf(0.90,grados_Libertad_num,grados_Libertad_denom,lower.tail = TRUE)
#Graficación Prueba F
shadeDist(xshade = F_Anova,"df",grados_Libertad_num,grados_Libertad_denom,lower.tail = FALSE, col=c("lightblue","orange"), sub=paste("Valor Critico:",F_Valor_Critico," ","F Critico:",F_Anova))

distribucion chi cuadrado

library(fastGraph)
#Gráfica
shadeDist(qchisq(0.1,25,lower.tail = FALSE),ddist = 'dchisq',parm1 = 25,lower.tail = FALSE, col=c('lightblue', 'pink'))

shadeDist(23,ddist = 'dchisq',parm1 = 25,lower.tail = FALSE,col=c('lightblue','yellow'),sub=paste(c(qchisq(0.1,25,lower.tail = FALSE))))