IMPORTAR DATOS

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
library(readxl)
options(scipen = 9999)
# Consumo Intermedio
mip_1990_ci <- read_excel("C:/Users/Usuario/Downloads/MATRIZ_INSUMO_PRODUCTO_1990-2006.xlsx", sheet = "MIP 1990", range = "i14:bb59", 
    col_names = FALSE)
## New names:
## • `` -> `...1`
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
## • `` -> `...16`
## • `` -> `...17`
## • `` -> `...18`
## • `` -> `...19`
## • `` -> `...20`
## • `` -> `...21`
## • `` -> `...22`
## • `` -> `...23`
## • `` -> `...24`
## • `` -> `...25`
## • `` -> `...26`
## • `` -> `...27`
## • `` -> `...28`
## • `` -> `...29`
## • `` -> `...30`
## • `` -> `...31`
## • `` -> `...32`
## • `` -> `...33`
## • `` -> `...34`
## • `` -> `...35`
## • `` -> `...36`
## • `` -> `...37`
## • `` -> `...38`
## • `` -> `...39`
## • `` -> `...40`
## • `` -> `...41`
## • `` -> `...42`
## • `` -> `...43`
## • `` -> `...44`
## • `` -> `...45`
## • `` -> `...46`
names(mip_1990_ci) <- as.character(1:46)
# Demanda Final
mip_1990_h <- read_excel("C:/Users/Usuario/Downloads/MATRIZ_INSUMO_PRODUCTO_1990-2006.xlsx", sheet = "MIP 1990", range = "bd14:be59", 
    col_names = FALSE)
## New names:
## • `` -> `...1`
## • `` -> `...2`
names(mip_1990_h) <- as.character(1:46)
## Warning: The `value` argument of `names<-()` must have the same length as `x` as of
## tibble 3.0.0.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Vector de Producción
mip_1990_x <- read_excel("C:/Users/Usuario/Downloads/MATRIZ_INSUMO_PRODUCTO_1990-2006.xlsx", sheet = "MIP 1990", range = "bi14:bi59", 
    col_names = FALSE)
## New names:
## • `` -> `...1`
names(mip_1990_x)<-as.character("X")

servicios_row_1990<-colSums(mip_1990_ci[41:46,])
temporal_1990<-rbind(mip_1990_ci[1:40,],servicios_row_1990)
servicios_col_1990<-rowSums(temporal_1990[,41:46])
mip1990_ci_corregida<-cbind(temporal_1990[,1:40],servicios_col_1990)
names(mip1990_ci_corregida)<-as.character(1:41)
X_1990<-rbind(mip_1990_x[1:40,],colSums(mip_1990_x[41:46,])) %>% print()
## # A tibble: 41 × 1
##          X
##      <dbl>
##  1 254545.
##  2  31712.
##  3 293495.
##  4  44229.
##  5 246870.
##  6 199058.
##  7 182977.
##  8  71190.
##  9  42357.
## 10 157813.
## # ℹ 31 more rows
library(dplyr)
library(readxl)
options(scipen = 9999)
# Consumo Intermedio
mip_2006_ci <- read_excel("C:/Users/Usuario/Downloads/MATRIZ_INSUMO_PRODUCTO_1990-2006.xlsx", sheet = "MIP 2006", range = "i15:bb60", 
    col_names = FALSE)
## New names:
## • `` -> `...1`
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
## • `` -> `...16`
## • `` -> `...17`
## • `` -> `...18`
## • `` -> `...19`
## • `` -> `...20`
## • `` -> `...21`
## • `` -> `...22`
## • `` -> `...23`
## • `` -> `...24`
## • `` -> `...25`
## • `` -> `...26`
## • `` -> `...27`
## • `` -> `...28`
## • `` -> `...29`
## • `` -> `...30`
## • `` -> `...31`
## • `` -> `...32`
## • `` -> `...33`
## • `` -> `...34`
## • `` -> `...35`
## • `` -> `...36`
## • `` -> `...37`
## • `` -> `...38`
## • `` -> `...39`
## • `` -> `...40`
## • `` -> `...41`
## • `` -> `...42`
## • `` -> `...43`
## • `` -> `...44`
## • `` -> `...45`
## • `` -> `...46`
names(mip_2006_ci) <- as.character(1:46)
# Demanda FInal
mip_2006_h <- read_excel("C:/Users/Usuario/Downloads/MATRIZ_INSUMO_PRODUCTO_1990-2006.xlsx", sheet = "MIP 2006", range = "bd15:be60", 
    col_names = FALSE)
