—————————————————-PARTE 1 DEL
EJERCICIO—————————————————————————
————————————————– PUNTO 1: SOMULAR LA
TRM——————————————————————–
# Preparar entorno
options(scipen = 999)
set.seed(123456)
# Parámetros de la simulación (mensuales)
s0 <- 3921.58 # valor inicial TRM
mu <- 0.002342942 # retorno medio mensual
sigma <- 0.029596084 # desviación estándar mensual
N <- 500 # número de trayectorias
T <- 72 # meses (6 años)
vec = rep (s0 , N)
mb = matrix ( ncol =N , nrow =T )
mb [1 ,]= vec
k= seq (s0 -30 , s0 +30 ,1)
length (k )
## [1] 61
for (i in 1: N) {
for (t in 2: T) {
mb [t,i ]= mb [(t -1) ,i]* exp (( mu -(0.5 *( sigma ^2) ))*(1/ 360) +
sigma *(1/ (360) ^(1 /2) )* qnorm ( runif (1 , min = 0, max = 1) ))
}
}
matplot (mb , type ="l")

q1 = quantile ( mb [T ,] , 0.975)
q2 = quantile ( mb [T ,] , 0.025)
plot ( density ( mb [T ,]) , ylab ="", xlab ="",
main =" Empirical ␣ distribution ", lwd = 3)
abline (h = NULL , v =q1 , col = " blue ", lwd = 2)
abline (h = NULL , v =q2 , col = " green ", lwd = 2)

