Carga de librerias

library(magrittr)
library(dplyr)
library(readxl)

Importar datos

USEDAT <- read_excel("C:/Users/Mayller Perez/Desktop/UNF6/UNF 8/DESARROLLO/USEDAT.xlsx")
USEDAT

Transformación de la data

Tasa del crecimiento del PBI

USEDAT <- USEDAT %>% group_by(region) %>%  mutate(ttpbi= log(pbi)-log(lag(pbi)))
USEDAT <- USEDAT %>%  transform(region= as.factor(region))

Normalización de indicadores

Capital Humano

Promedio de escolaridad

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(nprom_esco = (prom_esco - min(prom_esco)) / (max(prom_esco) - min(prom_esco)))

Tasa de analfabetismo

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(ntasa_analf = (max(tasa_analf)-tasa_analf) / (max(tasa_analf) - min(tasa_analf)))

Gasto público por alumno en educación superior

USEDAT <- USEDAT %>% 
  group_by(region) %>% 
  mutate(ngasto_alum = ((gasto_alum-min(gasto_alum))/(max(gasto_alum)-min(gasto_alum))))

Niños del cuarto grado con nivel satisfactorio en lectura

USEDAT <- USEDAT %>% 
  group_by(region) %>% 
  mutate(nsati_lec= ((sati_lec-min(sati_lec))/(max(sati_lec)-min(sati_lec))))

Niños del cuarto grado con nivel satisfactorio en razonamiento

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(nsati_mat = (sati_mat - min(sati_mat)) / (max(sati_mat) - min(sati_mat)))

Seguridad y orden público

Tasa de homicidios

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(ntas_hom = (max(tas_hom) - tas_hom) / (max(tas_hom) - min(tas_hom)))

Tasa de faltas

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(ntasa_faltas = (max(tasa_faltas) - tasa_faltas) / (max(tasa_faltas) - min(tasa_faltas)))

Tasa de delitos

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(ntasa_delit = (max(tasa_delit) - tasa_delit) / (max(tasa_delit) - min(tasa_delit)))

Población victima de algun evento contra tu salud

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(npob_vic = (max(pob_vic) - pob_vic) / (max(pob_vic) - min(pob_vic)))

Cohesión social

Opinión favorable de la población sobre la gestión del gobierno central

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(nges_cen = (ges_cen - min(ges_cen)) / (max(ges_cen) - min(ges_cen)))

Opinión favorable de la población sobre la gestión del gobierno regional

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(nges_reg = (ges_reg - min(ges_reg)) / (max(ges_reg) - min(ges_reg)))

Opinión favorable de la población sobre la gestión del gobierno local

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(nges_loc = (ges_loc - min(ges_loc)) / (max(ges_loc) - min(ges_loc)))

Conflictos sociales

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(nconfli = (max(confli) - confli) / (max(confli) - min(confli)))

Equidad e inclusión social

Niveles de pobreza monetaria

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(npob_monet = (max(pob_monet) - pob_monet) / (max(pob_monet) - min(pob_monet)))

Población con al menos una necesidad insatisfecha

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(npob_nec = (max(pob_nec) - pob_nec) / (max(pob_nec) - min(pob_nec)))

Tasa de empleo informal

USEDAT <- USEDAT %>%
  group_by(region) %>%
  mutate(ntasa_inf = (max(tasa_inf) - tasa_inf) / (max(tasa_inf) - min(tasa_inf)))

Creación de indicadores

Indicador capital humano

USEDAT <- USEDAT  %>% 
  group_by(region) %>% 
  mutate(ind_cap = ((0.2*nprom_esco)+(0.2*ntasa_analf)+(0.2*ngasto_alum)+(0.2*nsati_lec)+(0.2*nsati_mat)))

Seguridad y orden público

USEDAT <- USEDAT %>% 
  group_by(region) %>% 
  mutate(ind_segu = ((0.25*ntas_hom) + (0.25*ntasa_faltas) + (0.25*ntasa_delit) + (0.25*npob_vic)))

Cohesión social

USEDAT <- USEDAT %>% 
  group_by(region) %>% 
  mutate(ind_cohes = ((0.25*nges_cen) + (0.25*nges_reg) + (0.25*nges_loc) + (0.25*nconfli)))

Equidad e inclusión social

USEDAT <- USEDAT %>% 
  group_by(region) %>% 
  mutate(ind_equi = (((1/3)*npob_monet) + ((1/3)*npob_nec) + ((1/3)*ntasa_inf)))

Indicador de bienestar social

USEDAT <- USEDAT %>% 
  group_by(region) %>% 
  mutate(ind = ((0.25*ind_cap) + (0.25*ind_segu) + (0.25*ind_cohes) + (0.25*ind_equi)))

Datasat Normalizado

NUSEDAT <- USEDAT[,c(1,2, 22:42,19,21,20)]

Hechos Estilizados

Correlación

library(DataExplorer)
## Warning: package 'DataExplorer' was built under R version 4.4.1
plot_correlation(NUSEDAT[,c(19:23,24)])

Evolución del PBI

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
ggplot(NUSEDAT, aes(x= year, y= ttpbi))+
  geom_line()+
  facet_wrap(~region)+
  labs(title = "Evolución del PBI", x= "Año")+
  scale_x_continuous(breaks = seq(200,2025, by=6))+
  theme(axis.text.x = element_text(size = 5))
## Warning: Removed 26 rows containing missing values or values outside the scale range
## (`geom_line()`).

Región con el pbi más alto

NUSEDAT %>% 
  group_by(region) %>% 
  summarise(top_pbi= mean(ttpbi*100, na.rm= TRUE)) %>% 
  slice_max(top_pbi, n= 5)

Región con el pbi más bajo