## New names:
## • `` -> `...1`
## • `` -> `...2`
names(mip_2006_h) <- as.character(1:2)
# Vector de producción
mip_2006_x <- read_excel("C:/Users/Usuario/Downloads/MATRIZ_INSUMO_PRODUCTO_1990-2006.xlsx", sheet = "MIP 2006", range = "bi15:bi60", 
    col_names = FALSE)
## New names:
## • `` -> `...1`
names(mip_2006_x) <- as.character("X")

servicios_row_2006<-colSums(mip_2006_ci[41:46,])
temporal_2006<-rbind(mip_2006_ci[1:40,],servicios_row_2006)
servicios_col_2006<-rowSums(temporal_2006[,41:46])
mip2006_ci_corregida<-cbind(temporal_2006[,1:40],servicios_col_2006)
names(mip2006_ci_corregida)<-as.character(1:41)
X_2006<-rbind(mip_2006_x[1:40,],colSums(mip_2006_x[41:46,])) %>% print()
## # A tibble: 41 × 1
##           X
##       <dbl>
##  1  182287 
##  2   34523 
##  3  715438.
##  4   80222 
##  5 1474837.
##  6  312032.
##  7  576046.
##  8  172777.
##  9  188273.
## 10  490735.
## # ℹ 31 more rows
#Matriz de coeficientes tecnicos
mip_coeficientes_tecnicos<-function(matriz_consumo_intermedio,
                                    vector_demanda_final){
  filas_ci<-nrow(matriz_consumo_intermedio)
  columnas_ci<-ncol(matriz_consumo_intermedio)
  filas_x<-nrow(vector_demanda_final)
  if(filas_ci!=columnas_ci){
    stop("Ingrese una matriz de Consumo Intermedio, Cuadrada",call. = FALSE)
  }
  if(filas_ci!=filas_x){
    stop("Vector de demanda final incompatible (diferente dimensión)",call. = FALSE)
  }
  v<-solve(diag(as.vector(vector_demanda_final)))
  A<-matriz_consumo_intermedio%*%v
  list(A=A,V=v)
}
#matriz tecnológica

mip_matriz_tecnologica<-function(matriz_coeficientes_tecnicos){
  filas_A<-nrow(matriz_coeficientes_tecnicos)
  columnas_A<-ncol(matriz_coeficientes_tecnicos)
  if(filas_A!=columnas_A){
    stop("Ingrese una matriz de coef. técnicos cuadrada",call. = FALSE)
  }
  tipo_matriz<-typeof(matriz_coeficientes_tecnicos)
  if(tipo_matriz!="double"){
    stop("La matriz ingresada no es numerica",call. = FALSE)
  }
  T<-diag(1,filas_A)-matriz_coeficientes_tecnicos
  T
}
mip_matriz_leontief<-function(matriz_tecnologica){
  L<-solve(matriz_tecnologica)
  L
}
mip_multiplicadores_produccion_mp<-function(matriz_leontief){
  mp<-rowSums(matriz_leontief)
  mp
}
mip_multiplicadores_expansion_demanda_me<-function(matriz_leontief){
  me<-colSums(matriz_leontief)
  me
}
mip_encadenamiento_pd<-function(matriz_leontief){
  mp<-mip_multiplicadores_produccion_mp(matriz_leontief)
  mp/mean(mp)
}
mip_encadenamiento_sd<-function(matriz_leontief){
  me<-mip_multiplicadores_expansion_demanda_me(matriz_leontief)
  me/mean(me)
}
mip_tabla_rasmussen<-function(matriz_leontief){
library(dplyr)
pd<-mip_encadenamiento_pd(matriz_leontief)
sd<-mip_encadenamiento_sd(matriz_leontief)
rasmussen<-data.frame(pd=pd,sd=sd)
rasmussen_clasificado<-rasmussen %>% 
  mutate(clasificacion=case_when(pd>1 & sd>1 ~ "Sector Clave",
                                           pd<1 & sd>1 ~"Sector Estrategico",
                                           pd>1 & sd<1 ~"Sector Impulsor",
                                           pd<1 & sd<1 ~"Sector Isla",
                                           TRUE ~ "No clasificado")) %>% mutate(sector=row_number()) %>% select(sector,pd,sd,clasificacion)
rasmussen_clasificado
}

EJERCICIO 1

LITERAL A

