Importacion de bases de datos

Base de datos 2006

## Agregacion de servicios

library(dplyr)
servicios_row<-colSums(mip2006_ci[41:46,])
temporal<-rbind(mip2006_ci[1:40,],servicios_row)
servicios_col<-rowSums(temporal[,41:46])
mip2006_ci_corregida<-cbind(temporal[,1:40],servicios_col)
names(mip2006_ci_corregida)<-as.character(1:41)
X_2006<-rbind(mip2006_X[1:40,],colSums(mip2006_X[41:46,]))

Base de datos 1990.

## Agregacion de servicios 1990

servicios_row_1990<-colSums(mip1990_ci[41:46,])
temporal_1990<-rbind(mip1990_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(mip1990_x[1:40,],colSums(mip1990_x[41:46,]))

Funciones

# 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

}

1. Calculos

a. Multiplicadores de Expansión de la demanda

## Multiplicadores de expancion de la demanda 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)
me_2006
##  [1]  1.297922  1.020215  1.234962  1.847889  1.083978  1.400624  1.685844
##  [8]  1.026941  1.499664  1.071302  1.401085  1.471804  1.040887  1.526300
## [15]  1.941532  1.344572  1.277062  1.000000  1.301245  1.371596  1.395160
## [22]  1.176944  1.433429  1.363739  1.212840  1.240559  1.276547  1.496298
## [29]  1.990601  1.109025  1.088510  1.588449  2.124461  1.674974 23.762309
## [36]  1.299292  1.397290  1.684696  1.236529  1.171619  1.360409
## Multiplicadores de expancion de la demanda 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)
me_1990
##  [1]  1.255178  1.267747  1.261599  1.568111  1.124569  1.445002  1.768326
##  [8]  1.029765  1.383834  1.047445  1.834384  1.788561  1.059243  1.799649
## [15]  1.840519  1.553178  1.365915  1.384794  1.505731  1.642505  1.578688
## [22]  1.361625  1.665210  1.447935  1.327641  1.408787  1.395278  1.459492
## [29]  2.366807  1.299373  1.109323  1.451591  1.392119  1.826914 37.440804
## [36]  1.636206  1.517817  1.258089  1.353294  1.170121  1.301949

b. Multiplicadores de la producción

## Multiplicadores de la produccion MIP 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)
mp_2006
##  [1]  1.013829  1.052815  1.474348  1.301361  1.244981  1.623459  1.060766
##  [8]  1.196731  1.359658  2.568025  1.150131  1.077882  1.002044  1.355794
## [15]  1.054278  1.918127  1.134142  1.000527  1.470996  1.018324  1.129994
## [22]  1.107301  2.018467  1.888203  2.150340  6.346229  1.563541  1.509519
## [29]  1.791534  1.250410  1.532295  2.797425  1.081905  1.187016  1.062057
## [36]  1.197085 10.302597  1.590620  1.766302  6.502581  3.075466
## Multiplicadores de la produccion MIP 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)
mp_1990
##  [1]  1.105885  1.191285  1.750077  1.511243  1.389578  2.181171  1.119400
##  [8]  1.246299  1.083152  3.671425  1.223539  1.133089  1.006271  1.592563
## [15]  1.194635  2.224389  1.253500  1.015813  1.928648  1.030379  1.189543
## [22]  1.146679  2.696695  2.739024  3.150917  6.985378  2.603476  1.606020
## [29]  2.197902  1.495203  2.066329  2.185642  1.177725  1.239212  1.067583
## [36]  1.291981 13.816987  2.262777  3.717322  7.533336  3.673047

c. Tasa de cambio

Tasa de cambio para me

tasa_cambio_me<-me_2006/me_1990-1
tasa_cambio_me
##  [1]  0.034053910 -0.195253394 -0.021113105  0.178416600 -0.036093947
##  [6] -0.030710963 -0.046644285 -0.002742203  0.083702802  0.022777299
## [11] -0.236209344 -0.177101522 -0.017328929 -0.151889740  0.054882473
## [16] -0.134309142 -0.065050033 -0.277871073 -0.135805402 -0.164936051
## [21] -0.116253539 -0.135633166 -0.139190604 -0.058148876 -0.086470059
## [26] -0.119413382 -0.085095253  0.025218482 -0.158950892 -0.146492609
## [31] -0.018762181  0.094281625  0.526062912 -0.083167223 -0.365336575
## [36] -0.205911755 -0.079408189  0.339091521 -0.086281707  0.001280605
## [41]  0.044901570

Tasa de cambio mp