NUSEDAT %>% 
  group_by(region) %>% 
  summarise(top_pbi= mean(ttpbi*100, na.rm= TRUE)) %>% 
  slice_min(top_pbi, n=5)

Evolución del indicador de bienestar

library(ggplot2)
ggplot(NUSEDAT, aes(x=year, y= ind*100))+
  geom_line()+
  facet_wrap(~region)+
  labs(title = "Evolución del Índice de Bienestar Social", x= "Año", y="Índice de Bienestar Social")+
  scale_x_continuous(breaks = seq(2000,2024,6))+
  theme(axis.text.x = element_text(size = 7))

Región con el índice de bienestar más alto

NUSEDAT %>% 
  group_by(region) %>% 
  summarise(top_ind= mean(ind)*100) %>% 
  slice_max(top_ind, n= 5)

Región con el índice de bienestar más bajo

NUSEDAT %>% 
  group_by(region) %>% 
  summarise(top_ind= mean(ind)*100) %>% 
  slice_min(top_ind, n=5)

Evolución del capital humano

library(ggplot2)

ggplot(NUSEDAT, aes(x = year, y = ind_cap*100)) +
  geom_line(show.legend = FALSE) +
  facet_wrap(~region) +
  labs(title = "Evolución del pilar capital humano",
       x = "Año",
       y = "Pilar: Capital Humano")+
  theme(axis.text.x = element_text(size= 7))+
  scale_x_continuous(breaks = seq(2000,2024,6))

Regiones con el indicador de capital humano más alto

NUSEDAT %>% 
  group_by(region) %>%
  summarise(top_ind_cap = mean(ind_cap)*100) %>% 
  slice_max(top_ind_cap,n=5)

Regiones con el indicador de capital humano más bajo

NUSEDAT %>% 
  group_by(region) %>%
  summarise(top_ind_cap = mean(ind_cap)*100) %>% 
  top_n(-5,top_ind_cap)

Evolución de la seguridad y orden interno

library(ggplot2)
ggplot(NUSEDAT, aes(x = year, y = ind_segu*100)) +
  geom_line(show.legend = FALSE) +
  facet_wrap(~region) +
  labs(title = "Evolución del pilar seguridad y orden interno por regiones",
       x = "Año",
       y = "Pilar: Seguridad y orden interno")+
  theme(axis.text.x = element_text(size = 7))+
  scale_x_continuous(breaks = seq(2000,2024, 6))

Regiones con el indicador seguridad y orden interno más alto

NUSEDAT %>% 
  group_by(region) %>%
  summarise(top_ind_segu = mean(ind_segu)*100) %>% 
  slice_max(top_ind_segu, n=5)

Regiones con el indicador seguridad y orden interno más bajo

NUSEDAT %>% 
  group_by(region) %>%
  summarise(top_ind_segu = mean(ind_segu)*100) %>% 
  slice_min(top_ind_segu, n= 5)

Evolución de la cohesión social

ggplot(NUSEDAT, aes(x=year, y=ind_cohes*100))+
  geom_line()+
  facet_wrap(~region)+
  labs(title = "Evolución del pilar cohesión social",
       x = "Año",
       y = "Pilar: COhesión social")+
  scale_x_continuous(breaks = seq(2000, 2025, by = 6))+
   theme(axis.text.x = element_text(size = 7))

Regiones con el indicador cohesión social más alto

NUSEDAT %>% 
  group_by(region) %>%
  summarise(top_ind_cohes = mean(ind_cohes)*100) %>% 
  slice_max(top_ind_cohes, n=5)

Regiones con el indicador cohesión social más bajo

NUSEDAT %>% 
  group_by(region) %>%
  summarise(top_ind_cohes = mean(ind_cohes)*100) %>% 
  slice_min(top_ind_cohes, n=5)

Evolución de la equidad e inclusión social

library(ggplot2)

ggplot(NUSEDAT, aes(x = year, y = ind_equi)) +
  geom_line(show.legend = FALSE) +
  facet_wrap(~region) +
  labs(title = "Evolución del pilar equidad e inclusión social",
       x = "Año",
       y = "Pilar: Equidad e Inclusión Social")+
   scale_x_continuous(breaks = seq(2000, 2025, by = 6))+
  theme(axis.text.x = element_text(size = 7))

Regiones con el indicador equidad e inclusión social más alto

NUSEDAT %>% 
  group_by(region) %>%
  summarise(top_ind_equi = mean(ind_equi)*100) %>% 
  slice_max(top_ind_equi, n=5)

Regiones con el indicador equidad e inclusión social más bajo

NUSEDAT %>% 
  group_by(region) %>%
  summarise(top_ind_equi = mean(ind_equi*100)) %>% 
  slice_min(top_ind_equi, n=5)

Modelos aplicados

MCO

MCO por pilares

attach(NUSEDAT)
summary(lm(log(pbi)~ ind_cap+ind_cohes+ind_equi+ind_segu+log(exp)))
## 
## Call:
## lm(formula = log(pbi) ~ ind_cap + ind_cohes + ind_equi + ind_segu + 
##     log(exp))
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.43413 -0.57472 -0.08912  0.30336  2.38375 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 12.37699    0.29466  42.004  < 2e-16 ***
## ind_cap      0.59650    0.28243   2.112   0.0351 *  
## ind_cohes    0.86085    0.20028   4.298 1.99e-05 ***
## ind_equi     0.18918    0.22769   0.831   0.4064    
## ind_segu    -0.50739    0.26594  -1.908   0.0568 .  
## log(exp)     0.51278    0.01623  31.604  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7744 on 644 degrees of freedom
## Multiple R-squared:  0.6345, Adjusted R-squared:  0.6316 
## F-statistic: 223.6 on 5 and 644 DF,  p-value: < 2.2e-16

MCO indicador de bienestar

