Investigación de la librería fastGraph.

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.

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

Estimacion del Modelo.

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

Distribución Z.

library(fastGraph)
shadeDist(qnorm(0.95), "dnorm", 0, 1, col = c("blue","lightblue")) 

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

Distribución T.

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

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

Distribución F.

library(fastGraph)
F_Anova<-summary(regresion_Precio)$fstatistic[1]
grados_Libertad_num<-summary(regresion_Precio)$fstatistic[2]
grados_Libertad_denom<-summary(regresion_Precio)$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("blue","lightblue"), sub=paste("Valor Critico:",F_Valor_Critico," ","F Critico:",F_Anova))

Distribución Chi^2.

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

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