library(wooldridge)
library(fastGraph)
library(haven)
hprice1 <- read_dta("C:/Users/USUARIO/Downloads/hprice1.dta")
head(force(hprice1), n=5)
## # A tibble: 5 x 10
##   price assess bdrms lotsize sqrft colonial lprice lassess llotsize lsqrft
##   <dbl>  <dbl> <dbl>   <dbl> <dbl>    <dbl>  <dbl>   <dbl>    <dbl>  <dbl>
## 1   300   349.     4    6126  2438        1   5.70    5.86     8.72   7.80
## 2   370   352.     3    9903  2076        1   5.91    5.86     9.20   7.64
## 3   191   218.     3    5200  1374        0   5.25    5.38     8.56   7.23
## 4   195   232.     3    4600  1448        1   5.27    5.45     8.43   7.28
## 5   373   319.     4    6095  2514        1   5.92    5.77     8.72   7.83
library(fastGraph)
library(stargazer)
options(scipen=99999)
library(stargazer)
modelo_estimado<-lm(formula= price~lotsize+sqrft+bdrms, data = hprice1)
stargazer(modelo_estimado, type="html", 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

Coficiente desviacion p_values

library(fastGraph)
# matriz de coeficientes
matriz_coeficiente<-summary(modelo_estimado)$coefficients
t_valores<-matriz_coeficiente[, "t value"]
etiqueta<-names(t_valores)

prueba t

for(j in 2:4){
  tc<-t_valores[j]
  t_vc<-shadeDist( c(tc), "dt", 3, col=c("black", "yellow"), sub=paste("parametro de la variable:", etiqueta[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

Grafica del valor critico

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

Grafico prueba z

shadeDist()

Prueba F

f<-summary(modelo_estimado)$fstatistic[1]
gl_num<-summary(modelo_estimado)$fstatistic[2]
gl_den<-summary(modelo_estimado)$fstatistic[3]
f_vc<-qf(0.95,gl_num, gl_den, lower.tail=TRUE)
shadeDist(xshade=f,"df",gl_num, gl_den, lower.tail = FALSE,  sub=paste("vc:",f_vc,"fc", f))

grafica para p-value

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