summary(lm(log(pbi)~ind+log(exp)))
## 
## Call:
## lm(formula = log(pbi) ~ ind + log(exp))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4228 -0.6060 -0.1288  0.3049  2.2468 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 12.70325    0.21580  58.866   <2e-16 ***
## ind          0.53438    0.37445   1.427    0.154    
## log(exp)     0.50839    0.01578  32.216   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7854 on 647 degrees of freedom
## Multiple R-squared:  0.6223, Adjusted R-squared:  0.6211 
## F-statistic: 532.9 on 2 and 647 DF,  p-value: < 2.2e-16

Modelos por región

summary(lm(log(pbi) ~ factor(region) - 1 +
         ind_cap:factor(region) +
         ind_cohes:factor(region) +
         ind_equi:factor(region) +
         ind_segu:factor(region)))
## 
## Call:
## lm(formula = log(pbi) ~ factor(region) - 1 + ind_cap:factor(region) + 
##     ind_cohes:factor(region) + ind_equi:factor(region) + ind_segu:factor(region))
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.34619 -0.03562  0.00156  0.04074  0.49037 
## 
## Coefficients:
##                                                              Estimate
## factor(region)AMAZONAS                                      14.630972
## factor(region)ÁNCASH                                        16.600212
## factor(region)APURÍMAC                                      15.620570
## factor(region)AREQUIPA                                      17.228590
## factor(region)AYACUCHO                                      15.010954
## factor(region)CAJAMARCA                                     16.229774
## factor(region)CUSCO                                         16.679751
## factor(region)DEPARTAMENTO DE LIMA                          19.052860
## factor(region)HUANCAVELICA                                  14.849407
## factor(region)HUÁNUCO                                       15.281171
## factor(region)ICA                                           16.277784
## factor(region)JUNÍN                                         16.507160
## factor(region)LA LIBERTAD                                   16.686649
## factor(region)LAMBAYEQUE                                    15.837637
## factor(region)LIMA METROPOLITANA                            19.467457
## factor(region)LORETO                                        15.919320
## factor(region)MADRE DE DIOS                                 14.669522
## factor(region)MOQUEGUA                                      16.474968
## factor(region)PASCO                                         15.656589
## factor(region)PIURA                                         16.575681
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO           19.039949
## factor(region)PUNO                                          15.476162
## factor(region)SAN MARTÍN                                    15.107483
## factor(region)TACNA                                         15.615758
## factor(region)TUMBES                                        14.513360
## factor(region)UCAYALI                                       15.243743
## factor(region)AMAZONAS:ind_cap                               0.226886
## factor(region)ÁNCASH:ind_cap                                 0.162629
## factor(region)APURÍMAC:ind_cap                               1.179340
## factor(region)AREQUIPA:ind_cap                               0.721166
## factor(region)AYACUCHO:ind_cap                               0.427719
## factor(region)CAJAMARCA:ind_cap                              0.028653
## factor(region)CUSCO:ind_cap                                  0.102050
## factor(region)DEPARTAMENTO DE LIMA:ind_cap                   0.336205
## factor(region)HUANCAVELICA:ind_cap                           0.124261
## factor(region)HUÁNUCO:ind_cap                                0.491713
## factor(region)ICA:ind_cap                                   -0.168961
## factor(region)JUNÍN:ind_cap                                  0.350375
## factor(region)LA LIBERTAD:ind_cap                            0.339852
## factor(region)LAMBAYEQUE:ind_cap                             0.290472
## factor(region)LIMA METROPOLITANA:ind_cap                     0.233402
## factor(region)LORETO:ind_cap                                 0.044097
## factor(region)MADRE DE DIOS:ind_cap                          0.128339
## factor(region)MOQUEGUA:ind_cap                              -0.214318
## factor(region)PASCO:ind_cap                                 -0.054820
## factor(region)PIURA:ind_cap                                  0.324037
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_cap    0.137997
## factor(region)PUNO:ind_cap                                   0.417695
## factor(region)SAN MARTÍN:ind_cap                             0.340726
## factor(region)TACNA:ind_cap                                  0.444547
## factor(region)TUMBES:ind_cap                                 0.109406
## factor(region)UCAYALI:ind_cap                                0.051134
## factor(region)AMAZONAS:ind_cohes                            -0.046595
## factor(region)ÁNCASH:ind_cohes                              -0.158393
## factor(region)APURÍMAC:ind_cohes                            -1.497574
## factor(region)AREQUIPA:ind_cohes                            -0.343700
## factor(region)AYACUCHO:ind_cohes                            -0.076850
## factor(region)CAJAMARCA:ind_cohes                           -0.036561
## factor(region)CUSCO:ind_cohes                               -0.329036
## factor(region)DEPARTAMENTO DE LIMA:ind_cohes                -0.378850
## factor(region)HUANCAVELICA:ind_cohes                        -0.128635
## factor(region)HUÁNUCO:ind_cohes                             -0.425081
## factor(region)ICA:ind_cohes                                 -0.362256
## factor(region)JUNÍN:ind_cohes                               -0.594967
## factor(region)LA LIBERTAD:ind_cohes                         -0.332729
## factor(region)LAMBAYEQUE:ind_cohes                          -0.211109
## factor(region)LIMA METROPOLITANA:ind_cohes                  -0.628172
## factor(region)LORETO:ind_cohes                              -0.130967
## factor(region)MADRE DE DIOS:ind_cohes                        0.150649
## factor(region)MOQUEGUA:ind_cohes                            -0.568640
## factor(region)PASCO:ind_cohes                               -0.179483
## factor(region)PIURA:ind_cohes                               -0.335490
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_cohes -0.517090
## factor(region)PUNO:ind_cohes                                -0.117092
## factor(region)SAN MARTÍN:ind_cohes                          -0.338293
## factor(region)TACNA:ind_cohes                               -0.524305
## factor(region)TUMBES:ind_cohes                              -0.446772
## factor(region)UCAYALI:ind_cohes                             -0.338312
## factor(region)AMAZONAS:ind_equi                              0.298017
## factor(region)ÁNCASH:ind_equi                                0.003440
## factor(region)APURÍMAC:ind_equi                             -0.240390
## factor(region)AREQUIPA:ind_equi                             -0.208910
## factor(region)AYACUCHO:ind_equi                              0.301331
## factor(region)CAJAMARCA:ind_equi                             0.280283
## factor(region)CUSCO:ind_equi                                 0.362111
## factor(region)DEPARTAMENTO DE LIMA:ind_equi                  0.087758
## factor(region)HUANCAVELICA:ind_equi                          0.212029
## factor(region)HUÁNUCO:ind_equi                               0.038992
## factor(region)ICA:ind_equi                                   0.581354
## factor(region)JUNÍN:ind_equi                                -0.031039
## factor(region)LA LIBERTAD:ind_equi                          -0.040298
## factor(region)LAMBAYEQUE:ind_equi                            0.326816
## factor(region)LIMA METROPOLITANA:ind_equi                   -0.067625
## factor(region)LORETO:ind_equi                                0.179147
## factor(region)MADRE DE DIOS:ind_equi                         0.025251
## factor(region)MOQUEGUA:ind_equi                             -0.094457
## factor(region)PASCO:ind_equi                                -0.083218
## factor(region)PIURA:ind_equi                                 0.142815
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_equi   0.221143
## factor(region)PUNO:ind_equi                                  0.238859
## factor(region)SAN MARTÍN:ind_equi                            0.349852
## factor(region)TACNA:ind_equi                                -0.173524
## factor(region)TUMBES:ind_equi                                0.254627
## factor(region)UCAYALI:ind_equi                               0.255417
## factor(region)AMAZONAS:ind_segu                             -0.162924
## factor(region)ÁNCASH:ind_segu                                0.208050
## factor(region)APURÍMAC:ind_segu                             -0.646374
## factor(region)AREQUIPA:ind_segu                             -0.595277
## factor(region)AYACUCHO:ind_segu                             -0.018525
## factor(region)CAJAMARCA:ind_segu                            -0.329643
## factor(region)CUSCO:ind_segu                                -0.237485
## factor(region)DEPARTAMENTO DE LIMA:ind_segu                  0.007652
## factor(region)HUANCAVELICA:ind_segu                         -0.033904
## factor(region)HUÁNUCO:ind_segu                               0.051001
## factor(region)ICA:ind_segu                                   0.244246
## factor(region)JUNÍN:ind_segu                                -0.121003
## factor(region)LA LIBERTAD:ind_segu                           0.153472
## factor(region)LAMBAYEQUE:ind_segu                            0.081339
## factor(region)LIMA METROPOLITANA:ind_segu                   -0.231728
## factor(region)LORETO:ind_segu                               -0.064995
## factor(region)MADRE DE DIOS:ind_segu                        -0.510854
## factor(region)MOQUEGUA:ind_segu                              0.021805
## factor(region)PASCO:ind_segu                                -0.066764
## factor(region)PIURA:ind_segu                                -0.025181
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_segu   0.226241
## factor(region)PUNO:ind_segu                                  0.194283
## factor(region)SAN MARTÍN:ind_segu                            0.116771
## factor(region)TACNA:ind_segu                                 0.373958
## factor(region)TUMBES:ind_segu                                0.261598
## factor(region)UCAYALI:ind_segu                              -0.054820
##                                                             Std. Error t value
## factor(region)AMAZONAS                                        0.151755  96.412
## factor(region)ÁNCASH                                          0.194560  85.322
## factor(region)APURÍMAC                                        0.196625  79.443
## factor(region)AREQUIPA                                        0.177159  97.249
## factor(region)AYACUCHO                                        0.184314  81.442
## factor(region)CAJAMARCA                                       0.175681  92.382
## factor(region)CUSCO                                           0.159976 104.264
## factor(region)DEPARTAMENTO DE LIMA                            0.204469  93.182
## factor(region)HUANCAVELICA                                    0.218864  67.848
## factor(region)HUÁNUCO                                         0.215478  70.918
## factor(region)ICA                                             0.238139  68.354
## factor(region)JUNÍN                                           0.157439 104.848
## factor(region)LA LIBERTAD                                     0.179491  92.966
## factor(region)LAMBAYEQUE                                      0.203060  77.995
## factor(region)LIMA METROPOLITANA                              0.257546  75.588
## factor(region)LORETO                                          0.122491 129.963
## factor(region)MADRE DE DIOS                                   0.154565  94.909
## factor(region)MOQUEGUA                                        0.205906  80.012
## factor(region)PASCO                                           0.192539  81.316
## factor(region)PIURA                                           0.155260 106.761
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO             0.261778  72.733
## factor(region)PUNO                                            0.247264  62.590
## factor(region)SAN MARTÍN                                      0.144360 104.651
## factor(region)TACNA                                           0.243387  64.160
## factor(region)TUMBES                                          0.171103  84.822
## factor(region)UCAYALI                                         0.209081  72.908
## factor(region)AMAZONAS:ind_cap                                0.162728   1.394
## factor(region)ÁNCASH:ind_cap                                  0.194573   0.836
## factor(region)APURÍMAC:ind_cap                                0.184883   6.379
## factor(region)AREQUIPA:ind_cap                                0.212285   3.397
## factor(region)AYACUCHO:ind_cap                                0.174159   2.456
## factor(region)CAJAMARCA:ind_cap                               0.233643   0.123
## factor(region)CUSCO:ind_cap                                   0.211494   0.483
## factor(region)DEPARTAMENTO DE LIMA:ind_cap                    0.141410   2.378
## factor(region)HUANCAVELICA:ind_cap                            0.148199   0.838
## factor(region)HUÁNUCO:ind_cap                                 0.194544   2.528
## factor(region)ICA:ind_cap                                     0.220919  -0.765
## factor(region)JUNÍN:ind_cap                                   0.171168   2.047
## factor(region)LA LIBERTAD:ind_cap                             0.205184   1.656
## factor(region)LAMBAYEQUE:ind_cap                              0.166088   1.749
## factor(region)LIMA METROPOLITANA:ind_cap                      0.236379   0.987
## factor(region)LORETO:ind_cap                                  0.167825   0.263
## factor(region)MADRE DE DIOS:ind_cap                           0.205224   0.625
## factor(region)MOQUEGUA:ind_cap                                0.165124  -1.298
## factor(region)PASCO:ind_cap                                   0.194072  -0.282
## factor(region)PIURA:ind_cap                                   0.175015   1.851
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_cap     0.196233   0.703
## factor(region)PUNO:ind_cap                                    0.181949   2.296
## factor(region)SAN MARTÍN:ind_cap                              0.161239   2.113
## factor(region)TACNA:ind_cap                                   0.187803   2.367
## factor(region)TUMBES:ind_cap                                  0.173384   0.631
## factor(region)UCAYALI:ind_cap                                 0.223252   0.229
## factor(region)AMAZONAS:ind_cohes                              0.125044  -0.373
## factor(region)ÁNCASH:ind_cohes                                0.126865  -1.249
## factor(region)APURÍMAC:ind_cohes                              0.150044  -9.981
## factor(region)AREQUIPA:ind_cohes                              0.164386  -2.091
## factor(region)AYACUCHO:ind_cohes                              0.163374  -0.470
## factor(region)CAJAMARCA:ind_cohes                             0.134913  -0.271
## factor(region)CUSCO:ind_cohes                                 0.144454  -2.278
## factor(region)DEPARTAMENTO DE LIMA:ind_cohes                  0.142318  -2.662
## factor(region)HUANCAVELICA:ind_cohes                          0.149238  -0.862
## factor(region)HUÁNUCO:ind_cohes                               0.124118  -3.425
## factor(region)ICA:ind_cohes                                   0.174099  -2.081
## factor(region)JUNÍN:ind_cohes                                 0.121436  -4.899
## factor(region)LA LIBERTAD:ind_cohes                           0.150835  -2.206
## factor(region)LAMBAYEQUE:ind_cohes                            0.142564  -1.481
## factor(region)LIMA METROPOLITANA:ind_cohes                    0.159149  -3.947
## factor(region)LORETO:ind_cohes                                0.090003  -1.455
## factor(region)MADRE DE DIOS:ind_cohes                         0.101258   1.488
## factor(region)MOQUEGUA:ind_cohes                              0.133123  -4.272
## factor(region)PASCO:ind_cohes                                 0.145137  -1.237
## factor(region)PIURA:ind_cohes                                 0.130235  -2.576
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_cohes   0.169632  -3.048
## factor(region)PUNO:ind_cohes                                  0.159734  -0.733
## factor(region)SAN MARTÍN:ind_cohes                            0.099352  -3.405
## factor(region)TACNA:ind_cohes                                 0.140472  -3.732
## factor(region)TUMBES:ind_cohes                                0.133811  -3.339
## factor(region)UCAYALI:ind_cohes                               0.136136  -2.485
## factor(region)AMAZONAS:ind_equi                               0.152983   1.948
## factor(region)ÁNCASH:ind_equi                                 0.169814   0.020
## factor(region)APURÍMAC:ind_equi                               0.184782  -1.301
## factor(region)AREQUIPA:ind_equi                               0.139735  -1.495
## factor(region)AYACUCHO:ind_equi                               0.202482   1.488
## factor(region)CAJAMARCA:ind_equi                              0.186799   1.500
## factor(region)CUSCO:ind_equi                                  0.151516   2.390
## factor(region)DEPARTAMENTO DE LIMA:ind_equi                   0.120897   0.726
## factor(region)HUANCAVELICA:ind_equi                           0.136832   1.550
## factor(region)HUÁNUCO:ind_equi                                0.134174   0.291
## factor(region)ICA:ind_equi                                    0.168571   3.449
## factor(region)JUNÍN:ind_equi                                  0.145230  -0.214
## factor(region)LA LIBERTAD:ind_equi                            0.174688  -0.231
## factor(region)LAMBAYEQUE:ind_equi                             0.182093   1.795
## factor(region)LIMA METROPOLITANA:ind_equi                     0.124712  -0.542
## factor(region)LORETO:ind_equi                                 0.105543   1.697
## factor(region)MADRE DE DIOS:ind_equi                          0.125115   0.202
## factor(region)MOQUEGUA:ind_equi                               0.108163  -0.873
## factor(region)PASCO:ind_equi                                  0.149976  -0.555
## factor(region)PIURA:ind_equi                                  0.121675   1.174
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_equi    0.154364   1.433
## factor(region)PUNO:ind_equi                                   0.171461   1.393
## factor(region)SAN MARTÍN:ind_equi                             0.121151   2.888
## factor(region)TACNA:ind_equi                                  0.130419  -1.331
## factor(region)TUMBES:ind_equi                                 0.114084   2.232
## factor(region)UCAYALI:ind_equi                                0.141181   1.809
## factor(region)AMAZONAS:ind_segu                               0.196737  -0.828
## factor(region)ÁNCASH:ind_segu                                 0.177207   1.174
## factor(region)APURÍMAC:ind_segu                               0.198930  -3.249
## factor(region)AREQUIPA:ind_segu                               0.281393  -2.115
## factor(region)AYACUCHO:ind_segu                               0.184181  -0.101
## factor(region)CAJAMARCA:ind_segu                              0.234925  -1.403
## factor(region)CUSCO:ind_segu                                  0.133776  -1.775
## factor(region)DEPARTAMENTO DE LIMA:ind_segu                   0.181577   0.042
## factor(region)HUANCAVELICA:ind_segu                           0.175476  -0.193
## factor(region)HUÁNUCO:ind_segu                                0.184537   0.276
## factor(region)ICA:ind_segu                                    0.180829   1.351
## factor(region)JUNÍN:ind_segu                                  0.192603  -0.628
## factor(region)LA LIBERTAD:ind_segu                            0.148998   1.030
## factor(region)LAMBAYEQUE:ind_segu                             0.177608   0.458
## factor(region)LIMA METROPOLITANA:ind_segu                     0.214230  -1.082
## factor(region)LORETO:ind_segu                                 0.166191  -0.391
## factor(region)MADRE DE DIOS:ind_segu                          0.154074  -3.316
## factor(region)MOQUEGUA:ind_segu                               0.190019   0.115
## factor(region)PASCO:ind_segu                                  0.197454  -0.338
## factor(region)PIURA:ind_segu                                  0.177693  -0.142
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_segu    0.270190   0.837
## factor(region)PUNO:ind_segu                                   0.189978   1.023
## factor(region)SAN MARTÍN:ind_segu                             0.152958   0.763
## factor(region)TACNA:ind_segu                                  0.197652   1.892
## factor(region)TUMBES:ind_segu                                 0.151732   1.724
## factor(region)UCAYALI:ind_segu                                0.200975  -0.273
##                                                             Pr(>|t|)    
## factor(region)AMAZONAS                                       < 2e-16 ***
## factor(region)ÁNCASH                                         < 2e-16 ***
## factor(region)APURÍMAC                                       < 2e-16 ***
## factor(region)AREQUIPA                                       < 2e-16 ***
## factor(region)AYACUCHO                                       < 2e-16 ***
## factor(region)CAJAMARCA                                      < 2e-16 ***
## factor(region)CUSCO                                          < 2e-16 ***
## factor(region)DEPARTAMENTO DE LIMA                           < 2e-16 ***
## factor(region)HUANCAVELICA                                   < 2e-16 ***
## factor(region)HUÁNUCO                                        < 2e-16 ***
## factor(region)ICA                                            < 2e-16 ***
## factor(region)JUNÍN                                          < 2e-16 ***
## factor(region)LA LIBERTAD                                    < 2e-16 ***
## factor(region)LAMBAYEQUE                                     < 2e-16 ***
## factor(region)LIMA METROPOLITANA                             < 2e-16 ***
## factor(region)LORETO                                         < 2e-16 ***
## factor(region)MADRE DE DIOS                                  < 2e-16 ***
## factor(region)MOQUEGUA                                       < 2e-16 ***
## factor(region)PASCO                                          < 2e-16 ***
## factor(region)PIURA                                          < 2e-16 ***
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO            < 2e-16 ***
## factor(region)PUNO                                           < 2e-16 ***
## factor(region)SAN MARTÍN                                     < 2e-16 ***
## factor(region)TACNA                                          < 2e-16 ***
## factor(region)TUMBES                                         < 2e-16 ***
## factor(region)UCAYALI                                        < 2e-16 ***
## factor(region)AMAZONAS:ind_cap                              0.163834    
## factor(region)ÁNCASH:ind_cap                                0.403637    
## factor(region)APURÍMAC:ind_cap                              3.95e-10 ***
## factor(region)AREQUIPA:ind_cap                              0.000733 ***
## factor(region)AYACUCHO:ind_cap                              0.014379 *  
## factor(region)CAJAMARCA:ind_cap                             0.902441    
## factor(region)CUSCO:ind_cap                                 0.629641    
## factor(region)DEPARTAMENTO DE LIMA:ind_cap                  0.017790 *  
## factor(region)HUANCAVELICA:ind_cap                          0.402149    
## factor(region)HUÁNUCO:ind_cap                               0.011782 *  
## factor(region)ICA:ind_cap                                   0.444732    
## factor(region)JUNÍN:ind_cap                                 0.041163 *  
## factor(region)LA LIBERTAD:ind_cap                           0.098258 .  
## factor(region)LAMBAYEQUE:ind_cap                            0.080897 .  
## factor(region)LIMA METROPOLITANA:ind_cap                    0.323905    
## factor(region)LORETO:ind_cap                                0.792843    
## factor(region)MADRE DE DIOS:ind_cap                         0.532007    
## factor(region)MOQUEGUA:ind_cap                              0.194888    
## factor(region)PASCO:ind_cap                                 0.777693    
## factor(region)PIURA:ind_cap                                 0.064667 .  
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_cap   0.482227    
## factor(region)PUNO:ind_cap                                  0.022092 *  
## factor(region)SAN MARTÍN:ind_cap                            0.035062 *  
## factor(region)TACNA:ind_cap                                 0.018294 *  
## factor(region)TUMBES:ind_cap                                0.528313    
## factor(region)UCAYALI:ind_cap                               0.818927    
## factor(region)AMAZONAS:ind_cohes                            0.709578    
## factor(region)ÁNCASH:ind_cohes                              0.212404    
## factor(region)APURÍMAC:ind_cohes                             < 2e-16 ***
## factor(region)AREQUIPA:ind_cohes                            0.037030 *  
## factor(region)AYACUCHO:ind_cohes                            0.638271    
## factor(region)CAJAMARCA:ind_cohes                           0.786499    
## factor(region)CUSCO:ind_cohes                               0.023144 *  
## factor(region)DEPARTAMENTO DE LIMA:ind_cohes                0.008008 ** 
## factor(region)HUANCAVELICA:ind_cohes                        0.389112    
## factor(region)HUÁNUCO:ind_cohes                             0.000664 ***
## factor(region)ICA:ind_cohes                                 0.037946 *  
## factor(region)JUNÍN:ind_cohes                               1.29e-06 ***
## factor(region)LA LIBERTAD:ind_cohes                         0.027827 *  
## factor(region)LAMBAYEQUE:ind_cohes                          0.139264    
## factor(region)LIMA METROPOLITANA:ind_cohes                  9.00e-05 ***
## factor(region)LORETO:ind_cohes                              0.146232    
## factor(region)MADRE DE DIOS:ind_cohes                       0.137414    
## factor(region)MOQUEGUA:ind_cohes                            2.31e-05 ***
## factor(region)PASCO:ind_cohes                               0.216777    
## factor(region)PIURA:ind_cohes                               0.010269 *  
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_cohes 0.002418 ** 
## factor(region)PUNO:ind_cohes                                0.463861    
## factor(region)SAN MARTÍN:ind_cohes                          0.000713 ***
## factor(region)TACNA:ind_cohes                               0.000211 ***
## factor(region)TUMBES:ind_cohes                              0.000902 ***
## factor(region)UCAYALI:ind_cohes                             0.013265 *  
## factor(region)AMAZONAS:ind_equi                             0.051948 .  
## factor(region)ÁNCASH:ind_equi                               0.983846    
## factor(region)APURÍMAC:ind_equi                             0.193855    
## factor(region)AREQUIPA:ind_equi                             0.135512    
## factor(region)AYACUCHO:ind_equi                             0.137309    
## factor(region)CAJAMARCA:ind_equi                            0.134105    
## factor(region)CUSCO:ind_equi                                0.017207 *  
## factor(region)DEPARTAMENTO DE LIMA:ind_equi                 0.468234    
## factor(region)HUANCAVELICA:ind_equi                         0.121855    
## factor(region)HUÁNUCO:ind_equi                              0.771466    
## factor(region)ICA:ind_equi                                  0.000609 ***
## factor(region)JUNÍN:ind_equi                                0.830844    
## factor(region)LA LIBERTAD:ind_equi                          0.817649    
## factor(region)LAMBAYEQUE:ind_equi                           0.073271 .  
## factor(region)LIMA METROPOLITANA:ind_equi                   0.587881    
## factor(region)LORETO:ind_equi                               0.090222 .  
## factor(region)MADRE DE DIOS:ind_equi                        0.840133    
## factor(region)MOQUEGUA:ind_equi                             0.382909    
## factor(region)PASCO:ind_equi                                0.579218    
## factor(region)PIURA:ind_equi                                0.241039    
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_equi  0.152570    
## factor(region)PUNO:ind_equi                                 0.164192    
## factor(region)SAN MARTÍN:ind_equi                           0.004042 ** 
## factor(region)TACNA:ind_equi                                0.183933    
## factor(region)TUMBES:ind_equi                               0.026045 *  
## factor(region)UCAYALI:ind_equi                              0.071006 .  
## factor(region)AMAZONAS:ind_segu                             0.407977    
## factor(region)ÁNCASH:ind_segu                               0.240913    
## factor(region)APURÍMAC:ind_segu                             0.001232 ** 
## factor(region)AREQUIPA:ind_segu                             0.034865 *  
## factor(region)AYACUCHO:ind_segu                             0.919922    
## factor(region)CAJAMARCA:ind_segu                            0.161158    
## factor(region)CUSCO:ind_segu                                0.076442 .  
## factor(region)DEPARTAMENTO DE LIMA:ind_segu                 0.966400    
## factor(region)HUANCAVELICA:ind_segu                         0.846868    
## factor(region)HUÁNUCO:ind_segu                              0.782370    
## factor(region)ICA:ind_segu                                  0.177378    
## factor(region)JUNÍN:ind_segu                                0.530116    
## factor(region)LA LIBERTAD:ind_segu                          0.303478    
## factor(region)LAMBAYEQUE:ind_segu                           0.647164    
## factor(region)LIMA METROPOLITANA:ind_segu                   0.279896    
## factor(region)LORETO:ind_segu                               0.695896    
## factor(region)MADRE DE DIOS:ind_segu                        0.000978 ***
## factor(region)MOQUEGUA:ind_segu                             0.908686    
## factor(region)PASCO:ind_segu                                0.735407    
## factor(region)PIURA:ind_segu                                0.887364    
## factor(region)PROVINCIA CONSTITUCIONAL DEL CALLAO:ind_segu  0.402786    
## factor(region)PUNO:ind_segu                                 0.306945    
## factor(region)SAN MARTÍN:ind_segu                           0.445559    
## factor(region)TACNA:ind_segu                                0.059046 .  
## factor(region)TUMBES:ind_segu                               0.085287 .  
## factor(region)UCAYALI:ind_segu                              0.785138    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.08244 on 520 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:      1 
## F-statistic: 1.927e+05 on 130 and 520 DF,  p-value: < 2.2e-16