##LITERAL A
library(dplyr)
library(kableExtra)
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
# Año 1990
A_1990<-mip_coeficientes_tecnicos(as.matrix(mip1990_ci_corregida),as.matrix(X_1990))[[1]]
matriz_T_1990<-mip_matriz_tecnologica(matriz_coeficientes_tecnicos = A_1990)
L_1990<-mip_matriz_leontief(matriz_tecnologica = matriz_T_1990)
me_1990<-mip_multiplicadores_expansion_demanda_me(matriz_leontief = L_1990)

# Año 2006
A_2006<-mip_coeficientes_tecnicos(as.matrix(mip2006_ci_corregida),as.matrix(X_2006))[[1]]
matriz_T_2006<-mip_matriz_tecnologica(matriz_coeficientes_tecnicos = A_2006)
L_2006<-mip_matriz_leontief(matriz_tecnologica = matriz_T_2006)
me_2006<-mip_multiplicadores_expansion_demanda_me(matriz_leontief = L_2006)

tabla_me_1990_2006 <- cbind(1:41,me_1990, me_2006) 
 tabla_me_1990_2006 %>% head(41) %>% 
  kable(caption = "Multiplicadores Expansión de la demanda (me) para la MIP 1990 y 2006",
        align="c", digits = 4) %>% kable_styling(bootstrap_options = c("striped", "hover"))
Multiplicadores Expansión de la demanda (me) para la MIP 1990 y 2006
me_1990 me_2006
1 1.2552 1.2979
2 1.2677 1.0202
3 1.2616 1.2350
4 1.5681 1.8479
5 1.1246 1.0840
6 1.4450 1.4006
7 1.7683 1.6858
8 1.0298 1.0269
9 1.3838 1.4997
10 1.0474 1.0713
11 1.8344 1.4011
12 1.7886 1.4718
13 1.0592 1.0409
14 1.7996 1.5263
15 1.8405 1.9415
16 1.5532 1.3446
17 1.3659 1.2771
18 1.3848 1.0000
19 1.5057 1.3012
20 1.6425 1.3716
21 1.5787 1.3952
22 1.3616 1.1769
23 1.6652 1.4334
24 1.4479 1.3637
25 1.3276 1.2128
26 1.4088 1.2406
27 1.3953 1.2765
28 1.4595 1.4963
29 2.3668 1.9906
30 1.2994 1.1090
31 1.1093 1.0885
32 1.4516 1.5884
33 1.3921 2.1245
34 1.8269 1.6750
35 37.4408 23.7623
36 1.6362 1.2993
37 1.5178 1.3973
38 1.2581 1.6847
39 1.3533 1.2365
40 1.1701 1.1716
41 1.3019 1.3604

LIREAL B

library(dplyr)
library(kableExtra)
# Año 1990
A_1990<-mip_coeficientes_tecnicos(as.matrix(mip1990_ci_corregida),as.matrix(X_1990))[[1]]
matriz_T_1990<-mip_matriz_tecnologica(matriz_coeficientes_tecnicos = A_1990)
L_1990<-mip_matriz_leontief(matriz_tecnologica = matriz_T_1990)
mp_1990<-mip_multiplicadores_produccion_mp(matriz_leontief = L_1990)

# Año 2006
A_2006<-mip_coeficientes_tecnicos(as.matrix(mip2006_ci_corregida),as.matrix(X_2006))[[1]]
matriz_T_2006<-mip_matriz_tecnologica(matriz_coeficientes_tecnicos = A_2006)
L_2006<-mip_matriz_leontief(matriz_tecnologica = matriz_T_2006)
mp_2006<-mip_multiplicadores_produccion_mp(matriz_leontief = L_2006)

tabla_mp_1990_2006 <- cbind(1:41,mp_1990, mp_2006) 
 tabla_mp_1990_2006 %>% head(41) %>% 
  kable(caption = "Multiplicadores de la producción (mp) para la MIP 1990 y 2006",
        align="c", digits = 4) %>% kable_styling(bootstrap_options = c("striped", "hover"))
Multiplicadores de la producción (mp) para la MIP 1990 y 2006
mp_1990 mp_2006
1 1.1059 1.0138
2 1.1913 1.0528
3 1.7501 1.4743
4 1.5112 1.3014
5 1.3896 1.2450
6 2.1812 1.6235
7 1.1194 1.0608
8 1.2463 1.1967
9 1.0832 1.3597
10 3.6714 2.5680
11 1.2235 1.1501
12 1.1331 1.0779
13 1.0063 1.0020
14 1.5926 1.3558
15 1.1946 1.0543
16 2.2244 1.9181
17 1.2535 1.1341
18 1.0158 1.0005
19 1.9286 1.4710
20 1.0304 1.0183
21 1.1895 1.1300
22 1.1467 1.1073
23 2.6967 2.0185
24 2.7390 1.8882
25 3.1509 2.1503
26 6.9854 6.3462
27 2.6035 1.5635
28 1.6060 1.5095
29 2.1979 1.7915
30 1.4952 1.2504
31 2.0663 1.5323
32 2.1856 2.7974
33 1.1777 1.0819
34 1.2392 1.1870
35 1.0676 1.0621
36 1.2920 1.1971
37 13.8170 10.3026
38 2.2628 1.5906
39 3.7173 1.7663
40 7.5333 6.5026
41 3.6730 3.0755

