NUMERAL 1

library(readxl)
## Warning: package 'readxl' was built under R version 4.0.5
Investiment_Equation <- read_excel("C:/Users/Logistica4sv/Desktop/ALAN HERNANDEZ/UES 2021/ECONOMETRIA/Guia de trabajo 1/Investiment_Equation.xlsx")

Ecuacion_inversion<-lm(formula = InvReal~Trend+Inflation+PNBr+Interest,data = Investiment_Equation)
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=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

NUMERAL 2

model.matrix(Ecuacion_inversion)->Mat_X
n<-nrow(Mat_X)
M<-diag(n)-Mat_X%*%solve(t(Mat_X)%*%Mat_X)%*%t(Mat_X)
Y<-Investiment_Equation$InvReal
residuos<-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 = .93)
##         3.5 %   96.5 %
## PNBr 0.554777 0.774317