Data Panel

Data Panel por pilares

Efectos fijos

library(plm)
## Warning: package 'plm' was built under R version 4.4.1
## 
## Adjuntando el paquete: 'plm'
## The following objects are masked from 'package:dplyr':
## 
##     between, lag, lead
fijo_pi <- plm(log(pbi)~ind_cap+ind_cohes+ind_equi+ind_segu+log(exp), index = c("region","year"), model = "within", data= NUSEDAT)
summary(fijo_pi)
## Oneway (individual) effect Within Model
## 
## Call:
## plm(formula = log(pbi) ~ ind_cap + ind_cohes + ind_equi + ind_segu + 
##     log(exp), data = NUSEDAT, model = "within", index = c("region", 
##     "year"))
## 
## Balanced Panel: n = 26, T = 25, N = 650
## 
## Residuals:
##       Min.    1st Qu.     Median    3rd Qu.       Max. 
## -0.4415853 -0.0708311 -0.0075561  0.0638279  0.5641100 
## 
## Coefficients:
##             Estimate Std. Error t-value  Pr(>|t|)    
## ind_cap    0.2769512  0.0482676  5.7378 1.502e-08 ***
## ind_cohes -0.2666417  0.0356056 -7.4887 2.406e-13 ***
## ind_equi   0.0850310  0.0372548  2.2824    0.0228 *  
## ind_segu  -0.0201121  0.0472244 -0.4259    0.6703    
## log(exp)   0.0809072  0.0077298 10.4669 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    30.5
## Residual Sum of Squares: 9.3614
## R-Squared:      0.69307
## Adj. R-Squared: 0.67819
## F-statistic: 279.547 on 5 and 619 DF, p-value: < 2.22e-16

