library(readxl)
library(readxl)
Lima2022 <- read_excel("C:/Users/JHOJAN/Downloads/Lima2022.xlsx", 
    col_types = c("text", "numeric", "numeric", 
        "numeric"))
View(Lima2022)
h1=formula(resultados~QRESIDUOS_NO_DOM+año)
reg1=lm(h1,data=Lima2022)
summary(reg1)
## 
## Call:
## lm(formula = h1, data = Lima2022)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -19.472  -7.132  -2.711   6.663  32.095 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      24.7050106  3.8132570   6.479    1e-07 ***
## QRESIDUOS_NO_DOM -0.0001245  0.0001019  -1.221   0.2292    
## año               0.0362074  0.0167911   2.156   0.0371 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.17 on 40 degrees of freedom
## Multiple R-squared:  0.1168, Adjusted R-squared:  0.0726 
## F-statistic: 2.644 on 2 and 40 DF,  p-value: 0.08347
plot(reg1, 3)

library(lmtest)
## Warning: package 'lmtest' was built under R version 4.3.3
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.3.2
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(kableExtra)
## Warning: package 'kableExtra' was built under R version 4.3.3
resBP=bptest(reg1)
data.frame(list('BP'=resBP$statistic,
             'df'=resBP$parameter,
             "p-value"=resBP$p.value))%>%
    kable(caption = resBP$method)%>%kable_styling(full_width = F)
studentized Breusch-Pagan test
BP df p.value
BP 1.010546 2 0.6033409
resSW=shapiro.test(reg1$residuals)
data.frame(list('SW'=resSW$statistic,
             "p-value"=resSW$p.value))%>%
    kable(caption = resSW$method)%>%kable_styling(full_width = F)
Shapiro-Wilk normality test
SW p.value
W 0.9304653 0.0120625
library(DescTools)
# > 5 es problematico
VIF(reg1) %>%kable(col.names = "VIF",caption ="Evaluando Multicolinealidad usando VIF (Variance Inflation Factors)" )%>%kable_styling(full_width = F)
Evaluando Multicolinealidad usando VIF (Variance Inflation Factors)
VIF
QRESIDUOS_NO_DOM 1.043209
año 1.043209