## corrplot 0.95 loaded
La matriz de correlación indica que el ingreso per cápita presenta una fuerte correlación positiva con el nivel educativo y el acceso a internet, mientras que exhibe una fuerte correlación negativa con la pobreza.
##
## Call:
## lm(formula = saturado, data = datos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4585.2 -1168.6 -125.4 1208.2 5224.9
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3757.23 3338.95 1.125 0.264211
## bach_pct 264.14 68.73 3.843 0.000259 ***
## desem_pct 20.05 74.85 0.268 0.789533
## banda_pct 125.32 45.30 2.766 0.007198 **
## pobreza_pct -210.64 47.68 -4.417 3.45e-05 ***
## tam_hogar 816.67 622.90 1.311 0.193997
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1982 on 72 degrees of freedom
## Multiple R-squared: 0.8457, Adjusted R-squared: 0.835
## F-statistic: 78.93 on 5 and 72 DF, p-value: < 2.2e-16
s$adjr2
## [1] 0.7813345 0.8218674 0.8356189 0.8370999 0.8350019
s$bic
## [1] -110.8827 -123.5503 -126.5072 -123.9177 -119.6387
El modelo con 4 variables alcanzó el número más alto en el criterio R²-ajustado, explicando aproximadamente el 83.7% de la variabilidad del ingreso per cápita. No obstante, si queremos un balance entre simplicidad y ajustes, el modelo de 3 variables resulta más adecuado ya que obtuvo un valor de -126.51, siendo el menor del criterio BIC.
Forward
# Hacia adelante
m1_step <- step(m0, scope = list(lower = formula(m0), upper = formula(mF)),direction = "forward",k = log(nrow(datos)),trace = TRUE)
## Start: AIC=1328.25
## ing_pc ~ 1
##
## Df Sum of Sq RSS AIC
## + bach_pct 1 1438089133 395800604 1213.0
## + pobreza_pct 1 1331610382 502279355 1231.6
## + banda_pct 1 1121735582 712154155 1258.8
## <none> 1833889736 1328.2
## + desem_pct 1 8354792 1825534944 1332.2
## + tam_hogar 1 5821235 1828068502 1332.4
##
## Step: AIC=1213.01
## ing_pc ~ bach_pct
##
## Df Sum of Sq RSS AIC
## + pobreza_pct 1 77610119 318190485 1200.3
## + banda_pct 1 29535087 366265517 1211.3
## <none> 395800604 1213.0
## + tam_hogar 1 4923053 390877551 1216.4
## + desem_pct 1 2817657 392982947 1216.8
##
## Step: AIC=1200.34
## ing_pc ~ bach_pct + pobreza_pct
##
## Df Sum of Sq RSS AIC
## + banda_pct 1 28478762 289711723 1197.4
## <none> 318190485 1200.3
## + tam_hogar 1 4915101 313275383 1203.5
## + desem_pct 1 672748 317517737 1204.5
##
## Step: AIC=1197.39
## ing_pc ~ bach_pct + pobreza_pct + banda_pct
##
## Df Sum of Sq RSS AIC
## <none> 289711723 1197.4
## + tam_hogar 1 6489907 283221816 1200.0
## + desem_pct 1 17073 289694650 1201.7
Backward
# Hacia atras
m2_step <- step(mF,direction = "backward",k = log(nrow(datos)),trace = TRUE)
## Start: AIC=1204.26
## ing_pc ~ bach_pct + desem_pct + banda_pct + pobreza_pct + tam_hogar
##
## Df Sum of Sq RSS AIC
## - desem_pct 1 282063 283221816 1200.0
## - tam_hogar 1 6754897 289694650 1201.7
## <none> 282939753 1204.3
## - banda_pct 1 30072895 313012647 1207.8
## - bach_pct 1 58048450 340988202 1214.5
## - pobreza_pct 1 76685336 359625088 1218.6
##
## Step: AIC=1199.98
## ing_pc ~ bach_pct + banda_pct + pobreza_pct + tam_hogar
##
## Df Sum of Sq RSS AIC
## - tam_hogar 1 6489907 289711723 1197.4
## <none> 283221816 1200.0
## - banda_pct 1 30053567 313275383 1203.5
## - bach_pct 1 61021640 344243456 1210.8
## - pobreza_pct 1 76514196 359736013 1214.3
##
## Step: AIC=1197.39
## ing_pc ~ bach_pct + banda_pct + pobreza_pct
##
## Df Sum of Sq RSS AIC
## <none> 289711723 1197.4
## - banda_pct 1 28478762 318190485 1200.3
## - bach_pct 1 62624091 352335814 1208.3
## - pobreza_pct 1 76553794 366265517 1211.3
Both
# híbrido
m3_step <- step(m0,scope = list(lower = formula(m0), upper = formula(mF)),direction = "both",k = log(nrow(datos)),trace = TRUE)
## Start: AIC=1328.25
## ing_pc ~ 1
##
## Df Sum of Sq RSS AIC
## + bach_pct 1 1438089133 395800604 1213.0
## + pobreza_pct 1 1331610382 502279355 1231.6
## + banda_pct 1 1121735582 712154155 1258.8
## <none> 1833889736 1328.2
## + desem_pct 1 8354792 1825534944 1332.2
## + tam_hogar 1 5821235 1828068502 1332.4
##
## Step: AIC=1213.01
## ing_pc ~ bach_pct
##
## Df Sum of Sq RSS AIC
## + pobreza_pct 1 77610119 318190485 1200.3
## + banda_pct 1 29535087 366265517 1211.3
## <none> 395800604 1213.0
## + tam_hogar 1 4923053 390877551 1216.4
## + desem_pct 1 2817657 392982947 1216.8
## - bach_pct 1 1438089133 1833889736 1328.2
##
## Step: AIC=1200.34
## ing_pc ~ bach_pct + pobreza_pct
##
## Df Sum of Sq RSS AIC
## + banda_pct 1 28478762 289711723 1197.4
## <none> 318190485 1200.3
## + tam_hogar 1 4915101 313275383 1203.5
## + desem_pct 1 672748 317517737 1204.5
## - pobreza_pct 1 77610119 395800604 1213.0
## - bach_pct 1 184088870 502279355 1231.6
##
## Step: AIC=1197.39
## ing_pc ~ bach_pct + pobreza_pct + banda_pct
##
## Df Sum of Sq RSS AIC
## <none> 289711723 1197.4
## + tam_hogar 1 6489907 283221816 1200.0
## - banda_pct 1 28478762 318190485 1200.3
## + desem_pct 1 17073 289694650 1201.7
## - bach_pct 1 62624091 352335814 1208.3
## - pobreza_pct 1 76553794 366265517 1211.3
Summarys
Forward
summary(m1_step)
##
## Call:
## lm(formula = ing_pc ~ bach_pct + pobreza_pct + banda_pct, data = datos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4644.3 -995.6 -35.5 1360.0 5031.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6481.30 2522.94 2.569 0.012215 *
## bach_pct 270.45 67.62 3.999 0.000149 ***
## pobreza_pct -209.43 47.36 -4.422 3.3e-05 ***
## banda_pct 119.54 44.32 2.697 0.008657 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1979 on 74 degrees of freedom
## Multiple R-squared: 0.842, Adjusted R-squared: 0.8356
## F-statistic: 131.5 on 3 and 74 DF, p-value: < 2.2e-16
Backward
summary(m2_step)
##
## Call:
## lm(formula = ing_pc ~ bach_pct + banda_pct + pobreza_pct, data = datos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4644.3 -995.6 -35.5 1360.0 5031.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6481.30 2522.94 2.569 0.012215 *
## bach_pct 270.45 67.62 3.999 0.000149 ***
## banda_pct 119.54 44.32 2.697 0.008657 **
## pobreza_pct -209.43 47.36 -4.422 3.3e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1979 on 74 degrees of freedom
## Multiple R-squared: 0.842, Adjusted R-squared: 0.8356
## F-statistic: 131.5 on 3 and 74 DF, p-value: < 2.2e-16
Both
summary(m3_step)
##
## Call:
## lm(formula = ing_pc ~ bach_pct + pobreza_pct + banda_pct, data = datos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4644.3 -995.6 -35.5 1360.0 5031.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6481.30 2522.94 2.569 0.012215 *
## bach_pct 270.45 67.62 3.999 0.000149 ***
## pobreza_pct -209.43 47.36 -4.422 3.3e-05 ***
## banda_pct 119.54 44.32 2.697 0.008657 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1979 on 74 degrees of freedom
## Multiple R-squared: 0.842, Adjusted R-squared: 0.8356
## F-statistic: 131.5 on 3 and 74 DF, p-value: < 2.2e-16
Modelos finales ajustados
BIC
# Mejor modelo según BIC
coef_best <- coef(ajuste, best_bic)
vars_best <- names(coef_best)[-1]
f_final <- as.formula(paste("ing_pc ~", paste(vars_best, collapse = " + ")))
modelo_final_bic <- lm(f_final, data = datos)
summary(modelo_final_bic)
##
## Call:
## lm(formula = f_final, data = datos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4644.3 -995.6 -35.5 1360.0 5031.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6481.30 2522.94 2.569 0.012215 *
## bach_pct 270.45 67.62 3.999 0.000149 ***
## banda_pct 119.54 44.32 2.697 0.008657 **
## pobreza_pct -209.43 47.36 -4.422 3.3e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1979 on 74 degrees of freedom
## Multiple R-squared: 0.842, Adjusted R-squared: 0.8356
## F-statistic: 131.5 on 3 and 74 DF, p-value: < 2.2e-16
R²-ajustado
# Mejor modelo según R²-ajustado
coef_best <- coef(ajuste, best_r2)
vars_best <- names(coef_best)[-1]
f_final <- as.formula(paste("ing_pc ~", paste(vars_best, collapse = " + ")))
modelo_final_r2 <- lm(f_final, data = datos)
summary(modelo_final_r2)
##
## Call:
## lm(formula = f_final, data = datos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4630.0 -1129.5 -83.4 1182.5 5207.2
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4047.29 3138.40 1.290 0.201259
## bach_pct 267.16 67.36 3.966 0.000169 ***
## banda_pct 123.03 44.21 2.783 0.006848 **
## pobreza_pct -209.38 47.15 -4.441 3.12e-05 ***
## tam_hogar 790.86 611.48 1.293 0.199967
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1970 on 73 degrees of freedom
## Multiple R-squared: 0.8456, Adjusted R-squared: 0.8371
## F-statistic: 99.92 on 4 and 73 DF, p-value: < 2.2e-16
Los modelos paso a paso (forward, backward, both) usando BIC nos dieron lo mismo por lo cual decidimos comparar los mejores modelos de BIC y R²-ajustado.
El mejor modelo para usar, es el modelo según el criterio BIC. Este modelos selecciona 3 variables (bach_pct, pobreza_pct y banda_pct), en comparación del modelo según R²-ajustado que nos presenta cuatro variables, lo que lo hace más complejo. Ambos modelos presentan valores similares de R²-ajustado, por lo que no lo tomamos en consideración al momento de elegir el modelo.
Intercepto Cuando las variables bach_pct, pobreza_pct y banda_pct son 0, el ingreso per cápita es $648.30.
bach_pct Por cada punto porcentual que aumente en bachillerato, el incremento en ingreso per cápita será de $270.45.
banda_pct Por cada 1% mas de hogares con internet de banda ancha, el ingreso per cápita sube $120.
pobreza_pct Por cada 1% de aumento en pobreza, el ingreso per cápita disminuye $209.
El análisis nos permitió explorar la relación de la educación, desempleo, acceso a internet, pobreza y tamaño del hogar, pueden influir en el ingreso per cápita de cada municipio. Se trabajó con el modelo por subconjuntos y modelos paso a paso usando BIC, con el fin de identificar el modelo más adecuado para nuestra investigación. Los resultados mostraron que el modelo BIC cumple con nuestros requisitos de simplicidad, un R²-ajustado elevado. Las variables de educación, la pobreza y los hogares con internet, son las que mejor explica la variabilidad del ingreso per cápita.