Efectos aleatorios

library(plm)
aleatorio_pi <- plm(log(pbi)~ind_cap+ind_cohes+ind_equi+ind_segu+log(exp), index = c("region","year"), model = "random", data= NUSEDAT)
summary(aleatorio_pi)
## Oneway (individual) effect Random Effect Model 
##    (Swamy-Arora's transformation)
## 
## Call:
## plm(formula = log(pbi) ~ ind_cap + ind_cohes + ind_equi + ind_segu + 
##     log(exp), data = NUSEDAT, model = "random", index = c("region", 
##     "year"))
## 
## Balanced Panel: n = 26, T = 25, N = 650
## 
## Effects:
##                   var std.dev share
## idiosyncratic 0.01512 0.12298 0.034
## individual    0.42540 0.65223 0.966
## theta: 0.9623
## 
## Residuals:
##       Min.    1st Qu.     Median    3rd Qu.       Max. 
## -0.4965758 -0.0776564 -0.0037825  0.0865158  0.5085853 
## 
## Coefficients:
##              Estimate Std. Error  z-value  Pr(>|z|)    
## (Intercept) 15.581844   0.149990 103.8855 < 2.2e-16 ***
## ind_cap      0.273901   0.050195   5.4567 4.850e-08 ***
## ind_cohes   -0.262528   0.037026  -7.0903 1.338e-12 ***
## ind_equi     0.083380   0.038747   2.1519   0.03141 *  
## ind_segu    -0.023437   0.049109  -0.4772   0.63319    
## log(exp)     0.086570   0.007993  10.8308 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    31.957
## Residual Sum of Squares: 10.537
## R-Squared:      0.67028
## Adj. R-Squared: 0.66772
## Chisq: 1309.16 on 5 DF, p-value: < 2.22e-16