LITERAL C

library(dplyr)
library(kableExtra)
tasa_cambio_me<-(me_2006/me_1990)-1
tasa_cambio_mp<-(mp_2006/mp_1990)-1

tabla_tasa_me_mp <- cbind(1:41,tasa_cambio_me, tasa_cambio_mp) 
 tabla_tasa_me_mp %>% head(41) %>% 
  kable(caption = "Tasa de cambio para ambos multiplicadores 1990 y 2006",
        align="c", digits = 4) %>% kable_styling(bootstrap_options = c("striped", "hover"))
Tasa de cambio para ambos multiplicadores 1990 y 2006
tasa_cambio_me tasa_cambio_mp
1 0.0341 -0.0832
2 -0.1953 -0.1162
3 -0.0211 -0.1576
4 0.1784 -0.1389
5 -0.0361 -0.1041
6 -0.0307 -0.2557
7 -0.0466 -0.0524
8 -0.0027 -0.0398
9 0.0837 0.2553
10 0.0228 -0.3005
11 -0.2362 -0.0600
12 -0.1771 -0.0487
13 -0.0173 -0.0042
14 -0.1519 -0.1487
15 0.0549 -0.1175
16 -0.1343 -0.1377
17 -0.0651 -0.0952
18 -0.2779 -0.0150
19 -0.1358 -0.2373
20 -0.1649 -0.0117
21 -0.1163 -0.0501
22 -0.1356 -0.0343
23 -0.1392 -0.2515
24 -0.0581 -0.3106
25 -0.0865 -0.3176
26 -0.1194 -0.0915
27 -0.0851 -0.3994
28 0.0252 -0.0601
29 -0.1590 -0.1849
30 -0.1465 -0.1637
31 -0.0188 -0.2584
32 0.0943 0.2799
33 0.5261 -0.0814
34 -0.0832 -0.0421
35 -0.3653 -0.0052
36 -0.2059 -0.0734
37 -0.0794 -0.2544
38 0.3391 -0.2970
39 -0.0863 -0.5248
40 0.0013 -0.1368
41 0.0449 -0.1627

LITERAL D

library(dplyr)
library(kableExtra)

tabla_multiplicadores <- data.frame(me_1990=me_1990,me_2006=me_2006, mp_1990=mp_1990, mp_2006=mp_2006) %>% 
  mutate(dif_me=round((me_2006/me_1990-1)*100,2),
         dif_mp=round((mp_2006/mp_1990-1)*100,2)) %>%
  mutate(sector=row_number()) %>% 
         select(sector, everything())

tabla_multiplicadores %>% 
  kable(aption="Tabla de los multiplicadores MIP 1990 y 2006",
        align = "c", digits = 4) %>% 
  kable_styling(bootstrap_options = c("striped", "hover"))
