CREACION DE FUNCIONES
#matriz de coeficientes tecnios
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_tecnologica
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
}
##Funciones para el calculos de los multiplicadores
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
}
##Funiones del analisis de rasmusen
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
}
EXPORTACIONES DE DATOS 2006
library(readxl)
##consumo intermedio
mip2006_ci<- read_excel("C:/Users/Roberto/Downloads/Anexo_Resolución_32_MATRIZ_INSUMO_PRODUCTO_A_PRECIOS_CORRIENTES_EN_DOLARES_1990-2006.xlsx",
sheet = "MIP 2006", range = "I15:BB60",
col_names = FALSE)
names(mip2006_ci)<-as.character(1:46)
print(mip2006_ci)
## # A tibble: 46 × 46
## `1` `2` `3` `4` `5` `6` `7` `8` `9` `10` `11` `12`
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 86 0 0 0 0 0 0 0 0 0 0 0
## 2 0 0 0 0 0 0 0 0 0 0 0 0
## 3 0 0 11004 0 0 5313 28072 0 0 0 1 65
## 4 0 0 0 3071 0 0 0 0 0 0 0 0
## 5 0 104 38676 1357 11299 0 0 0 0 0 14 469
## 6 0 0 0 0 0 8777 19 0 0 0 89833 144571
## 7 0 0 0 0 0 0 16874 0 7 0 4137 57
## 8 576 1 2000 272 563 65 0 36 0 0 204 734
## 9 0 0 0 0 0 0 0 0 44464 0 0 0
## 10 1 1 73 58 21 2023 6 0 2 15334 3 89
## # ℹ 36 more rows
## # ℹ 34 more variables: `13` <dbl>, `14` <dbl>, `15` <dbl>, `16` <dbl>,
## # `17` <dbl>, `18` <dbl>, `19` <dbl>, `20` <dbl>, `21` <dbl>, `22` <dbl>,
## # `23` <dbl>, `24` <dbl>, `25` <dbl>, `26` <dbl>, `27` <dbl>, `28` <dbl>,
## # `29` <dbl>, `30` <dbl>, `31` <dbl>, `32` <dbl>, `33` <dbl>, `34` <dbl>,
## # `35` <dbl>, `36` <dbl>, `37` <dbl>, `38` <dbl>, `39` <dbl>, `40` <dbl>,
## # `41` <dbl>, `42` <dbl>, `43` <dbl>, `44` <dbl>, `45` <dbl>, `46` <dbl>
##matrz de demanda final
mip2006_B <- read_excel("C:/Users/Roberto/Downloads/Anexo_Resolución_32_MATRIZ_INSUMO_PRODUCTO_A_PRECIOS_CORRIENTES_EN_DOLARES_1990-2006.xlsx",
range = "BD15:BE60", col_names = FALSE,sheet = "MIP 2006")
names(mip2006_B)=as.character(1:2)
##vector de producto final
mip2006_x <- read_excel("C:/Users/Roberto/Downloads/Anexo_Resolución_32_MATRIZ_INSUMO_PRODUCTO_A_PRECIOS_CORRIENTES_EN_DOLARES_1990-2006.xlsx",
range = "BI15:BI60", col_names = FALSE,sheet = "MIP 2006")
names(mip2006_x)=c("X")
correcion de las tablas
##suma la fila 41-46
servicios_row=colSums(mip2006_ci[41:46,])
temporal=rbind(mip2006_ci[1:40,],servicios_row)
##suma de columnas
servicios_col<-rowSums(temporal[,41:46])
mip2006_corregida=cbind(temporal[,1:40],servicios_col)
names(mip2006_corregida)=as.character(1:41)
##correcion del vector de demanda final
x_2006<-rbind(mip2006_x[1:40,],colSums(mip2006_x[41:46,]))
EXPORTACION DE DATOS MP 1990
## consumo intermedio
mip1990_ci= read_excel("C:/Users/Roberto/Downloads/Anexo_Resolución_32_MATRIZ_INSUMO_PRODUCTO_A_PRECIOS_CORRIENTES_EN_DOLARES_1990-2006.xlsx",
range = "I14:BB59", col_names = FALSE,sheet = "MIP 1990")
names(mip1990_ci)<-as.character(1:46)
## matriz de demanda final
mip1990_B= read_excel("C:/Users/Roberto/Downloads/Anexo_Resolución_32_MATRIZ_INSUMO_PRODUCTO_A_PRECIOS_CORRIENTES_EN_DOLARES_1990-2006.xlsx",
range = "BD14:BE59", col_names = FALSE,sheet = "MIP 1990")
names(mip1990_B)=as.character(1:2)
## vector de demanda produccion
mip1990_x= read_excel("C:/Users/Roberto/Downloads/Anexo_Resolución_32_MATRIZ_INSUMO_PRODUCTO_A_PRECIOS_CORRIENTES_EN_DOLARES_1990-2006.xlsx",
range = "BI14:BI59", col_names = FALSE,sheet = "MIP 1990")
correcion de tablas.
library(dplyr)
##suma la fila 41-46
servicios_row=colSums(mip1990_ci[41:46,])
temporal2=rbind(mip1990_ci[1:40,],servicios_row)
##suma de columnas
servicios_col<-rowSums(temporal2[,41:46])
mip1990_corregida=cbind(temporal2[,1:40],servicios_col)
names(mip1990_corregida)=as.character(1:41)
##correcion del vector de demanda final
x_1990<-rbind(mip1990_x[1:40,],
colSums(mip1990_x[41:46,]))
1.
A. MULTIPLICADORES DE EXPACION DE LA DEMANDA
1990
library(dplyr)
A_1990=mip_coeficientes_tecnicos(matriz_consumo_intermedio = as.matrix(mip1990_corregida),vector_demanda_final = as.matrix(x_1990))[[1]]
Matriz_t=mip_matriz_tecnologica(matriz_coeficientes_tecnicos = A_1990)
L_1990=mip_matriz_leontief(matriz_tecnologica = Matriz_t)
MIP_ED_1990=mip_multiplicadores_expansion_demanda_me(matriz_leontief = L_1990)%>%print()
## [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
2006
library(dplyr)
A_2006=mip_coeficientes_tecnicos(matriz_consumo_intermedio = as.matrix(mip2006_corregida),vector_demanda_final = as.matrix(x_2006))[[1]]
Matriz_t=mip_matriz_tecnologica(matriz_coeficientes_tecnicos = A_2006)
L_2006=mip_matriz_leontief(matriz_tecnologica = Matriz_t)
MIP_ED_2006=mip_multiplicadores_expansion_demanda_me(matriz_leontief = L_2006)%>%print()
## [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
B.MULTIPLICADORES DE LA PRODUCCION.
1990
MP_1990=mip_multiplicadores_produccion_mp(matriz_leontief = L_1990)%>%print()
## [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
2006
MP_2006=mip_multiplicadores_produccion_mp(matriz_leontief = L_2006)%>%print()
## [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
C.TASA DE CAMBIO PARA AMBOS MULTIPLICADORES
library(dplyr)
tasa_MP=((MP_2006/MP_1990-1)*100)%>%print()
## [1] -8.3241979 -11.6236057 -15.7552595 -13.8880926 -10.4058154 -25.5693743
## [7] -5.2379626 -3.9771981 25.5279837 -30.0537226 -5.9997035 -4.8722602
## [13] -0.4201206 -14.8671769 -11.7488893 -13.7683601 -9.5219718 -1.5047927
## [19] -23.7291624 -1.1699801 -5.0060911 -3.4340801 -25.1503562 -31.0629203
## [25] -31.7550983 -9.1498080 -39.9441022 -6.0086690 -18.4889040 -16.3718910
## [31] -25.8445453 27.9910220 -8.1359642 -4.2120529 -0.5176405 -7.3449996
## [37] -25.4352824 -29.7049512 -52.4845471 -13.6825786 -16.2693486
tasa_ED=((MIP_ED_2006/MIP_ED_1990-1)*100)%>%print()
## [1] 3.4053910 -19.5253394 -2.1113105 17.8416600 -3.6093947 -3.0710963
## [7] -4.6644285 -0.2742203 8.3702802 2.2777299 -23.6209344 -17.7101522
## [13] -1.7328929 -15.1889740 5.4882473 -13.4309142 -6.5050033 -27.7871073
## [19] -13.5805402 -16.4936051 -11.6253539 -13.5633166 -13.9190604 -5.8148876
## [25] -8.6470059 -11.9413382 -8.5095253 2.5218482 -15.8950891 -14.6492609
## [31] -1.8762181 9.4281625 52.6062912 -8.3167223 -36.5336575 -20.5911755
## [37] -7.9408189 33.9091521 -8.6281707 0.1280605 4.4901570
D.PRESENTACION EN TABLAS
library(dplyr)
library(kableExtra)
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
tabla1=data.frame(tasa_MP=tasa_MP,tasa_ED=tasa_ED)%>%mutate(sector=row_number())%>%select(sector,everything())
tabla1%>%kable(aption = "tabla de los multiplicadores MIP",align = "c",digits = 2)%>%kable_material(html_font = "sans-serif")%>%kable_styling(bootstrap_options = c("striped", "hover"))
|
sector
|
tasa_MP
|
tasa_ED
|
|
1
|
-8.32
|
3.41
|
|
2
|
-11.62
|
-19.53
|
|
3
|
-15.76
|
-2.11
|
|
4
|
-13.89
|
17.84
|
|
5
|
-10.41
|
-3.61
|
|
6
|
-25.57
|
-3.07
|
|
7
|
-5.24
|
-4.66
|
|
8
|
-3.98
|
-0.27
|
|
9
|
25.53
|
8.37
|
|
10
|
-30.05
|
2.28
|
|
11
|
-6.00
|
-23.62
|
|
12
|
-4.87
|
-17.71
|
|
13
|
-0.42
|
-1.73
|
|
14
|
-14.87
|
-15.19
|
|
15
|
-11.75
|
5.49
|
|
16
|
-13.77
|
-13.43
|
|
17
|
-9.52
|
-6.51
|
|
18
|
-1.50
|
-27.79
|
|
19
|
-23.73
|
-13.58
|
|
20
|
-1.17
|
-16.49
|
|
21
|
-5.01
|
-11.63
|
|
22
|
-3.43
|
-13.56
|
|
23
|
-25.15
|
-13.92
|
|
24
|
-31.06
|
-5.81
|
|
25
|
-31.76
|
-8.65
|
|
26
|
-9.15
|
-11.94
|
|
27
|
-39.94
|
-8.51
|
|
28
|
-6.01
|
2.52
|
|
29
|
-18.49
|
-15.90
|
|
30
|
-16.37
|
-14.65
|
|
31
|
-25.84
|
-1.88
|
|
32
|
27.99
|
9.43
|
|
33
|
-8.14
|
52.61
|
|
34
|
-4.21
|
-8.32
|
|
35
|
-0.52
|
-36.53
|
|
36
|
-7.34
|
-20.59
|
|
37
|
-25.44
|
-7.94
|
|
38
|
-29.70
|
33.91
|
|
39
|
-52.48
|
-8.63
|
|
40
|
-13.68
|
0.13
|
|
41
|
-16.27
|
4.49
|
2. ANALISIS DE RASMUSSEN
1990
tabla_1990=mip_tabla_rasmussen(matriz_leontief = L_1990)%>%print()
## sector pd sd clasificacion
## 1 1 0.4738099 0.5377737 Sector Isla
## 2 2 0.5103989 0.5431585 Sector Isla
## 3 3 0.7498101 0.5405244 Sector Isla
## 4 4 0.6474832 0.6718479 Sector Isla
## 5 5 0.5953563 0.4818147 Sector Isla
## 6 6 0.9345096 0.6191023 Sector Isla
## 7 7 0.4796003 0.7576287 Sector Isla
## 8 8 0.5339693 0.4411965 Sector Isla
## 9 9 0.4640698 0.5928952 Sector Isla
## 10 10 1.5729999 0.4487713 Sector Impulsor
## 11 11 0.5242181 0.7859308 Sector Isla
## 12 12 0.4854652 0.7662982 Sector Isla
## 13 13 0.4311308 0.4538262 Sector Isla
## 14 14 0.6823240 0.7710486 Sector Isla
## 15 15 0.5118341 0.7885595 Sector Isla
## 16 16 0.9530260 0.6654498 Sector Isla
## 17 17 0.5370545 0.5852182 Sector Isla
## 18 18 0.4352191 0.5933068 Sector Isla
## 19 19 0.8263179 0.6451216 Sector Isla
## 20 20 0.4414599 0.7037213 Sector Isla
## 21 21 0.5096526 0.6763795 Sector Isla
## 22 22 0.4912877 0.5833802 Sector Isla
## 23 23 1.1553830 0.7134494 Sector Impulsor
## 24 24 1.1735183 0.6203589 Sector Impulsor
## 25 25 1.3499915 0.5688198 Sector Impulsor
## 26 26 2.9928433 0.6035863 Sector Impulsor
## 27 27 1.1154436 0.5977987 Sector Impulsor
## 28 28 0.6880895 0.6253106 Sector Isla
## 29 29 0.9416781 1.0140442 Sector Estrategico
## 30 30 0.6406108 0.5567087 Sector Isla
## 31 31 0.8853062 0.4752828 Sector Isla
## 32 32 0.9364251 0.6219254 Sector Isla
## 33 33 0.5045891 0.5964451 Sector Isla
## 34 34 0.5309331 0.7827303 Sector Isla
## 35 35 0.4573997 16.0412883 Sector Estrategico
## 36 36 0.5535413 0.7010228 Sector Isla
## 37 37 5.9198052 0.6502997 Sector Impulsor
## 38 38 0.9694733 0.5390206 Sector Isla
## 39 39 1.5926642 0.5798107 Sector Impulsor
## 40 40 3.2276126 0.5013313 Sector Impulsor
## 41 41 1.5736950 0.5578123 Sector Impulsor
tabla_1990=tabla_1990%>%group_by(clasificacion)%>%summarise(total=n())%>%mutate(porcetaje_1990=round(prop.table(total)*100,2))
tabla_1990%>%kable(aption="Analisis de rasmuseen MIP 1990",align = "c",digits = 2) %>%
kable_material(html_font = "sans-serif") %>%
kable_styling(bootstrap_options = c("striped", "hover"))
|
clasificacion
|
total
|
porcetaje_1990
|
|
Sector Estrategico
|
2
|
4.88
|
|
Sector Impulsor
|
10
|
24.39
|
|
Sector Isla
|
29
|
70.73
|
2006
tabla_2006=mip_tabla_rasmussen(matriz_leontief = L_2006)
tabla_2006=tabla_2006%>%group_by(clasificacion)%>%summarise(total=n())%>%mutate(porcetaje_2006=round(prop.table(total)*100,2))
tabla_2006%>%kable(aption="Analisis de rasmuseen MIP 2006",align = "c",digits = 2) %>%
kable_material(html_font = "sans-serif") %>%
kable_styling(bootstrap_options = c("striped", "hover"))
|
clasificacion
|
total
|
porcetaje_2006
|
|
Sector Estrategico
|
4
|
9.76
|
|
Sector Impulsor
|
8
|
19.51
|
|
Sector Isla
|
29
|
70.73
|
3.TABLA COMPARATIVA.
tabla3=left_join(tabla_1990,tabla_2006,by="clasificacion", suffix=c("_1990","_2006"))
tabla3%>%mutate(dif_variacion=round((porcetaje_2006/porcetaje_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"))
|
clasificacion
|
total_1990
|
porcetaje_1990
|
total_2006
|
porcetaje_2006
|
dif_variacion
|
|
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
|