Test de Hausman

phtest(fijo_pi, aleatorio_pi)
## 
##  Hausman Test
## 
## data:  log(pbi) ~ ind_cap + ind_cohes + ind_equi + ind_segu + log(exp)
## chisq = 7.8267, df = 5, p-value = 0.1661
## alternative hypothesis: one model is inconsistent

Data panel - ind

Efectos fijos

library(plm)
fijo_ind <- plm(log(pbi)~ind+log(exp), index = c("region","year"), model = "within", data= NUSEDAT)
summary(fijo_ind)
## Oneway (individual) effect Within Model
## 
## Call:
## plm(formula = log(pbi) ~ ind + log(exp), data = NUSEDAT, model = "within", 
##     index = c("region", "year"))
## 
## Balanced Panel: n = 26, T = 25, N = 650
## 
## Residuals:
##       Min.    1st Qu.     Median    3rd Qu.       Max. 
## -0.4101512 -0.1003530 -0.0051041  0.0803282  0.5496565 
## 
## Coefficients:
##           Estimate Std. Error t-value  Pr(>|t|)    
## ind      1.1078344  0.0834492  13.276 < 2.2e-16 ***
## log(exp) 0.1343049  0.0090885  14.777 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    30.5
## Residual Sum of Squares: 14.951
## R-Squared:      0.50981
## Adj. R-Squared: 0.48853
## F-statistic: 323.451 on 2 and 622 DF, p-value: < 2.22e-16

