library(rio)
data=import("dataPeru.xlsx")
data$porcentajecS = (data$contribuyentesSunat/sum(data$contribuyentesSunat))*100
data$porcentajepeaOcup = (data$peaOcupada/sum(data$peaOcupada))*100
modelo1 = lm(buenEstado ~ porcentajecS + porcentajepeaOcup, data = data)
summary(modelo1)
## 
## Call:
## lm(formula = buenEstado ~ porcentajecS + porcentajepeaOcup, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.589  -3.966  -1.347   1.907  21.518 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         18.646      2.694   6.922 5.98e-07 ***
## porcentajecS         1.955      2.255   0.867    0.395    
## porcentajepeaOcup   -1.963      2.758  -0.712    0.484    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.925 on 22 degrees of freedom
## Multiple R-squared:  0.1561, Adjusted R-squared:  0.07939 
## F-statistic: 2.035 on 2 and 22 DF,  p-value: 0.1546
modelo1_st = lm(scale(buenEstado) ~ scale(porcentajecS) + scale(porcentajepeaOcup), data = data)
summary(modelo1_st)
## 
## Call:
## lm(formula = scale(buenEstado) ~ scale(porcentajecS) + scale(porcentajepeaOcup), 
##     data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.2821 -0.4802 -0.1631  0.2309  2.6052 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)
## (Intercept)               3.023e-16  1.919e-01   0.000    1.000
## scale(porcentajecS)       2.034e+00  2.346e+00   0.867    0.395
## scale(porcentajepeaOcup) -1.670e+00  2.346e+00  -0.712    0.484
## 
## Residual standard error: 0.9595 on 22 degrees of freedom
## Multiple R-squared:  0.1561, Adjusted R-squared:  0.07939 
## F-statistic: 2.035 on 2 and 22 DF,  p-value: 0.1546

#PREGUNTA 2

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