sector me_1990 me_2006 mp_1990 mp_2006 dif_me dif_mp
1 1.2552 1.2979 1.1059 1.0138 3.41 -8.32
2 1.2677 1.0202 1.1913 1.0528 -19.53 -11.62
3 1.2616 1.2350 1.7501 1.4743 -2.11 -15.76
4 1.5681 1.8479 1.5112 1.3014 17.84 -13.89
5 1.1246 1.0840 1.3896 1.2450 -3.61 -10.41
6 1.4450 1.4006 2.1812 1.6235 -3.07 -25.57
7 1.7683 1.6858 1.1194 1.0608 -4.66 -5.24
8 1.0298 1.0269 1.2463 1.1967 -0.27 -3.98
9 1.3838 1.4997 1.0832 1.3597 8.37 25.53
10 1.0474 1.0713 3.6714 2.5680 2.28 -30.05
11 1.8344 1.4011 1.2235 1.1501 -23.62 -6.00
12 1.7886 1.4718 1.1331 1.0779 -17.71 -4.87
13 1.0592 1.0409 1.0063 1.0020 -1.73 -0.42
14 1.7996 1.5263 1.5926 1.3558 -15.19 -14.87
15 1.8405 1.9415 1.1946 1.0543 5.49 -11.75
16 1.5532 1.3446 2.2244 1.9181 -13.43 -13.77
17 1.3659 1.2771 1.2535 1.1341 -6.51 -9.52
18 1.3848 1.0000 1.0158 1.0005 -27.79 -1.50
19 1.5057 1.3012 1.9286 1.4710 -13.58 -23.73
20 1.6425 1.3716 1.0304 1.0183 -16.49 -1.17
21 1.5787 1.3952 1.1895 1.1300 -11.63 -5.01
22 1.3616 1.1769 1.1467 1.1073 -13.56 -3.43
23 1.6652 1.4334 2.6967 2.0185 -13.92 -25.15
24 1.4479 1.3637 2.7390 1.8882 -5.81 -31.06
25 1.3276 1.2128 3.1509 2.1503 -8.65 -31.76
26 1.4088 1.2406 6.9854 6.3462 -11.94 -9.15
27 1.3953 1.2765 2.6035 1.5635 -8.51 -39.94
28 1.4595 1.4963 1.6060 1.5095 2.52 -6.01
29 2.3668 1.9906 2.1979 1.7915 -15.90 -18.49
30 1.2994 1.1090 1.4952 1.2504 -14.65 -16.37
31 1.1093 1.0885 2.0663 1.5323 -1.88 -25.84
32 1.4516 1.5884 2.1856 2.7974 9.43 27.99
33 1.3921 2.1245 1.1777 1.0819 52.61 -8.14
34 1.8269 1.6750 1.2392 1.1870 -8.32 -4.21
35 37.4408 23.7623 1.0676 1.0621 -36.53 -0.52
36 1.6362 1.2993 1.2920 1.1971 -20.59 -7.34
37 1.5178 1.3973 13.8170 10.3026 -7.94 -25.44
38 1.2581 1.6847 2.2628 1.5906 33.91 -29.70
39 1.3533 1.2365 3.7173 1.7663 -8.63 -52.48
40 1.1701 1.1716 7.5333 6.5026 0.13 -13.68
41 1.3019 1.3604 3.6730 3.0755 4.49 -16.27

EJERCICIO 2

ANALISIS DE RASMUSSEN MIP 1990

library(dplyr)
library(kableExtra)
rasmussen_1990 <- mip_tabla_rasmussen(L_1990)
summary_rasmussen_1990 <- rasmussen_1990 %>% 
  group_by(clasificacion) %>% summarise(total=n()) %>% mutate(porcentaje=round(prop.table(total)*100,2))

summary_rasmussen_1990 %>% 
  kable(aption="Análisis de Rasmussen para MIP 1990",
        align = "c", digits = 2) %>% 
  kable_styling(bootstrap_options = c("striped", "hover"))
clasificacion total porcentaje
Sector Estrategico 2 4.88
Sector Impulsor 10 24.39
Sector Isla 29 70.73

ANALISIS DE RASMUSSEN MIP 2006

library(dplyr)
library(kableExtra)
rasmussen_2006 <- mip_tabla_rasmussen(L_2006)
summary_rasmussen_2006 <- rasmussen_2006 %>% 
  group_by(clasificacion) %>% summarise(total=n()) %>% mutate(porcentaje=round(prop.table(total)*100,2))

summary_rasmussen_2006 %>% 
  kable(aption="Análisis de Rasmussen para MIP 2006",
        align = "c", digits = 2) %>% 
  kable_styling(bootstrap_options = c("striped", "hover"))
clasificacion total porcentaje
Sector Estrategico 4 9.76
Sector Impulsor 8 19.51
Sector Isla 29 70.73

EJERCICIO 3

tabla_comparativa<-left_join(summary_rasmussen_1990, summary_rasmussen_2006, by="clasificacion", suffix=c("_1990","_2006"))
tabla_comparativa %>% 
  mutate(dif_variacion_porcentual= round((porcentaje_2006/porcentaje_1990-1)*100,2)) %>% 
  kable(aption="Tabla comparativa",
        align = "c", digits = 2) %>% 
  kable_styling(bootstrap_options = c("striped", "hover"))
clasificacion total_1990 porcentaje_1990 total_2006 porcentaje_2006 dif_variacion_porcentual
Sector Estrategico 2 4.88 4 9.76 100.00
Sector Impulsor 10 24.39 8 19.51 -20.01
Sector Isla 29 70.73 29 70.73 0.00