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.
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
library(stargazer)
options(scipen = 999999)
modelo_hprice1<-lm(formula = price~bdrms+lotsize,data = hprice1)
stargazer(modelo_hprice1,title = "Modelo hprice1",type = "text",digits = 8)
##
## Modelo hprice1
## ===============================================
## Dependent variable:
## ---------------------------
## price
## -----------------------------------------------
## bdrms 57.31285000***
## (10.88452000)
##
## lotsize 0.00285826***
## (0.00090014)
##
## Constant 63.26224000
## (39.61957000)
##
## -----------------------------------------------
## Observations 88
## R2 0.33681690
## Adjusted R2 0.32121260
## Residual Std. Error 84.62413000 (df = 85)
## F Statistic 21.58486000*** (df = 2; 85)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
library(fastGraph)
shadeDist(qnorm(0.95), "dnorm", 0, 1, col = c("purple","black"))
shadeDist(qnorm(0.95), lower.tail=FALSE, col = c("purple","black"))
library(stargazer)
#Matriz de Coeficientes
coeficientes_Modelo<-summary(modelo_hprice1)$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(modelo_hprice1, parm = t,level = 0.90))
}
## 5 % 95 %
## bdrms 39.21212 75.41358
## 5 % 95 %
## lotsize 0.001361347 0.004355174
#Grafica Distribucion T
library(fastGraph)
t_Valor_Critico<- shadeDist( c(-t_critico, t_critico ), "dt", 13,col=c("purple","black"),sub=paste("ParƔmetro de la Variable:",nombres[t]))
F_Anova<-summary(modelo_hprice1)$fstatistic[1]
grados_libertad_num<-summary(modelo_hprice1)$fstatistic[2]
grados_libertad_denom<-summary(modelo_hprice1)$fstatistic[3]
F_Valor_Critico<-qf(0.90,grados_libertad_num,grados_libertad_denom,lower.tail = TRUE)
print(F_Valor_Critico)
## [1] 2.366102
#Grafica Prueba F
library(fastGraph)
shadeDist(xshade = F_Anova,"df",grados_libertad_num,grados_libertad_denom,lower.tail = FALSE, col=c("purple","black"), sub=paste("Valor Critico:",F_Valor_Critico," ","F Critico:",F_Anova))
library(fastGraph)
shadeDist(qchisq(0.1,25,lower.tail = FALSE),ddist = 'dchisq',parm1 = 25,lower.tail = FALSE, col=c('purple','black'))
shadeDist(23,ddist = 'dchisq',parm1 = 25,lower.tail = FALSE,col=c('purple','black'),sub=paste(c(qchisq(0.1,25,lower.tail = FALSE))))