InvReal=Inversión Real en millones de US\(, Trend=tendencia, Inflation=inflación, PNBr=Producto Nacional Bruto Real en US\), Interest=Tasa de interés
library(readxl)
Investiment_Equation <- read_excel("C:/Users/jacob/Desktop/ROJAS/00 UES/Econometria/Guia 1 Archivos/Investiment_Equation.xlsx")
#Calculamos ecuación de inversión
ecuacion_inversion<-lm(formula = InvReal ~ Trend+Inflation+PNBr+Interest,
data = Investiment_Equation)
#Presentamos en formato APA con librería stargazer
library(stargazer)
stargazer(ecuacion_inversion,title = "Ecuación de Inversión",type = "text")
##
## Ecuación de Inversión
## ===============================================
## 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
#Calculamos la matriz x
matriz_x<-model.matrix(ecuacion_inversion)
#Calculamos matriz M
n<-nrow(matriz_x)
matriz_m<-diag(n)-matriz_x%*%solve(t(matriz_x)%*%matriz_x)%*%t(matriz_x)
#Asignamos a variable endogena (y) su valor segun la base de datos
y<-Investiment_Equation$InvReal
#Obtenemos residuos
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
confint(object = ecuacion_inversion, parm = "PNBr",level=0.93)
## 3.5 % 96.5 %
## PNBr 0.554777 0.774317