tasa_cambio_mp<-mp_2006/mp_1990-1
tasa_cambio_mp
##  [1] -0.083241979 -0.116236057 -0.157552595 -0.138880926 -0.104058154
##  [6] -0.255693743 -0.052379626 -0.039771981  0.255279837 -0.300537226
## [11] -0.059997035 -0.048722602 -0.004201206 -0.148671768 -0.117488893
## [16] -0.137683601 -0.095219718 -0.015047927 -0.237291624 -0.011699801
## [21] -0.050060911 -0.034340801 -0.251503562 -0.310629203 -0.317550983
## [26] -0.091498080 -0.399441022 -0.060086690 -0.184889040 -0.163718910
## [31] -0.258445453  0.279910220 -0.081359642 -0.042120529 -0.005176405
## [36] -0.073449996 -0.254352824 -0.297049512 -0.524845471 -0.136825786
## [41] -0.162693486

d. Tabla de resultados

library(dplyr)
library(kableExtra)
## 
## Adjuntando el paquete: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
# Nombres de  sectores 
nombres_sectores <- c(  "CAFE ORO", "ALGODON", "GRANOS BASICOS", "CAÑA DE AZUCAR", 
                        "OTRAS PRODUCCIONES AGRICOLAS",   "GANADERIA", "AVICULTURA", 
                        "SILVICULTURA", "PROD. DE LA CAZA Y LA PESCA", "PROD. DE LA MINERIA",
                        "CARNE Y SUS PRODUCTOS", "PRODUCTOS LACTEOS", "PROD. ELABORADOS DE LA PESCA",
                        "PROD. DE MOLINERIA Y PANADERIA", "AZUCAR", "OTROS PROD. ALIM. ELABORADOS", 
                        "BEBIDAS", "TABACO ELABORADO", "TEXTILES Y ART. CONFEC. DE MAT. TEXT.", 
                        "PRENDAS DE VESTIR", "CUERO Y SUS PRODUCTOS", "MADERA Y SUS PRODUCTOS", 
                        "PAPEL, CARTON Y SUS PRODUCTOS",  "PROD. DE LA IMPRENTA Y DE IND. CONEX.", 
                        "QUIMICA DE BASE Y ELABORADOS", "PROD. DE LA REFINACION DE PETROLEO",
                        "PROD. DE CAUCHO Y PLASTICO", "PROD. MINERALES NO METALICOS ELAB.", 
                        "PROD. METALICOS DE BASE Y ELAB.",  "MAQUINARIA, EQUIPOS Y SUMINISTROS", 
                        "MATERIAL DE TRANSP. Y MANUF. DIVERSAS", "ELECTRICIDAD",  
                        "AGUA Y ALCANTARILLADOS", "CONSTRUCCION", "COMERCIO", "RESTAURANTES Y HOTELES",
                        "TRANSP. Y ALMACENAMIENTO",  "COMUNICACIONES", "BANCOS, SEGUROS, OTRAS INST. FINANC.",
                        "BIENES INMUEBLES Y SERV. PRESTADOS",   "ALQUILERES DE VIVIENDA."
)


