Numeral 1
library(readxl)
Investiment_Equation <- read_excel("C:/Users/gusta_000/Desktop/Econometria/Guia/Investiment_Equation.xlsx")
ecuacion_inversion <- lm(formula = InvReal~Trend+Inflation+PNBr+Interest, data = Investiment_Equation)
library(stargazer)
stargazer(ecuacion_inversion, title = "Ecuacion de inversion", type = "text")
##
## Ecuacion de inversion
## ===============================================
## Dependent variable:
## ---------------------------
## InvReal
## -----------------------------------------------
## Trend -0.016***
## (0.002)
##
## Inflation 0.00002
## (0.001)
##
## PNBr 0.665***
## (0.054)
##
## Interest -0.240*
## (0.120)
##
## Constant -0.503***
## (0.054)
##
## -----------------------------------------------
## Observations 15
## R2 0.973
## Adjusted R2 0.962
## Residual Std. Error 0.007 (df = 10)
## F Statistic 90.089*** (df = 4; 10)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
Numeral 2
model.matrix(ecuacion_inversion) -> matriz_x
n <- nrow(matriz_x)
matriz_M <- diag(n)-matriz_x%*%solve(t(matriz_x)%*%matriz_x)%*%t(matriz_x)
Y <- Investiment_Equation$InvReal
residuos <- matriz_M%*%Y
print(residuos)
## [,1]
## 1 -0.0100602233
## 2 -0.0009290882
## 3 0.0029656679
## 4 0.0078576839
## 5 0.0028109133
## 6 0.0006259732
## 7 0.0075909286
## 8 -0.0055352778
## 9 -0.0037254127
## 10 0.0006953129
## 11 0.0019904770
## 12 -0.0001288433
## 13 -0.0101976729
## 14 0.0068712384
## 15 -0.0008316770
Numeral 3
confint(object = ecuacion_inversion, parm = "PNBr", level = 0.93)
## 3.5 % 96.5 %
## PNBr 0.554777 0.774317
Interpretacion: En el 93% de las ocasiones que estimemos la ecuacion, se esperaria que el impacto de un millon de dolares del PNB real se traduzca en un minimo de 0.55 millones de dolares en inversion real hasta un maximo de 0.77 millones de dolares.