——————————————————– PUNTO 2: CREDITO EN USD Y AMORTIZACION
—————————————————-
# Parámetros del crédito
credito_cop <- 300000000 # Valor total en COP
pago_inicial <- 0.10 # 10% pago inicial
s0 <- 3921.58 # TRM hoy
credito_usd <- (credito_cop * (1 - pago_inicial)) / s0 # Monto financiado en USD
tasa_mensual <- 0.0044 # 0.44% efectiva mensual
n <- 72 # Plazo en meses
# Cuota fija en USD con sistema francés
cuota_usd <- credito_usd * (tasa_mensual * (1 + tasa_mensual)^n) / ((1 + tasa_mensual)^n - 1)
# Tabla de amortización
saldo <- credito_usd
tabla <- data.frame(
Mes = integer(),
Saldo = numeric(),
Interes = numeric(),
Cuota = numeric(),
Amortizacion = numeric()
)
for (t in 1:n) {
interes <- saldo * tasa_mensual
amortizacion <- cuota_usd - interes
saldo <- saldo - amortizacion
tabla <- rbind(
tabla,
data.frame(
Mes = t,
Saldo = ifelse(saldo < 0, 0, saldo + amortizacion), # Saldo al inicio del período
Interes = interes,
Cuota = cuota_usd,
Amortizacion = amortizacion
)
)
}
# Mostrar tabla en R
print(tabla)
## Mes Saldo Interes Cuota Amortizacion
## 1 1 68849.800 302.939121 1117.786 814.8467
## 2 2 68034.954 299.353796 1117.786 818.4320
## 3 3 67216.522 295.752695 1117.786 822.0331
## 4 4 66394.489 292.135750 1117.786 825.6500
## 5 5 65568.839 288.502890 1117.786 829.2829
## 6 6 64739.556 284.854045 1117.786 832.9317
## 7 7 63906.624 281.189145 1117.786 836.5966
## 8 8 63070.027 277.508120 1117.786 840.2777
## 9 9 62229.750 273.810898 1117.786 843.9749
## 10 10 61385.775 270.097409 1117.786 847.6884
## 11 11 60538.086 266.367580 1117.786 851.4182
## 12 12 59686.668 262.621340 1117.786 855.1644
## 13 13 58831.504 258.858616 1117.786 858.9272
## 14 14 57972.577 255.079337 1117.786 862.7064
## 15 15 57109.870 251.283428 1117.786 866.5024
## 16 16 56243.368 247.470818 1117.786 870.3150
## 17 17 55373.053 243.641432 1117.786 874.1444
## 18 18 54498.908 239.795197 1117.786 877.9906
## 19 19 53620.918 235.932039 1117.786 881.8537
## 20 20 52739.064 232.051882 1117.786 885.7339
## 21 21 51853.330 228.154653 1117.786 889.6311
## 22 22 50963.699 224.240276 1117.786 893.5455
## 23 23 50070.154 220.308676 1117.786 897.4771
## 24 24 49172.676 216.359776 1117.786 901.4260
## 25 25 48271.250 212.393502 1117.786 905.3923
## 26 26 47365.858 208.409776 1117.786 909.3760
## 27 27 46456.482 204.408522 1117.786 913.3773
## 28 28 45543.105 200.389662 1117.786 917.3961
## 29 29 44625.709 196.353119 1117.786 921.4327
## 30 30 43704.276 192.298815 1117.786 925.4870
## 31 31 42778.789 188.226672 1117.786 929.5591
## 32 32 41849.230 184.136612 1117.786 933.6492
## 33 33 40915.581 180.028556 1117.786 937.7572
## 34 34 39977.824 175.902424 1117.786 941.8834
## 35 35 39035.940 171.758137 1117.786 946.0276
## 36 36 38089.913 167.595616 1117.786 950.1902
## 37 37 37139.722 163.414779 1117.786 954.3710
## 38 38 36185.351 159.215546 1117.786 958.5702
## 39 39 35226.781 154.997837 1117.786 962.7879
## 40 40 34263.993 150.761570 1117.786 967.0242
## 41 41 33296.969 146.506664 1117.786 971.2791
## 42 42 32325.690 142.233036 1117.786 975.5527
## 43 43 31350.137 137.940604 1117.786 979.8452
## 44 44 30370.292 133.629285 1117.786 984.1565
## 45 45 29386.136 129.298996 1117.786 988.4868
## 46 46 28397.649 124.949654 1117.786 992.8361
## 47 47 27404.813 120.581175 1117.786 997.2046
## 48 48 26407.608 116.193475 1117.786 1001.5923
## 49 49 25406.016 111.786469 1117.786 1005.9993
## 50 50 24400.016 107.360072 1117.786 1010.4257
## 51 51 23389.591 102.914199 1117.786 1014.8716
## 52 52 22374.719 98.448764 1117.786 1019.3370
## 53 53 21355.382 93.963681 1117.786 1023.8221
## 54 54 20331.560 89.458864 1117.786 1028.3269
## 55 55 19303.233 84.934225 1117.786 1032.8516
## 56 56 18270.381 80.389678 1117.786 1037.3961
## 57 57 17232.985 75.825136 1117.786 1041.9606
## 58 58 16191.025 71.240509 1117.786 1046.5453
## 59 59 15144.479 66.635710 1117.786 1051.1501
## 60 60 14093.329 62.010649 1117.786 1055.7751
## 61 61 13037.554 57.365239 1117.786 1060.4205
## 62 62 11977.134 52.699388 1117.786 1065.0864
## 63 63 10912.047 48.013008 1117.786 1069.7728
## 64 64 9842.275 43.306008 1117.786 1074.4798
## 65 65 8767.795 38.578297 1117.786 1079.2075
## 66 66 7688.587 33.829784 1117.786 1083.9560
## 67 67 6604.631 29.060378 1117.786 1088.7254
## 68 68 5515.906 24.269986 1117.786 1093.5158
## 69 69 4422.390 19.458516 1117.786 1098.3273
## 70 70 3324.063 14.625876 1117.786 1103.1599
## 71 71 2220.903 9.771973 1117.786 1108.0138
## 72 72 0.000 4.896712 1117.786 1112.8891
————————————— PUNTO 3: SELECCION DE TRAYECTORIAS Y AMORTIZACION
(LARGO, MEDIO,CORTO)————————————
Tomamos el valor final de cada trayectoria
finales <- mb[nrow(mb), ]
# Identificar las trayectorias
idx_larga <- which.max(finales) # TRM más alta al final (devaluación más fuerte)
idx_corta <- which.min(finales) # TRM más baja al final (apreciación del COP)
idx_media <- order(finales)[length(finales) %/% 2] # TRM intermedia
# Extraer las trayectorias
trm_larga <- mb[, idx_larga]
trm_corta <- mb[, idx_corta]
trm_media <- mb[, idx_media]
# --- Función para convertir tabla en USD a COP ---
convertir_a_cop <- function(trm, tabla_usd) {
data.frame(
Saldo = tabla_usd$Saldo * trm,
Interes = tabla_usd$Interes * trm,
Cuota = tabla_usd$Cuota * trm,
Amortizacion = tabla_usd$Amortizacion * trm
)
}
#LARGO
tabla_cop_larga <- convertir_a_cop(trm_larga, tabla)
head(tabla_cop_larga, 72)
## Saldo Interes Cuota Amortizacion
## 1 270000000 1188000.00 4383486 3195486
## 2 267251332 1175905.86 4390827 3214922
## 3 263799630 1160718.37 4386890 3226171
## 4 260478229 1146104.21 4385287 3239182
## 5 257295299 1132099.31 4386246 3254146
## 6 254314321 1118983.01 4390962 3271979
## 7 251925409 1108471.80 4406408 3297936
## 8 248575256 1093731.13 4405482 3311751
## 9 245492652 1080167.67 4409598 3329431
## 10 242478636 1066906.00 4415342 3348436
## 11 239399794 1053359.09 4420320 3366960
## 12 236269891 1039587.52 4424759 3385172
## 13 233800347 1028721.53 4442156 3413434
## 14 230716911 1015154.41 4448519 3433364
## 15 227061982 999072.72 4444182 3445109
## 16 223774684 984608.61 4447318 3462710
## 17 220511102 970248.85 4451338 3481089
## 18 217064474 955083.69 4452045 3496961
## 19 213555907 939645.99 4451803 3512157
## 20 209670975 922552.29 4443902 3521350
## 21 206243101 907469.65 4445917 3538447
## 22 203112309 893694.16 4454858 3561164
## 23 199943996 879753.58 4463628 3583875
## 24 195873105 861841.66 4452558 3590716
## 25 192365622 846408.74 4454485 3608076
## 26 188701660 830287.31 4453166 3622879
## 27 185213605 814939.86 4456410 3641470
## 28 182513059 803057.46 4479504 3676446
## 29 178616247 785911.49 4473984 3688072
## 30 174771186 768993.22 4469969 3700976
## 31 171143558 753031.66 4471885 3718854
## 32 167687339 737824.29 4478900 3741076
## 33 164160142 722304.62 4484743 3762439
## 34 160244227 705074.60 4480452 3775377
## 35 156551071 688824.71 4482806 3793982
## 36 152406666 670589.33 4472523 3801934
## 37 149084280 655970.83 4486956 3830985
## 38 145140120 638616.53 4483460 3844843
## 39 141514546 622664.00 4490417 3867753
## 40 137775326 606211.44 4494610 3888399
## 41 134009447 589641.57 4498723 3909082
## 42 130604315 574658.99 4516149 3941490
## 43 126364203 556002.49 4505502 3949500
## 44 122725137 539990.60 4516928 3976937
## 45 119007836 523634.48 4526804 4003169
## 46 115346359 507523.98 4540253 4032729
## 47 111294965 489697.85 4539492 4049794
## 48 107221726 471775.59 4538500 4066724
## 49 103483154 455325.88 4552937 4097611
## 50 99350567 437142.49 4551335 4114193
## 51 95193073 418849.52 4549266 4130416
## 52 91064547 400684.01 4549360 4148676
## 53 86944739 382556.85 4550871 4168314
## 54 82834398 364471.35 4554058 4189587
## 55 78763430 346559.09 4560927 4214368
## 56 74512667 327855.73 4558701 4230845
## 57 70510274 310245.20 4573519 4263274
## 58 66358424 291977.07 4581211 4289234
## 59 62067068 273095.10 4581055 4307959
## 60 57813949 254381.38 4585404 4331023
## 61 53520107 235488.47 4588592 4353103
## 62 49239518 216653.88 4595359 4378706
## 63 44897906 197550.79 4599159 4401608
## 64 40519524 178285.91 4601797 4423511
## 65 35983105 158325.66 4587402 4429077
## 66 31603945 139057.36 4594659 4455602
## 67 27244956 119877.81 4611011 4491133
## 68 22718564 99961.68 4603865 4503904
## 69 18261031 80348.54 4615586 4535237
## 70 13705137 60302.60 4608639 4548337
## 71 9165529 40328.33 4613033 4572705
## 72 0 20148.86 4599434 4579286
#TRAYECTORIA MEDIA
tabla_cop_media <- convertir_a_cop(trm_media, tabla)
head(tabla_cop_media, 72)
## Saldo Interes Cuota Amortizacion
## 1 270000000 1188000.00 4383486 3195486
## 2 266851349 1174145.93 4384256 3210110
## 3 263114884 1157705.49 4375503 3217797
## 4 259728899 1142807.16 4372671 3229864
## 5 256390933 1128120.11 4370828 3242708
## 6 253559598 1115662.23 4377931 3262269
## 7 250817423 1103596.66 4387028 3283431
## 8 247727612 1090001.49 4390460 3300458
## 9 244481554 1075718.84 4391437 3315718
## 10 241538577 1062769.74 4398224 3335454
## 11 237833785 1046468.65 4391404 3344936
## 12 234732517 1032823.07 4395968 3363145
## 13 231131886 1016980.30 4391456 3374475
## 14 227619138 1001524.21 4388790 3387265
## 15 224131210 986177.33 4386819 3400642
## 16 220498760 970194.55 4382212 3412018
## 17 217194991 955657.96 4384397 3428740
## 18 213422178 939057.58 4377340 3438283
## 19 209970843 923871.71 4377068 3453197
## 20 206870723 910231.18 4384552 3474321
## 21 204077657 897941.69 4399237 3501296
## 22 200585744 882577.28 4399443 3516866
## 23 196941524 866542.71 4396600 3530057
## 24 193721144 852373.04 4403640 3551266
## 25 190137926 836606.87 4402900 3566293
## 26 186763402 821758.97 4407425 3585666
## 27 183192385 806046.49 4407778 3601731
## 28 179678684 790586.21 4409938 3619352
## 29 175795206 773498.91 4403322 3629823
## 30 171894545 756336.00 4396395 3640059
## 31 168181541 739998.78 4394489 3654491
## 32 164291454 722882.40 4388197 3665314
## 33 160502672 706211.76 4384824 3678612
## 34 156688674 689430.17 4381038 3691608
## 35 152800936 672324.12 4375422 3703098
## 36 149049065 655815.89 4373991 3718175
## 37 145101688 638447.43 4367093 3728645
## 38 141335372 621875.64 4365929 3744053
## 39 137781652 606239.27 4371968 3765729
## 40 134467629 591657.57 4386704 3795047
## 41 130789779 575475.03 4390639 3815164
## 42 127169889 559547.51 4397391 3837843
## 43 123161457 541910.41 4391309 3849398
## 44 119235774 524637.41 4388501 3863863
## 45 115321509 507414.64 4386584 3879169
## 46 111298758 489714.54 4380932 3891218
## 47 107409334 472601.07 4381005 3908404
## 48 103512719 455455.96 4381504 3926048
## 49 99622490 438338.96 4383080 3944741
## 50 95858101 421775.65 4391342 3969567
## 51 92043633 404991.99 4398754 3993762
## 52 88132930 387784.89 4402904 4015119
## 53 84273957 370805.41 4411077 4040271
## 54 80279456 353229.61 4413593 4060364
## 55 76347720 335929.97 4421042 4085112
## 56 72164444 317523.55 4415036 4097512
## 57 68134854 299793.36 4419442 4119648
## 58 63852352 280950.35 4408199 4127248
## 59 59672759 262560.14 4404335 4141775
## 60 55451546 243986.80 4398035 4154048
## 61 51394031 226133.73 4406311 4180177
## 62 47150934 207464.11 4400439 4192975
## 63 42939401 188933.36 4398538 4209604
## 64 38674419 170167.44 4392248 4222081
## 65 34460217 151624.95 4393253 4241628
## 66 30248330 133092.65 4397577 4264484
## 67 25936846 114122.12 4389623 4275500
## 68 21653287 95274.46 4387989 4292715
## 69 17350737 76343.24 4385503 4309160
## 70 13047155 57407.48 4387379 4329972
## 71 8711101 38328.85 4384318 4345989
## 72 0 19243.62 4392793 4373549
#CORTO
tabla_cop_corta <- convertir_a_cop(trm_corta, tabla)
head(tabla_cop_corta, 72)
## Saldo Interes Cuota Amortizacion
## 1 270000000 1188000.00 4383486 3195486
## 2 267153114 1175473.70 4389214 3213740
## 3 264029940 1161731.73 4390720 3228988
## 4 260853870 1147757.03 4391611 3243854
## 5 256830118 1130052.52 4378315 3248263
## 6 253453728 1115196.41 4376103 3260907
## 7 250215559 1100948.46 4376501 3275552
## 8 246486187 1084539.22 4368458 3283919
## 9 242914183 1068822.40 4363283 3294461
## 10 240005341 1056023.50 4370305 3314282
## 11 236289271 1039672.79 4362886 3323214
## 12 233045772 1025401.40 4364379 3338978
## 13 229789993 1011075.97 4365960 3354884
## 14 225760402 993345.77 4352951 3359605
## 15 222298324 978112.62 4350945 3372832
## 16 219181699 964399.48 4356037 3391637
## 17 215744712 949276.73 4355121 3405845
## 18 212632148 935581.45 4361137 3425555
## 19 208882840 919084.50 4354388 3435303
## 20 205662385 904914.49 4358941 3454027
## 21 202163344 889518.71 4357971 3468452
## 22 199002310 875610.16 4364714 3489103
## 23 195704449 861099.57 4368983 3507883
## 24 191832860 844064.58 4360715 3516651
## 25 188309748 828562.89 4360566 3532003
## 26 184911981 813612.71 4363734 3550121
## 27 181015516 796468.27 4355400 3558932
## 28 177589036 781391.76 4358651 3577259
## 29 173958394 765416.93 4357314 3591897
## 30 170560616 750466.71 4362279 3611812
## 31 167136597 735401.03 4367186 3631785
## 32 163236611 718241.09 4360022 3641781
## 33 159235302 700635.33 4350200 3649565
## 34 155299908 683319.59 4342208 3658888
## 35 151643912 667233.21 4342291 3675058
## 36 147844094 650514.01 4338630 3688116
## 37 143997421 633588.65 4333858 3700269
## 38 139946197 615763.27 4323016 3707253
## 39 136048630 598613.97 4316978 3718364
## 40 131905669 580384.94 4303126 3722741
## 41 128177736 563982.04 4302952 3738970
## 42 124534013 547949.66 4306245 3758296
## 43 120788455 531469.20 4306699 3775230
## 44 116866145 514211.04 4301286 3787075
## 45 112912329 496814.25 4294944 3798129
## 46 109060230 479865.01 4292819 3812954
## 47 105398206 463752.10 4298975 3835223
## 48 101584487 446971.74 4299886 3852914
## 49 97680393 429793.73 4297634 3867840
## 50 93931227 413297.40 4303070 3889773
## 51 90016477 396072.50 4301877 3905804
## 52 86244764 379476.96 4308576 3929099
## 53 82093949 361213.37 4296971 3935757
## 54 77906655 342789.28 4283142 3940352
## 55 73928744 325286.47 4280967 3955680
## 56 69856730 307369.61 4273849 3966480
## 57 65888842 289910.91 4273758 3983847
## 58 61836631 272081.18 4269038 3996957
## 59 57767379 254176.47 4263703 4009526
## 60 53701801 236287.92 4259257 4022969
## 61 49576166 218135.13 4250455 4032320
## 62 45572280 200518.03 4253108 4052590
## 63 41480220 182512.97 4249065 4066552
## 64 37429365 164689.21 4250848 4086159
## 65 33386148 146899.05 4256322 4109423
## 66 29250704 128703.10 4252540 4123836
## 67 25077343 110340.31 4244158 4133818
## 68 20939496 92133.78 4243341 4151207
## 69 16742158 73665.49 4231681 4158016
## 70 12581772 55359.80 4230884 4175525
## 71 8384934 36893.71 4220158 4183264
## 72 0 18454.70 4212705 4194250
——————————————————– PARTE 2 DEL EJERCICIO
——————————————————————–
# Preparar entorno
options(scipen = 999)
set.seed(123456)
# Parámetros de la simulación (mensuales)
s0 <- 3947 # valor inicial del futuro
mu <- -0.0164 # retorno medio mensual
sigma <- 0.0299 # desviación estándar mensual
N <- 500 # número de trayectorias
T <- 72 # meses totales (6 años)
# Inicializar matriz de simulación
vec <- rep(s0, N)
mb <- matrix(ncol = N, nrow = T)
mb[1, ] <- vec
# Simulación de trayectorias BMG mensual
for (i in 1:N) {
for (t in 2:T) {
mb[t, i] <- mb[t - 1, i] * exp((mu - 0.5 * sigma^2) * 1 +
sigma * sqrt(1) * rnorm(1))
}
}
# Extraer solo meses 37 a 72
mb_sub <- mb[37:72, ]
# Calcular estadísticas por mes
p10 <- apply(mb_sub, 1, quantile, probs = 0.10)
p50 <- apply(mb_sub, 1, quantile, probs = 0.50) # mediana
p90 <- apply(mb_sub, 1, quantile, probs = 0.90)
media <- apply(mb_sub, 1, mean)
# Crear data frame con resultados
df_futuro <- data.frame(
Mes_Absoluto = 37:72, # mes dentro de los 72 totales
Mes_Relativo = 1:36, # mes relativo al subperiodo
P10 = round(p10, 4),
Mediana = round(p50, 4),
P90 = round(p90, 4),
Media = round(media, 4)
)
# Mostrar en consola
print(df_futuro)
## Mes_Absoluto Mes_Relativo P10 Mediana P90 Media
## 1 37 1 1713.0104 2149.611 2694.320 2193.630
## 2 38 2 1701.7978 2115.530 2653.144 2155.130
## 3 39 3 1665.0674 2091.999 2611.980 2122.961
## 4 40 4 1643.7221 2048.261 2560.121 2088.601
## 5 41 5 1601.2367 2012.643 2527.900 2051.460
## 6 42 6 1572.2060 1987.525 2490.902 2017.311
## 7 43 7 1528.2808 1950.280 2468.732 1986.596
## 8 44 8 1504.7385 1919.655 2435.794 1956.418
## 9 45 9 1478.3354 1883.180 2400.878 1926.094
## 10 46 10 1447.5499 1853.451 2356.118 1894.191
## 11 47 11 1439.3974 1823.874 2354.773 1869.268
## 12 48 12 1412.7454 1804.890 2300.280 1838.158
## 13 49 13 1381.1684 1781.006 2270.780 1807.731
## 14 50 14 1372.6939 1742.849 2243.545 1777.219
## 15 51 15 1349.2013 1717.696 2203.971 1750.737
## 16 52 16 1310.3206 1694.187 2161.612 1723.055
## 17 53 17 1279.3292 1658.189 2156.208 1692.616
## 18 54 18 1276.6049 1624.605 2129.355 1662.417
## 19 55 19 1233.7669 1597.217 2072.175 1632.530
## 20 56 20 1222.4493 1576.264 2037.046 1607.023
## 21 57 21 1192.9219 1538.385 2011.790 1579.512
## 22 58 22 1177.0851 1519.358 1967.555 1555.172
## 23 59 23 1147.3320 1496.895 1964.018 1533.631
## 24 60 24 1123.7747 1485.367 1953.510 1514.528
## 25 61 25 1107.2298 1459.795 1899.001 1490.780
## 26 62 26 1090.7268 1439.811 1875.004 1466.384
## 27 63 27 1058.6761 1411.117 1853.424 1443.005
## 28 64 28 1045.1061 1380.151 1826.215 1418.481
## 29 65 29 1023.5776 1349.435 1804.840 1391.239
## 30 66 30 1009.3553 1339.998 1771.937 1366.049
## 31 67 31 966.2454 1317.225 1749.744 1344.875
## 32 68 32 964.3829 1308.927 1713.828 1323.852
## 33 69 33 938.4152 1279.552 1691.992 1301.067
## 34 70 34 936.7451 1245.144 1692.642 1282.031
## 35 71 35 903.1901 1221.802 1664.304 1258.386
## 36 72 36 892.9537 1208.017 1634.454 1237.969
# Si usas RStudio, esto abre la tabla en el visor
View(df_futuro)
# Supongamos que ya tienes la matriz mb con 72 meses simulados x N trayectorias
# Seleccionemos una trayectoria de ejemplo (por ejemplo la primera)
trayectoria <- mb[37:72, 1] # meses 37 a 72
# Definir parámetros del contrato
tam_contrato <- 50000 # USD por contrato
margen_inicial_pct <- 0.063 # 6.3% garantía inicial según BVC
margen_mantenimiento_pct <- 0.75 # asumimos 75% del inicial
# Construir el data frame con los meses 37 a 72
df_expo <- data.frame(
Mes = 37:72,
TRM = trayectoria,
Exposicion = trayectoria * tam_contrato,
Margen_Inicial = trayectoria * tam_contrato * margen_inicial_pct,
Margen_Mantenimiento = trayectoria * tam_contrato * margen_inicial_pct * margen_mantenimiento_pct
)
# Mostrar primeras filas
head(df_expo, 10)
## Mes TRM Exposicion Margen_Inicial Margen_Mantenimiento
## 1 37 2555.293 127764674 8049174 6036881
## 2 38 2632.585 131629255 8292643 6219482
## 3 39 2668.377 133418850 8405388 6304041
## 4 40 2706.994 135349708 8527032 6395274
## 5 41 2574.425 128721260 8109439 6082080
## 6 42 2451.616 122580785 7722589 5791942
## 7 43 2481.438 124071886 7816529 5862397
## 8 44 2452.493 122624641 7725352 5794014
## 9 45 2347.756 117387814 7395432 5546574
## 10 46 2319.487 115974338 7306383 5479787