tabla <- data.frame(Nombre=nombres_sectores, me1990=me_1990, me2006=me_2006, mp1990=mp_1990, mp2006=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 %>% 
  kable(caption = "Tabla de multiplicadores MIP 1990 y 2006",
        align = "c",
        digits = 2) %>% 
  kable_material(html_font = "sans-serif") %>% 
  kable_styling(bootstrap_options = c("striped", "hover"),
                full_width = FALSE) %>%
  column_spec(2, width = "5cm") %>% column_spec(column = 7, background = "#EEE9E9") %>% column_spec(column = 8, background = "#EEE9E9") %>% column_spec(column = 2, background = "#EEE9E9")
Tabla de multiplicadores MIP 1990 y 2006
sector Nombre me1990 me2006 mp1990 mp2006 dif_me dif_mp
1 CAFE ORO 1.26 1.30 1.11 1.01 3.41 -8.32
2 ALGODON 1.27 1.02 1.19 1.05 -19.53 -11.62
3 GRANOS BASICOS 1.26 1.23 1.75 1.47 -2.11 -15.76
4 CAÑA DE AZUCAR 1.57 1.85 1.51 1.30 17.84 -13.89
5 OTRAS PRODUCCIONES AGRICOLAS 1.12 1.08 1.39 1.24 -3.61 -10.41
6 GANADERIA 1.45 1.40 2.18 1.62 -3.07 -25.57
7 AVICULTURA 1.77 1.69 1.12 1.06 -4.66 -5.24
8 SILVICULTURA 1.03 1.03 1.25 1.20 -0.27 -3.98
9 PROD. DE LA CAZA Y LA PESCA 1.38 1.50 1.08 1.36 8.37 25.53
10 PROD. DE LA MINERIA 1.05 1.07 3.67 2.57 2.28 -30.05
11 CARNE Y SUS PRODUCTOS 1.83 1.40 1.22 1.15 -23.62 -6.00
12 PRODUCTOS LACTEOS 1.79 1.47 1.13 1.08 -17.71 -4.87
13 PROD. ELABORADOS DE LA PESCA 1.06 1.04 1.01 1.00 -1.73 -0.42
14 PROD. DE MOLINERIA Y PANADERIA 1.80 1.53 1.59 1.36 -15.19 -14.87
15 AZUCAR 1.84 1.94 1.19 1.05 5.49 -11.75
16 OTROS PROD. ALIM. ELABORADOS 1.55 1.34 2.22 1.92 -13.43 -13.77
17 BEBIDAS 1.37 1.28 1.25 1.13 -6.51 -9.52
18 TABACO ELABORADO 1.38 1.00 1.02 1.00 -27.79 -1.50
19 TEXTILES Y ART. CONFEC. DE MAT. TEXT. 1.51 1.30 1.93 1.47 -13.58 -23.73
20 PRENDAS DE VESTIR 1.64 1.37 1.03 1.02 -16.49 -1.17
21 CUERO Y SUS PRODUCTOS 1.58 1.40 1.19 1.13 -11.63 -5.01
22 MADERA Y SUS PRODUCTOS 1.36 1.18 1.15 1.11 -13.56 -3.43
23 PAPEL, CARTON Y SUS PRODUCTOS 1.67 1.43 2.70 2.02 -13.92 -25.15
24 PROD. DE LA IMPRENTA Y DE IND. CONEX. 1.45 1.36 2.74 1.89 -5.81 -31.06
25 QUIMICA DE BASE Y ELABORADOS 1.33 1.21 3.15 2.15 -8.65 -31.76
26 PROD. DE LA REFINACION DE PETROLEO 1.41 1.24 6.99 6.35 -11.94 -9.15
27 PROD. DE CAUCHO Y PLASTICO 1.40 1.28 2.60 1.56 -8.51 -39.94
28 PROD. MINERALES NO METALICOS ELAB. 1.46 1.50 1.61 1.51 2.52 -6.01
29 PROD. METALICOS DE BASE Y ELAB. 2.37 1.99 2.20 1.79 -15.90 -18.49
30 MAQUINARIA, EQUIPOS Y SUMINISTROS 1.30 1.11 1.50 1.25 -14.65 -16.37
31 MATERIAL DE TRANSP. Y MANUF. DIVERSAS 1.11 1.09 2.07 1.53 -1.88 -25.84
32 ELECTRICIDAD 1.45 1.59 2.19 2.80 9.43 27.99
33 AGUA Y ALCANTARILLADOS 1.39 2.12 1.18 1.08 52.61 -8.14
34 CONSTRUCCION 1.83 1.67 1.24 1.19 -8.32 -4.21
35 COMERCIO 37.44 23.76 1.07 1.06 -36.53 -0.52
36 RESTAURANTES Y HOTELES 1.64 1.30 1.29 1.20 -20.59 -7.34
37 TRANSP. Y ALMACENAMIENTO 1.52 1.40 13.82 10.30 -7.94 -25.44
38 COMUNICACIONES 1.26 1.68 2.26 1.59 33.91 -29.70
39 BANCOS, SEGUROS, OTRAS INST. FINANC. 1.35 1.24 3.72 1.77 -8.63 -52.48
40 BIENES INMUEBLES Y SERV. PRESTADOS 1.17 1.17 7.53 6.50 0.13 -13.68
41 ALQUILERES DE VIVIENDA. 1.30 1.36 3.67 3.08 4.49 -16.27

2. Analisis Rasmussen

Análisis de Rasmussen para MIP 2006.

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_material(html_font = "sans-serif") %>% 
  kable_styling(bootstrap_options = c("striped", "hover")) %>% row_spec(row = 1, background = "#F0FFF0") %>% row_spec(row = 2, background = "#E0EEE0") %>% row_spec(row = 3, background = "#C1CDC1")
clasificacion total porcentaje
Sector Estrategico 4 9.76
Sector Impulsor 8 19.51
Sector Isla 29 70.73

Análisis de Rasmussen para MIP 1990

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_material(html_font = "sans-serif") %>% 
  kable_styling(bootstrap_options = c("striped", "hover")) %>% row_spec(row = 1, background = "#F0FFF0") %>% row_spec(row = 2, background = "#E0EEE0") %>% row_spec(row = 3, background = "#C1CDC1")
clasificacion total porcentaje
Sector Estrategico 2 4.88
Sector Impulsor 10 24.39
Sector Isla 29 70.73

3. Tabla comparativa 1990 - 2006

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_material(html_font = "sans-serif") %>% 
  kable_styling(bootstrap_options = c("striped", "hover")) %>% row_spec(row = 1, background = "#F0FFF0") %>% row_spec(row = 2, background = "#E0EEE0") %>% row_spec(row = 3, background = "#C1CDC1")
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