Efectos Aleatorios.

aleatorio_ind <- plm(log(pbi)~ind+log(exp), index = c("region","year"), model = "random", data= NUSEDAT)
summary(aleatorio_ind)
## Oneway (individual) effect Random Effect Model 
##    (Swamy-Arora's transformation)
## 
## Call:
## plm(formula = log(pbi) ~ ind + log(exp), data = NUSEDAT, model = "random", 
##     index = c("region", "year"))
## 
## Balanced Panel: n = 26, T = 25, N = 650
## 
## Effects:
##                   var std.dev share
## idiosyncratic 0.02404 0.15504 0.043
## individual    0.53301 0.73008 0.957
## theta: 0.9576
## 
## Residuals:
##       Min.    1st Qu.     Median    3rd Qu.       Max. 
## -0.4543283 -0.0968110 -0.0036556  0.0905578  0.5117419 
## 
## Coefficients:
##               Estimate Std. Error z-value  Pr(>|z|)    
## (Intercept) 14.6807625  0.1574792  93.224 < 2.2e-16 ***
## ind          1.0885215  0.0852271  12.772 < 2.2e-16 ***
## log(exp)     0.1399516  0.0092306  15.162 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    32.347
## Residual Sum of Squares: 16.259
## R-Squared:      0.49737
## Adj. R-Squared: 0.49581
## Chisq: 640.218 on 2 DF, p-value: < 2.22e-16

Test de hausman

phtest(fijo_ind, aleatorio_ind)
## 
##  Hausman Test
## 
## data:  log(pbi) ~ ind + log(exp)
## chisq = 12.25, df = 2, p-value = 0.002187
## alternative hypothesis: one model is inconsistent