library(rio)
library(DescTools)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
data=import("dataPeru.xlsx")
data$porcentajeContribuyentes <- (data$contribuyentesSunat / data$pobTotal) * 100
data$porcentajePEA <- (data$peaOcupada / data$pobTotal) * 100
modelo1 <- lm(buenEstado ~ porcentajeContribuyentes + porcentajePEA, data = data)
summary(modelo1)
## 
## Call:
## lm(formula = buenEstado ~ porcentajeContribuyentes + porcentajePEA, 
##     data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.0928  -4.3610   0.2575   4.4003  11.0196 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)
## (Intercept)              -22.6095    15.9617  -1.416    0.171
## porcentajeContribuyentes   0.1003     0.3121   0.321    0.751
## porcentajePEA              1.0218     0.6424   1.590    0.126
## 
## Residual standard error: 6.299 on 22 degrees of freedom
## Multiple R-squared:  0.4669, Adjusted R-squared:  0.4184 
## F-statistic: 9.633 on 2 and 22 DF,  p-value: 0.000989
modelo2 <- lm(peaOcupada ~ contribuyentesSunat + buenEstado, data = data)
summary(modelo2)
## 
## Call:
## lm(formula = peaOcupada ~ contribuyentesSunat + buenEstado, data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -91867 -58573 -11166  46174 155851 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          1.155e+05  3.787e+04   3.049  0.00588 ** 
## contribuyentesSunat  9.206e-01  1.741e-02  52.872  < 2e-16 ***
## buenEstado          -1.412e+03  1.983e+03  -0.712  0.48395    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 74540 on 22 degrees of freedom
## Multiple R-squared:  0.9932, Adjusted R-squared:  0.9926 
## F-statistic:  1603 on 2 and 22 DF,  p-value: < 2.2e-16