Problema:
La criptomoneda Ethereum presenta fluctuaciones significativas en su valor a lo largo del tiempo. Estas variaciones, aunque impulsadas por múltiples factores, pueden tener patrones subyacentes que, si se identifican, podrían proporcionar una visión valiosa para futuras tendencias de precios.
Objetivo:
Realizar un análisis de series temporales sobre los datos diarios de Ethereum con un enfoque académico. Identificar patrones y tendencias para prever movimientos de precios y apoyar decisiones de inversión informadas.’
Marco teórico:
Ethereum: Una Revolución en la Tecnología Blockchain Definiendo Ethereum
Ethereum no se puede describir simplemente como una moneda digital o una tecnología emergente. Representa una reconfiguración fundamental de cómo entendemos las transacciones y operaciones digitales. Al mirar su infraestructura, vemos una red global descentralizada compuesta por máquinas distribuidas, todas operando con un protocolo unificado y sin un único centro o propietario. Esta estructura descentralizada representa un alejamiento significativo de las operaciones tradicionales centralizadas.
Sin embargo, es crucial no confundir Ethereum con una simple criptomoneda. Ethereum es un entorno de software que distingue por ejecutar aplicaciones no en servidores individuales, sino a través de la misma red, brindando mayor confiabilidad.
Ether: El Pulso de Ethereum
Aunque Ethereum es la estructura, Ether es el latido del corazón. Es la moneda que energiza la red, recompensando a los usuarios por contribuir con poder computacional. Las tareas computacionales son vitales para mantener la red operativa, y Ether actúa como un incentivo para garantizar una participación continua.
Dinero Programable y Contratos Inteligentes
Ethereum ha llevado a la noción de “dinero programable” a la vanguardia. Dentro de su cadena de bloques, opera con contratos inteligentes que actúan como acuerdos autoejecutables. Estos contratos, esencialmente, cumplen con términos y condiciones sin la necesidad de intermediarios. Esta autonomía no sólo reduce el riesgo de interferencia humana sino que también garantiza la ejecución del contrato siempre que se cumplan las condiciones preestablecidas.
Tokens de Ethereum y la Revolución ERC-20
A diferencia de muchas otras redes blockchain, Ethereum permite la creación de tokens personalizados dentro de su estructura. Estos tokens, respaldados por contratos inteligentes, pueden representar cualquier activo o valor. La versatilidad de este sistema ha dado origen a una multitud de tokens, siendo el ERC-20 uno de los más destacados y utilizados en la actualidad.
Ethereum en Funcionamiento
El funcionamiento interno de Ethereum es una danza compleja pero bien coreografiada de contratos inteligentes y transacciones. Cada vez que se activa una transacción, se ejecuta a través de la Máquina Virtual Ethereum, y cada nodo en la red registra y refleja esta transacción. Esta armonía asegura un registro distribuido y confiable de todas las transacciones.
El Gas: El Combustible de Ethereum
Para garantizar una operación fluida y evitar congestiones, Ethereum utiliza un sistema llamado gas. Este sistema funciona como una tarifa de transacción, donde se asigna un valor a las operaciones basado en su complejidad. Así, las operaciones más complejas y que consumen más recursos tendrán un costo más elevado, asegurando un equilibrio y una gestión eficiente de los recursos de la red.
Métodos de Análisis de Series Temporales: El Enfoque de Prophet Introducción al Análisis de Series Temporales
Antes de sumergirnos en Prophet, es esencial entender el vasto paisaje del análisis de series temporales. Una serie temporal es una sucesión de datos medidos en momentos consecutivos a lo largo del tiempo, generalmente a intervalos uniformes. Estas series se utilizan ampliamente en estadísticas, economía y negocios, y tienen aplicaciones en diversos campos, desde el análisis de las tendencias del mercado de valores hasta la predicción del clima.
El análisis de series temporales tiene como objetivo descomponer estas series para entender o prever una tendencia futura. Para ello, se utilizan diversos métodos y técnicas que van desde modelos estadísticos simples hasta algoritmos complejos de aprendizaje automático.
Prophet: Una Herramienta Revolucionaria para Series Temporales
Prophet, desarrollado por el equipo de Facebook, ha emergido como una herramienta poderosa y versátil para el análisis y pronóstico de series temporales. A diferencia de muchos métodos tradicionales que requieren una configuración detallada y pueden ser fácilmente perturbados por anomalías en los datos, Prophet es robusto ante la falta de datos y cambios en las tendencias, lo que lo hace particularmente útil en el mundo real donde los datos a menudo no son perfectos.
Características distintivas de Prophet:
Flexibilidad: Prophet no asume un modelo lineal o no lineal previo. En su lugar, identifica automáticamente las tendencias al adaptarse a las estacionalidades anuales, semanales y diarias de los datos.
Tratamiento de días festivos: Una característica única de Prophet es su capacidad para modelar los efectos de los días festivos en una serie temporal.
Componentes Adicionales: Además de las tendencias y estacionalidades, Prophet permite incorporar componentes adicionales, como eventos especiales, que pueden influir en las series temporales.
Facilidad de Uso: A pesar de su complejidad subyacente, Prophet es sorprendentemente fácil de usar, incluso para aquellos sin un profundo conocimiento en análisis de series temporales.
Prophet en el Contexto de Ethereum
Dada la naturaleza volátil y dinámica de las criptomonedas, las herramientas tradicionales de análisis de series temporales a menudo no son suficientes para prever sus movimientos con precisión. Aquí es donde Prophet brilla. Al considerar la historia de precios de Ethereum y teniendo en cuenta sus peculiaridades, Prophet puede ofrecer predicciones más precisas y detalladas sobre movimientos futuros, brindando así una herramienta valiosa para inversionistas y analistas.
Vistazo a los datos
etherium <- rio::import("https://github.com/EdwinHigueraA/bfi_s/raw/main/Etherium1.csv")
etherium <- na.omit(etherium)
cols_to_convert <- c("Open", "High", "Low", "Close")
for (col in cols_to_convert) {
etherium[[col]] <- as.numeric(gsub(",", "", etherium[[col]]))
}## Date Open High Low Close
## 1 1/1/2020 128.41 132.86 127.93 131.52
## 2 1/2/2020 131.52 131.52 126.18 127.44
## 3 1/3/2020 127.44 134.58 125.43 132.34
## 4 1/4/2020 132.34 135.58 131.94 133.93
## 5 1/5/2020 133.93 138.25 133.71 135.28
## 6 1/6/2020 135.06 142.86 134.01 141.50
## Date Open High Low Close
## 1402 11/2/2023 1857.41 1874.79 1788.22 1805.63
## 1403 11/3/2023 1805.01 1833.61 1779.62 1829.48
## 1404 11/4/2023 1829.09 1848.00 1825.48 1839.54
## 1405 11/5/2023 1839.54 1912.50 1839.54 1869.71
## 1406 11/6/2023 1869.11 1914.73 1869.11 1891.66
## 1407 11/7/2023 1892.75 1907.49 1851.63 1893.34
## Time Series:
## Start = c(2020, 1)
## End = c(2023, 312)
## Frequency = 365
## [1] 131.52 127.44 132.34 133.93 135.28 141.50 142.54 139.12 136.75
## [10] 142.96 144.11 144.53 144.17 163.72 165.28 163.23 170.87 176.46
## [19] 165.71 167.04 168.91 167.55 162.28 163.10 161.29 167.11 171.11
## [28] 172.37 175.82 184.77 180.64 182.30 191.67 189.48 187.38 206.36
## [37] 213.35 219.42 223.21 225.20 222.31 237.20 270.00 262.80 282.92
## [46] 268.28 251.90 260.41 280.87 262.99 259.63 263.06 262.88 271.70
## [55] 261.86 249.90 223.79 226.19 226.49 223.51 214.38 232.68 223.91
## [64] 222.80 231.10 240.83 238.78 209.61 198.36 202.76 192.70 128.64
## [73] 128.62 127.62 120.10 109.21 119.22 116.41 137.25 125.21 135.46
## [82] 124.20 132.20 139.86 135.45 136.79 137.43 131.17 125.59 134.04
## [91] 134.68 132.33 140.95 140.69 143.70 142.49 164.09 163.62 172.12
## [100] 170.73 159.09 154.72 163.91 156.73 159.28 157.77 172.50 170.84
## [109] 183.47 181.70 171.70 172.61 182.94 189.12 187.87 194.40 196.86
## [118] 193.67 196.59 217.00 211.80 209.77 214.15 207.98 207.89 205.40
## [127] 205.59 211.62 214.66 212.07 188.02 186.65 189.99 198.30 202.56
## [136] 193.24 200.11 208.06 212.65 212.41 210.40 199.05 208.24 208.02
## [145] 206.41 204.90 202.20 206.29 214.36 219.97 235.38 235.70 241.75
## [154] 236.64 241.63 241.91 241.00 242.17 241.85 242.10 243.52 247.75
## [163] 232.37 237.67 236.94 234.12 232.68 233.73 231.10 229.06 229.20
## [172] 227.58 228.99 244.65 243.52 234.60 233.61 230.27 218.60 224.85
## [181] 227.30 225.47 231.51 226.29 226.88 229.21 225.09 238.25 238.57
## [190] 246.24 241.31 239.29 238.71 238.76 238.87 241.35 238.17 232.61
## [199] 232.53 236.35 235.71 236.40 245.08 245.92 273.34 286.37 305.82
## [208] 310.92 324.25 319.74 322.64 339.11 345.73 386.82 374.39 390.64
## [217] 388.46 400.58 396.81 378.01 388.49 393.23 395.53 373.99 386.61
## [226] 409.80 438.99 432.50 430.72 437.85 427.07 404.40 416.30 395.03
## [235] 388.71 392.69 401.41 377.40 389.32 379.69 394.21 405.21 423.00
## [244] 432.33 482.44 436.64 405.90 391.78 333.29 351.89 344.70 335.66
## [253] 353.69 365.39 368.43 383.27 363.00 376.32 365.56 365.71 392.15
## [262] 380.61 386.03 369.60 346.59 344.85 321.90 345.66 354.90 353.68
## [271] 353.33 362.73 357.72 356.64 351.61 346.32 349.07 351.55 351.99
## [280] 337.25 340.51 351.65 364.05 374.58 373.72 387.64 380.19 376.73
## [289] 380.56 366.60 367.12 375.92 379.65 368.66 395.25 417.80 409.40
## [298] 412.01 408.10 392.90 403.95 385.94 389.05 384.31 387.94 396.63
## [307] 385.91 383.35 401.11 413.65 447.20 435.58 450.45 447.90 451.73
## [316] 467.16 462.55 472.28 460.06 444.00 459.25 480.99 474.31 472.98
## [325] 508.87 544.31 573.94 606.93 601.02 578.49 512.59 515.87 543.92
## [334] 566.54 605.20 604.51 604.51 615.43 581.81 592.41 599.42 588.61
## [343] 566.01 576.17 563.66 549.44 570.91 591.64 586.06 588.63 629.38
## [352] 641.26 651.36 666.95 634.80 618.46 622.83 597.37 605.10 618.92
## [361] 647.00 676.41 726.77 723.94 749.13 739.08 729.99 769.00 950.50
## [370] 1008.06 1086.64 1183.71 1251.50 1190.64 1292.24 1269.99 1035.10 1078.26
## [379] 1126.30 1189.00 1160.75 1228.99 1260.64 1234.03 1410.55 1323.76 1174.95
## [388] 1243.67 1248.50 1353.24 1345.18 1335.01 1275.28 1350.38 1375.79 1385.72
## [397] 1296.00 1348.97 1516.43 1633.45 1642.51 1721.71 1710.88 1602.50 1702.98
## [406] 1769.73 1727.99 1769.92 1851.59 1814.50 1828.54 1792.02 1753.24 1854.00
## [415] 1944.68 1957.91 1968.81 1922.80 1799.77 1539.99 1591.57 1526.11 1429.31
## [424] 1507.11 1416.12 1547.00 1467.94 1595.02 1516.45 1535.09 1642.70 1664.00
## [433] 1790.92 1825.00 1816.73 1840.50 1758.32 1911.71 1876.05 1791.32 1797.41
## [442] 1817.47 1774.49 1817.85 1827.61 1800.00 1678.35 1672.34 1615.01 1603.41
## [451] 1664.68 1718.50 1667.28 1806.40 1840.99 1940.00 1969.99 2092.13 2061.32
## [460] 2061.67 2104.42 2122.45 1983.56 2054.91 2070.83 2090.86 2144.51 2145.92
## [469] 2301.00 2369.54 2499.50 2460.83 2390.93 2226.09 2206.66 2307.28 2405.01
## [478] 2408.00 2323.83 2295.99 2214.89 2463.00 2649.25 2708.01 2712.80 2763.92
## [487] 2949.51 2969.00 3288.00 3409.65 3467.44 3467.85 3501.77 3852.00 3909.82
## [496] 3899.32 4140.00 4104.21 3714.20 3990.47 3794.99 3360.34 3440.10 3434.23
## [505] 2535.67 2761.80 2248.80 2356.38 2073.14 2623.97 2552.11 2791.65 2725.92
## [514] 2424.99 2237.97 2437.73 2595.82 2577.58 2723.52 2819.99 2702.23 2627.47
## [523] 2706.96 2651.31 2537.01 2563.27 2467.85 2383.54 2403.58 2562.82 2541.84
## [532] 2522.43 2402.42 2343.23 2194.37 2225.64 2254.99 1941.23 1930.48 1931.56
## [541] 2007.27 1867.87 1767.57 1816.34 2135.01 2191.26 2239.11 2117.60 2089.00
## [550] 2219.55 2350.42 2217.31 2310.85 2362.01 2137.80 2134.85 2095.08 2130.87
## [559] 2026.57 1949.46 1989.35 1925.09 1902.35 1899.02 1895.28 1819.30 1794.03
## [568] 1947.62 2016.29 2039.45 2151.04 2157.66 2260.97 2242.77 2301.10 2314.17
## [577] 2419.57 2490.81 2670.00 2597.51 2487.41 2708.97 2803.67 2911.70 3081.75
## [586] 2988.72 3071.56 3156.55 3236.20 3061.61 3281.00 3233.92 3261.22 3164.98
## [595] 3072.00 3007.34 3157.16 3260.97 3226.38 3156.96 3339.98 3216.70 3210.00
## [604] 3116.84 3264.37 3239.14 3236.00 3342.39 3392.83 3730.00 3811.26 3917.19
## [613] 3880.55 3972.05 3949.99 3415.04 3473.72 3424.95 3250.96 3293.97 3316.89
## [622] 3295.57 3377.76 3551.43 3487.77 3378.01 3398.69 3359.13 3019.11 2765.16
## [631] 3026.36 3142.44 2947.01 2927.45 3088.41 2974.94 2863.28 2820.49 2972.80
## [640] 3293.01 3428.74 3426.97 3384.30 3533.79 3560.16 3623.58 3554.29 3579.31
## [649] 3512.75 3493.73 3476.80 3576.00 3759.36 3879.87 3831.77 3700.98 3739.16
## [658] 3809.34 4107.96 4089.19 3975.35 4089.33 4063.12 4180.80 4262.82 3984.14
## [667] 4257.60 4409.10 4311.57 4269.50 4310.99 4505.48 4618.00 4517.22 4453.68
## [676] 4488.09 4629.00 4773.85 4800.00 4557.49 4743.20 4655.12 4652.40 4576.79
## [685] 4572.81 4257.79 4253.17 4022.41 4279.00 4433.39 4369.45 4078.51 4351.45
## [694] 4257.24 4500.00 4078.31 4080.89 4256.95 4453.80 4627.16 4569.99 4545.44
## [703] 4218.61 4066.10 4153.22 4324.65 4292.32 4418.54 4167.70 3999.61 4022.39
## [712] 4122.34 3770.01 3854.24 4066.00 4030.84 3913.17 3976.42 3922.25 3914.36
## [721] 4023.92 4015.75 4112.67 4067.43 4121.52 4087.98 4061.30 3807.82 3724.98
## [730] 3733.98 3687.67 3749.75 3813.67 3727.99 3826.65 3557.41 3426.38 3216.50
## [739] 3080.64 3188.77 3073.50 3232.52 3370.80 3271.94 3332.60 3337.18 3331.00
## [748] 3168.54 3164.35 3114.58 3083.99 2614.44 2448.91 2422.90 2442.65 2414.06
## [757] 2419.99 2359.79 2537.68 2620.00 2558.81 2680.71 2790.00 2647.75 2657.49
## [766] 2957.62 3027.15 2996.00 3151.38 3118.37 3240.00 3114.29 2927.28 2880.00
## [775] 2875.03 2915.92 3099.47 3136.48 2896.67 2783.64 2742.00 2599.40 2583.87
## [784] 2604.01 2620.70 2633.01 2709.14 2827.20 2606.65 2821.51 2954.79 2963.89
## [793] 2804.50 2608.32 2655.49 2627.79 2484.17 2560.80 2708.44 2604.00 2573.60
## [802] 2586.98 2547.01 2524.55 2625.59 2774.50 2807.99 2952.01 2956.80 2877.47
## [811] 2911.51 3001.61 2981.96 3104.85 3128.32 3144.00 3238.88 3417.28 3395.20
## [820] 3413.71 3299.98 3443.19 3471.20 3495.00 3510.17 3436.17 3235.47 3238.51
## [829] 3247.98 3226.04 3290.16 2992.28 2987.70 3105.73 3011.47 3030.16 3034.06
## [838] 3045.70 3005.18 3094.31 3085.00 3001.41 2971.28 2961.98 2941.25 2996.74
## [847] 2828.63 2864.84 2948.97 2806.13 2788.47 2812.70 2827.69 2774.37 2943.42
## [856] 2754.37 2704.81 2673.55 2539.33 2286.10 2321.92 2031.16 1925.01 2043.75
## [865] 1997.47 2128.88 2030.99 2051.90 1962.74 2011.38 1957.64 1972.76 2004.77
## [874] 1996.35 1967.21 1959.09 1826.05 1744.16 1790.25 1793.03 1952.14 1948.13
## [883] 1794.22 1824.05 1758.06 1774.69 1809.74 1860.47 1844.73 1796.12 1792.44
## [892] 1677.39 1521.84 1477.97 1243.08 1187.30 1177.44 1096.86 1095.00 902.25
## [901] 1138.58 1119.96 1121.57 1051.16 1134.20 1215.09 1207.44 1247.70 1202.24
## [910] 1160.55 1107.93 1011.67 1067.88 1062.79 1083.27 1120.44 1154.34 1160.63
## [919] 1237.75 1242.36 1219.84 1177.50 1136.62 1046.00 1075.93 1191.48 1256.28
## [928] 1345.60 1343.41 1473.04 1559.60 1524.00 1586.73 1525.01 1523.82 1611.43
## [937] 1520.86 1379.02 1601.64 1756.28 1733.17 1702.82 1721.29 1622.95 1650.30
## [946] 1641.88 1590.67 1679.93 1715.00 1722.52 1799.85 1698.01 1842.60 1902.53
## [955] 1933.74 1991.91 1942.57 1904.74 1885.13 1850.20 1876.87 1687.80 1531.94
## [964] 1618.24 1578.05 1649.28 1683.37 1707.80 1557.41 1480.58 1483.47 1546.83
## [973] 1557.62 1572.96 1580.77 1568.51 1552.16 1571.36 1598.42 1579.95 1641.59
## [982] 1644.75 1720.62 1734.07 1759.33 1724.26 1607.50 1603.66 1504.22 1436.00
## [991] 1462.59 1370.86 1357.73 1342.61 1313.67 1324.18 1301.98 1342.22 1293.03
## [1000] 1325.05 1324.42 1351.26 1338.25 1331.30 1309.66 1303.74 1323.92 1362.09
## [1009] 1346.06 1363.88 1332.01 1325.20 1320.90 1307.39 1282.78 1298.57 1294.30
## [1018] 1302.20 1280.85 1311.01 1330.45 1314.44 1293.99 1281.77 1302.46 1316.05
## [1027] 1330.22 1351.91 1473.00 1554.46 1527.81 1561.00 1627.40 1595.49 1566.34
## [1036] 1575.52 1513.45 1541.15 1647.04 1631.71 1604.04 1575.70 1335.07 1105.81
## [1045] 1320.71 1265.94 1255.72 1216.60 1226.43 1244.39 1206.04 1205.70 1208.80
## [1054] 1210.00 1139.38 1092.64 1130.19 1168.79 1195.20 1199.67 1209.93 1216.21
## [1063] 1172.11 1219.38 1296.99 1276.85 1290.99 1260.76 1277.23 1259.46 1256.66
## [1072] 1231.63 1278.18 1259.91 1268.94 1264.92 1275.15 1320.19 1310.85 1264.65
## [1081] 1194.61 1179.27 1182.99 1176.05 1216.55 1211.12 1215.00 1221.85 1218.69
## [1090] 1218.33 1216.70 1210.24 1186.77 1195.20 1197.20 1199.52 1202.11 1221.34
## [1099] 1210.65 1252.16 1251.32 1266.32 1264.20 1269.72 1317.74 1339.75 1342.74
## [1108] 1427.58 1456.07 1538.04 1552.35 1579.41 1581.50 1528.20 1545.03 1637.84
## [1117] 1660.63 1628.25 1632.14 1599.45 1617.97 1602.99 1598.72 1567.24 1643.21
## [1126] 1557.18 1576.74 1635.79 1640.80 1657.36 1678.81 1622.40 1638.37 1667.49
## [1135] 1652.81 1541.00 1507.00 1535.60 1511.92 1486.15 1555.78 1665.44 1682.03
## [1144] 1695.34 1688.00 1686.12 1700.70 1641.12 1619.33 1646.58 1602.99 1574.00
## [1153] 1642.65 1627.28 1605.47 1656.70 1641.69 1558.69 1556.43 1571.74 1566.31
## [1162] 1550.40 1552.67 1432.87 1426.20 1475.61 1562.36 1672.75 1708.72 1652.89
## [1171] 1658.91 1743.94 1796.69 1799.55 1760.30 1798.20 1736.07 1817.20 1750.00
## [1180] 1732.01 1761.52 1707.60 1774.61 1803.13 1795.10 1817.14 1817.06 1789.24
## [1189] 1780.58 1879.00 1905.27 1865.02 1853.74 1855.68 1857.01 1885.87 1895.20
## [1198] 1908.85 2008.64 2107.57 2089.25 2122.92 2078.22 2092.83 1981.65 1938.10
## [1207] 1838.38 1868.86 1848.21 1837.70 1860.78 1865.73 1919.58 1895.84 1904.53
## [1216] 1892.35 1809.79 1870.08 1874.03 1878.06 1990.86 1898.07 1913.16 1840.91
## [1225] 1848.64 1858.80 1796.09 1788.28 1804.40 1799.10 1826.27 1821.41 1826.20
## [1234] 1796.79 1812.70 1817.13 1806.42 1818.16 1854.86 1804.97 1809.86 1835.42
## [1243] 1827.72 1854.69 1893.48 1904.12 1865.88 1869.00 1905.58 1888.02 1904.47
## [1252] 1804.84 1876.99 1841.52 1853.42 1835.97 1744.18 1770.55 1739.10 1737.99
## [1261] 1639.49 1668.06 1725.64 1728.16 1729.94 1730.08 1787.30 1877.35 1888.03
## [1270] 1907.34 1876.83 1893.40 1852.34 1891.64 1831.27 1849.91 1927.83 1923.46
## [1279] 1918.45 1959.62 1941.90 1910.07 1883.21 1865.67 1848.98 1869.41 1891.95
## [1288] 1874.76 1871.99 1984.00 1916.38 1932.03 1928.67 1890.35 1894.84 1899.00
## [1297] 1887.27 1894.77 1888.50 1891.99 1850.79 1861.73 1882.11 1858.85 1876.17
## [1306] 1884.26 1864.68 1853.28 1849.42 1841.11 1843.43 1820.65 1832.41 1828.82
## [1315] 1825.17 1863.42 1851.60 1848.25 1843.93 1846.64 1853.18 1843.10 1827.97
## [1324] 1807.39 1715.99 1657.64 1671.39 1688.54 1672.50 1630.52 1684.34 1648.30
## [1333] 1649.52 1646.92 1653.31 1645.84 1727.69 1703.25 1647.42 1629.34 1634.45
## [1342] 1642.73 1627.10 1629.31 1628.00 1638.72 1636.05 1633.73 1619.14 1540.25
## [1351] 1599.23 1604.73 1628.99 1621.50 1635.44 1617.37 1638.02 1642.87 1623.35
## [1360] 1588.24 1591.06 1593.68 1590.66 1586.68 1586.61 1594.33 1657.07 1667.04
## [1369] 1680.35 1674.25 1716.35 1656.88 1642.81 1616.91 1647.17 1634.13 1637.22
## [1378] 1577.03 1559.90 1563.28 1535.49 1559.61 1555.15 1564.20 1586.75 1560.91
## [1387] 1562.31 1565.88 1603.59 1630.22 1640.72 1708.78 1771.85 1788.04 1798.87
## [1396] 1781.31 1779.42 1797.52 1802.05 1814.72 1853.58 1805.63 1829.48 1839.54
## [1405] 1869.71 1891.66 1893.34
eth_close_zoo <- as.zoo(eth_close_ts)
eth_close_df <- fortify.zoo(eth_close_zoo)
eth_close_df$Year <- floor(eth_close_df$Index)
eth_close_df$Days <- round((eth_close_df$Index - eth_close_df$Year) * 365.25)
eth_close_df$Date <- as.Date(paste0(eth_close_df$Year, "-01-01")) + eth_close_df$Days
hchart(eth_close_df, "line", hcaes(x = Date, y = eth_close_zoo)) %>%
hc_add_theme(hc_theme_darkunica())##
## Augmented Dickey-Fuller Test
##
## data: eth_close_ts
## Dickey-Fuller = -1.6616, Lag order = 11, p-value = 0.7216
## alternative hypothesis: stationary
##
## Phillips-Perron Unit Root Test
##
## data: eth_close_ts
## Dickey-Fuller Z(alpha) = -5.4418, Truncation lag parameter = 7, p-value
## = 0.8062
## alternative hypothesis: stationary
# Identificación
par(mfrow=c(3,3))
plot(eth_close_ts,type="o")
acf(eth_close_ts, lag.max=40)
pacf(eth_close_ts, lag.max=40)
plot(diff(eth_close_ts),type="o")
abline(h=2*sqrt(var(diff(eth_close_ts))),col="red",lty=2)
abline(h=-2*sqrt(var(diff(eth_close_ts))),col="red",lty=2)
acf(diff(eth_close_ts), lag.max=40)
pacf(diff(eth_close_ts), lag.max=40)
plot(diff(eth_close_ts,),type="o")
acf(diff(eth_close_ts,365), lag.max=40)
pacf(diff(eth_close_ts,365), lag.max=40)Dickey Fuller del paquete tseries
##
## Augmented Dickey-Fuller Test
##
## data: diff(eth_close_ts, 365)
## Dickey-Fuller = -1.4958, Lag order = 10, p-value = 0.7917
## alternative hypothesis: stationary
Test Phillips-Perron
##
## Phillips-Perron Unit Root Test
##
## data: diff(eth_close_ts, 365)
## Dickey-Fuller Z(alpha) = -5.0666, Truncation lag parameter = 7, p-value
## = 0.8271
## alternative hypothesis: stationary
Transformación y modelado de los datos:
1. Transformación Logarítmica
eth_close_log <- log(eth_close_ts)
autoplot(eth_close_log) + ggtitle("Log-Transformed Ethereum Prices")Arima LOG
##
## Call:
## arima(x = eth_close_log, order = c(2, 1, 1))
##
## Coefficients:
## ar1 ar2 ma1
## 0.5601 0.0595 -0.5815
## s.e. 0.2430 0.0273 0.2427
##
## sigma^2 estimated as 0.00203: log likelihood = 2363.49, aic = -4718.98
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.001728614 0.04503583 0.03047377 0.02623036 0.441566 0.9983703
## ACF1
## Training set -0.002459091
## [1] -4697.989
eth_close_diff_log <- diff(eth_close_log)
par(mfrow=c(3,1))
plot(eth_close_diff_log, main="Log-Transformed & Differenced Ethereum Prices")
acf(eth_close_diff_log, lag.max=40, main="ACF of Log-Transformed & Differenced Ethereum Prices")
pacf(eth_close_diff_log, lag.max=40, main="PACF of Log-Transformed & Differenced Ethereum Prices")2. Transformación Box-Cox
lambda <- BoxCox.lambda(eth_close_ts)
eth_close_boxcox <- BoxCox(eth_close_ts, lambda)
autoplot(eth_close_boxcox) + ggtitle("Box-Cox Transformed Ethereum Prices")ARIMA - Box-Cox
##
## Call:
## arima(x = eth_close_boxcox, order = c(3, 1, 2))
##
## Coefficients:
## ar1 ar2 ar3 ma1 ma2
## -0.2109 0.6923 0.0458 0.1438 -0.5883
## s.e. 0.1504 0.1094 0.0354 0.1484 0.1106
##
## sigma^2 estimated as 1.53e-08: log likelihood = 10655.75, aic = -21299.51
##
## Training set error measures:
## ME RMSE MAE MPE MAPE
## Training set 4.984781e-06 0.0001264424 4.716271e-05 0.0005000895 0.004734736
## MASE ACF1
## Training set 1.012657 -0.01616264
## [1] -21268.02
Profundidad del modelo Logarítmico
et <- residuals(model_log)
par(mfrow=c(2,2))
plot(et, main="Residuales del modelo")
acf(et, main="ACF de Residuales")
pacf(et, main="PACF de Residuales")
qqnorm(et, main="QQ Plot de Residuales")
qqline(et)Test de los supuestos del modelo
##
## Box-Ljung test
##
## data: et
## X-squared = 13.67, df = 7, p-value = 0.05736
##
## Jarque Bera Test
##
## data: et
## X-squared = 4695.9, df = 2, p-value < 2.2e-16
#### Test de Aleatoriedad
#$H_0:$ Residuales exhiben un comport. de Aleatoriedad
#$H_a:$ Residuales no exhiben estructura (Tendencia, o cualquier otro comportamiento predecible)##
## Runs Test
##
## data: as.factor(sign(et))
## Standard Normal = 1.0078, p-value = 0.3136
## alternative hypothesis: two.sided
Pronóstico Inicial
forecast_log <- forecast(model_log, h=10, fan = T)
plot(forecast(model_log,h=15, fan=T))
lines(fitted(model_log), col="red")3.Modelado con Prophet - Sin LOG
## Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
future <- make_future_dataframe(m, periods = 10)
forecast <- predict(m, future)
forecast_prophet <- predict(m, future)4.Modelado con Prophet - Con LOG
## Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
future2 <- make_future_dataframe(m2, periods = 10)
forecast2 <- predict(m2, future2)
forecast_prophet_log <- predict(m2, future2)5.Red Neuronal
tamano_total <- length(S)
tamano_train <- round(tamano_total * 0.75, digits = 0)
train <- 1:tamano_train
test <- (tamano_train+1):tamano_totallibrary(zoo)
slogN <- data.frame(y = S,
lag.1 = stats::lag(S, -1),
lag.2 = stats::lag(S, -2),
lag.3 = stats::lag(S, -3),
lag.4 = stats::lag(S, -4),
lag.5 = stats::lag(S, -5),
lag.6 = stats::lag(S, -6),
lag.7 = stats::lag(S, -7),
lag.8 = stats::lag(S, -8),
lag.9 = stats::lag(S, -9),
lag.10 = stats::lag(S, -10),
lag.11 = stats::lag(S, -11),
lag.12 = stats::lag(S, -12))
slogN <- na.omit(slogN)
inputs <- as.data.frame(slogN[,-1])
outputs <- slogN$yRed De Elman
##
## Attaching package: 'RSNNS'
## The following objects are masked from 'package:caret':
##
## confusionMatrix, train
# Definir rangos de hiperparámetros
sizes <- c(5, 10, 15) # Número de neuronas en las capas
learning_rates <- c(0.1, 0.01) # Tasas de aprendizaje
# Guardar el mejor modelo, su error y sus hiperparámetros
best_model <- NULL
best_error <- Inf
best_size <- NA
best_learning_rate <- NA
# Bucle sobre todas las combinaciones posibles de hiperparámetros
for (size in sizes) {
for (lr in learning_rates) {
# Entrenar el modelo
fit <- elman(inputs[train,], outputs[train], size = c(size), learnFuncParams = c(lr), maxit = 200)
# Evaluar el modelo
predictions <- predict(fit, newdata = inputs[test,])
error <- sum((predictions - outputs[test])^2) # Puedes usar otra métrica de error
# Actualizar el mejor modelo si es necesario
if (error < best_error) {
best_model <- fit
best_error <- error
best_size <- size
best_learning_rate <- lr
}
}
}
# Mostrar los hiperparámetros del mejor modelo
cat("Mejor modelo con tamaño:", best_size, "y tasa de aprendizaje:", best_learning_rate, "con un error de:", best_error)## Mejor modelo con tamaño: 5 y tasa de aprendizaje: 0.01 con un error de: 0.0003054597
y <- as.vector(outputs[test])
plot(y, type = "l", ylim = range(c(y, predict(fit, newdata = inputs[test,]))))
lines(predict(fit, newdata = inputs[test,]), col = "red")predictions <- predict(fit, newdata = inputs)
predictions_desnorm <- predictions * (max(Z) - min(Z)) + min(Z)plot(Z, type = "l", col = "blue", lwd = 2, main = "Predicciones vs Datos Reales", xlab = "Tiempo", ylab = "Valor")
lines(predictions_desnorm, col = "red", lwd = 2)
legend("topright", legend = c("Real", "Predicción"), col = c("blue", "red"), lty = 1, cex = 0.8)library(RSNNS)
slogN <- cbind(y = S, sapply(1:12, function(lag) stats::lag(S, -lag)))
slogN <- na.omit(slogN)
inputs <- slogN[,-1]
outputs <- slogN[,1]
predicciones <- numeric(15)
ultimos_datos <- as.matrix(tail(inputs, 12))
for(i in 1:15){
pred <- predict(fit, newdata = t(ultimos_datos[1, ]))
predicciones[i] <- pred[1]
ultimos_datos[1:(nrow(ultimos_datos) - 1), ] <- ultimos_datos[2:nrow(ultimos_datos), ]
ultimos_datos[nrow(ultimos_datos), 1] <- pred[1]
}
# Desnormalizar las predicciones:
predicciones_desnorm <- predicciones * (max(Z) - min(Z)) + min(Z)
plot(Z, type = "l", col = "blue", lwd = 2, main = "Predicciones vs Datos Reales", xlab = "Tiempo", ylab = "Valor")
lines(c(rep(NA, length(Z)), predicciones_desnorm), col = "red", lwd = 2)
legend("topright", legend = c("Real", "Predicción"), col = c("blue", "red"), lty = 1, cex = 0.8)
#### Red Jordan
library(RSNNS)
# Asegurarse de que 'inputs' sea una matriz con 12 columnas (una por cada lag)
inputs_matrix <- as.matrix(inputs)
# Entrenar la red de Jordan
fit_j <- jordan(inputs_matrix[train, ], outputs[train], size=6, learnFuncParams=c(0.1), maxit=300)
# Plot del error iterativo
plotIterativeError(fit_j, main = "Iterative Error for 6 Neuron Jordan Network")# Comparar predicciones con valores reales
y_j <- as.vector(outputs[test])
plot(y_j, type = "l", ylim = range(c(y_j, predict(fit_j, newdata = inputs_matrix[test, ]))))
lines(predict(fit_j, newdata = inputs_matrix[test, ]), col = "red")y_j <- as.vector(outputs[test])
plot(y_j, type = "l", ylim = range(c(y_j, predict(fit_j, newdata = inputs[test,]))))
lines(predict(fit_j, newdata = inputs[test,]), col = "red")predictions <- predict(fit_j, newdata = inputs)
predictions_desnorm_jor <- predictions * (max(Z) - min(Z)) + min(Z)plot(Z, type = "l", col = "blue", lwd = 2, main = "Predicciones vs Datos Reales", xlab = "Tiempo", ylab = "Valor")
lines(predictions_desnorm_jor, col = "red", lwd = 2)
legend("topright", legend = c("Real", "Predicción"), col = c("blue", "red"), lty = 1, cex = 0.8)Ingreso de Datos reales:
Comparación General de los modelos:
etherium_real$Date <- as.Date(etherium_real$Date, format="%m/%d/%Y")
ultimos_10_dias <- etherium_real$Close
fechas_correctas <- tail(etherium_real$Date, length(ultimos_10_dias))
forecast_prophet_log_values <- head(exp(forecast_prophet_log$yhat[(length(etherium$Close)+1):(length(etherium$Close)+10)]), length(ultimos_10_dias))
predicciones_desnorm_values <- head(predicciones_desnorm, length(ultimos_10_dias))
predictions_desnorm_values_jor <- tail(predictions_desnorm_jor,length(ultimos_10_dias))
fechas <- etherium_real$Date[1:length(ultimos_10_dias)]
tabla_predicciones <- data.frame(
Fecha = fechas_correctas,
Real = ultimos_10_dias,
ProphetLog = forecast_prophet_log_values,
RedNeuronal = predicciones_desnorm_values,
RedNeuronal_Jordan = predictions_desnorm_values_jor
)## Fecha Real ProphetLog RedNeuronal RedNeuronal_Jordan
## 2023-11-08 1888.25 1692.825 1749.890 1822.712
## 2023-11-09 2060.14 1684.167 1783.962 1827.257
## 2023-11-10 2094.24 1674.565 1813.334 1840.494
## 2023-11-11 2044.75 1666.843 1817.619 1881.253
## 2023-11-12 2060.08 1666.858 1832.389 1830.064
## 2023-11-13 2061.00 1659.992 1878.446 1855.733
## 2023-11-14 1981.95 1661.086 1798.769 1866.145
## 2023-11-15 2048.93 1660.127 1844.933 1897.740
## 2023-11-16 1956.32 1657.106 1851.229 1920.360
## 2023-11-17 1946.60 1653.903 1890.232 1921.662
grafico <- ggplot(tabla_predicciones, aes(x=Fecha)) +
geom_line(aes(y=Real, colour="Real")) +
geom_line(aes(y=ProphetLog, colour="Prophet Log")) +
geom_line(aes(y=RedNeuronal, colour="Red Neuronal Elman")) +
geom_line(aes(y=RedNeuronal_Jordan, colour = "Red Neuronal Jordan"))+
labs(title="Comparación de Predicciones vs Datos Reales", x="Fecha", y="Valor") +
scale_color_manual(name="Leyenda",
values=c("Real"="black",
"Prophet Log"="blue",
"Red Neuronal Elman"="purple",
"Red Neuronal Jordan"="green")) +
theme_minimal() +
theme(legend.position="bottom")
grafico# Funciones para calcular RMSE y MAE
rmse <- function(error) {
sqrt(mean(error^2))
}
mae <- function(error) {
mean(abs(error))
}
# Error para cada modelo
error_log <- tabla_predicciones$Real - tabla_predicciones$Log
error_prophet <- tabla_predicciones$Real - tabla_predicciones$Prophet
error_prophet_log <- tabla_predicciones$Real - tabla_predicciones$ProphetLog
error_red_neuronal <- tabla_predicciones$Real - tabla_predicciones$RedNeuronal
error_red_neuronal_jordan <- tabla_predicciones$Real - tabla_predicciones$RedNeuronal_Jordan
# RMSE
rmse_log <- rmse(error_log)
rmse_prophet <- rmse(error_prophet)
rmse_prophet_log <- rmse(error_prophet_log)
rmse_red_neuronal <- rmse(error_red_neuronal)
rmse_red_neuronal_jordan <- rmse(error_red_neuronal_jordan)
# MAE
mae_log <- mae(error_log)
mae_prophet <- mae(error_prophet)
mae_prophet_log <- mae(error_prophet_log)
mae_red_neuronal <- mae(error_red_neuronal)
mae_red_neuronal_jordan <- mae(error_red_neuronal_jordan)
# Creando un dataframe con los resultados
metricas <- data.frame(
Modelo = c("Prophet", "Prophet Log", "Red Neuronal","Red Neuronal Jordan"),
RMSE = c(rmse_prophet, rmse_prophet_log, rmse_red_neuronal,rmse_red_neuronal_jordan),
MAE = c(mae_prophet, mae_prophet_log, mae_red_neuronal,mae_red_neuronal_jordan)
)
metricas## Modelo RMSE MAE
## 1 Prophet 352.5962 346.4788
## 2 Prophet Log 352.5962 346.4788
## 3 Red Neuronal 200.1187 188.1456
## 4 Red Neuronal Jordan 168.1885 147.8838
bitcoin <- rio::import("https://github.com/EdwinHigueraA/bfi_s/raw/main/BTC-USD.csv")
bitcoin <- na.omit(bitcoin)
cols_to_convert <- c("Open", "High", "Low", "Close")
for (col in cols_to_convert) {
bitcoin[[col]] <- as.numeric(gsub(",", "", bitcoin[[col]]))
}
bitcoin_close_ts <- ts(bitcoin$Close, start = c(2020, 1), frequency = 365)
bitcoin_close_ts## Time Series:
## Start = c(2020, 1)
## End = c(2023, 312)
## Frequency = 365
## [1] 7200.174 6985.470 7344.884 7410.657 7411.317 7769.219 8163.692
## [8] 8079.863 7879.071 8166.554 8037.538 8192.494 8144.194 8827.765
## [15] 8807.011 8723.786 8929.038 8942.809 8706.245 8657.643 8745.895
## [22] 8680.876 8406.516 8445.435 8367.848 8596.830 8909.819 9358.590
## [29] 9316.630 9508.993 9350.529 9392.875 9344.365 9293.521 9180.963
## [36] 9613.424 9729.802 9795.943 9865.119 10116.674 9856.611 10208.236
## [43] 10326.055 10214.380 10312.116 9889.425 9934.434 9690.143 10141.996
## [50] 9633.387 9608.476 9686.441 9663.182 9924.516 9650.175 9341.705
## [57] 8820.522 8784.494 8672.455 8599.509 8562.454 8869.670 8787.786
## [64] 8755.246 9078.763 9122.546 8909.954 8108.116 7923.645 7909.729
## [71] 7911.430 4970.788 5563.707 5200.366 5392.315 5014.480 5225.629
## [78] 5238.438 6191.193 6198.778 6185.066 5830.255 6416.315 6734.804
## [85] 6681.063 6716.440 6469.798 6242.194 5922.043 6429.842 6438.645
## [92] 6606.776 6793.625 6733.387 6867.527 6791.129 7271.781 7176.415
## [99] 7334.099 7302.089 6865.493 6859.083 6971.092 6845.038 6842.428
## [106] 6642.110 7116.804 7096.185 7257.665 7189.425 6881.958 6880.323
## [113] 7117.208 7429.725 7550.901 7569.936 7679.867 7795.601 7807.059
## [120] 8801.038 8658.554 8864.767 8988.597 8897.469 8912.654 9003.070
## [127] 9268.762 9951.519 9842.666 9593.896 8756.431 8601.796 8804.478
## [134] 9269.987 9733.722 9328.197 9377.014 9670.739 9726.575 9729.038
## [141] 9522.981 9081.762 9182.577 9209.287 8790.368 8906.935 8835.053
## [148] 9181.018 9525.751 9439.124 9700.414 9461.059 10167.269 9529.804
## [155] 9656.718 9800.637 9665.533 9653.680 9758.853 9771.489 9795.700
## [162] 9870.095 9321.781 9480.844 9475.277 9386.788 9450.702 9538.024
## [169] 9480.255 9411.841 9288.019 9332.341 9303.630 9648.718 9629.658
## [176] 9313.610 9264.813 9162.918 9045.391 9143.582 9190.854 9137.993
## [183] 9228.325 9123.410 9087.304 9132.488 9073.942 9375.475 9252.277
## [190] 9428.333 9277.968 9278.808 9240.347 9276.500 9243.614 9243.214
## [197] 9192.837 9132.228 9151.393 9159.040 9185.817 9164.231 9374.888
## [204] 9525.363 9581.072 9536.893 9677.113 9905.167 10990.873 10912.823
## [211] 11100.468 11111.214 11323.467 11759.593 11053.614 11246.349 11205.893
## [218] 11747.022 11779.773 11601.473 11754.046 11675.739 11878.111 11410.525
## [225] 11584.935 11784.138 11768.871 11865.698 11892.804 12254.402 11991.233
## [232] 11758.283 11878.372 11592.489 11681.825 11664.848 11774.596 11366.135
## [239] 11488.363 11323.397 11542.500 11506.865 11711.506 11680.820 11970.479
## [246] 11414.034 10245.297 10511.813 10169.567 10280.352 10369.563 10131.517
## [253] 10242.348 10363.139 10400.915 10442.171 10323.756 10680.838 10796.951
## [260] 10974.905 10948.990 10944.586 11094.347 10938.271 10462.260 10538.460
## [267] 10246.187 10760.066 10692.717 10750.724 10775.270 10709.652 10844.641
## [274] 10784.491 10619.452 10575.975 10549.329 10669.583 10793.340 10604.406
## [281] 10668.969 10915.686 11064.458 11296.361 11384.182 11555.363 11425.899
## [288] 11429.507 11495.350 11322.123 11358.102 11483.359 11742.037 11916.335
## [295] 12823.689 12965.892 12931.539 13108.062 13031.174 13075.248 13654.219
## [302] 13271.285 13437.883 13546.522 13780.995 13737.109 13550.489 13950.301
## [309] 14133.707 15579.849 15565.881 14833.754 15479.567 15332.315 15290.902
## [316] 15701.340 16276.344 16317.809 16068.139 15955.588 16716.111 17645.406
## [323] 17804.006 17817.090 18621.314 18642.232 18370.002 18364.121 19107.465
## [330] 18732.121 17150.623 17108.402 17717.414 18177.484 19625.836 18802.998
## [337] 19201.092 19445.398 18699.766 19154.230 19345.121 19191.631 18321.145
## [344] 18553.916 18264.992 18058.904 18803.656 19142.383 19246.645 19417.076
## [351] 21310.598 22805.162 23137.961 23869.832 23477.295 22803.082 23783.029
## [358] 23241.346 23735.949 24664.791 26437.037 26272.295 27084.809 27362.438
## [365] 28840.953 29001.721 29374.152 32127.268 32782.023 31971.914 33992.430
## [372] 36824.363 39371.043 40797.609 40254.547 38356.441 35566.656 33922.961
## [379] 37316.359 39187.328 36825.367 36178.141 35791.277 36630.074 36069.805
## [386] 35547.750 30825.699 33005.762 32067.643 32289.379 32366.393 32569.850
## [393] 30432.547 33466.098 34316.387 34269.523 33114.359 33537.176 35510.289
## [400] 37472.090 36926.066 38144.309 39266.012 38903.441 46196.465 46481.105
## [407] 44918.184 47909.332 47504.852 47105.516 48717.289 47945.059 49199.871
## [414] 52149.008 51679.797 55888.133 56099.520 57539.945 54207.320 48824.426
## [421] 49705.332 47093.852 46339.762 46188.453 45137.770 49631.242 48378.988
## [428] 50538.242 48561.168 48927.305 48912.383 51206.691 52246.523 54824.117
## [435] 56008.551 57805.121 57332.090 61243.086 59302.316 55907.199 56804.902
## [442] 58870.895 57858.922 58346.652 58313.645 57523.422 54529.145 54738.945
## [449] 52774.266 51704.160 55137.312 55973.512 55950.746 57750.199 58917.691
## [456] 58918.832 59095.809 59384.312 57603.891 58758.555 59057.879 58192.359
## [463] 56048.938 58323.953 58245.004 59793.234 60204.965 59893.453 63503.457
## [470] 63109.695 63314.012 61572.789 60683.820 56216.184 55724.266 56473.031
## [477] 53906.090 51762.273 51093.652 50050.867 49004.254 54021.754 55033.117
## [484] 54824.703 53555.109 57750.176 57828.051 56631.078 57200.293 53333.539
## [491] 57424.008 56396.516 57356.402 58803.777 58232.316 55859.797 56704.574
## [498] 49150.535 49716.191 49880.535 46760.188 46456.059 43537.512 42909.402
## [505] 37002.441 40782.738 37304.691 37536.633 34770.582 38705.980 38402.223
## [512] 39294.199 38436.969 35697.605 34616.066 35678.129 37332.855 36684.926
## [519] 37575.180 39208.766 36894.406 35551.957 35862.379 33560.707 33472.633
## [526] 37345.121 36702.598 37334.398 35552.516 39097.859 40218.477 40406.270
## [533] 38347.062 38053.504 35787.246 35615.871 35698.297 31676.693 32505.660
## [540] 33723.027 34662.438 31637.779 32186.277 34649.645 34434.336 35867.777
## [547] 35040.836 33572.117 33897.047 34668.547 35287.781 33746.004 34235.195
## [554] 33855.328 32877.371 33798.012 33520.520 34240.188 33155.848 32702.025
## [561] 32822.348 31780.730 31421.539 31533.068 31796.811 30817.832 29807.348
## [568] 32110.693 32313.105 33581.551 34292.445 35350.188 37337.535 39406.941
## [575] 39995.906 40008.422 42235.547 41626.195 39974.895 39201.945 38152.980
## [582] 39747.504 40869.555 42816.500 44555.801 43798.117 46365.402 45585.031
## [589] 45593.637 44428.289 47793.320 47096.945 47047.004 46004.484 44695.359
## [596] 44801.188 46717.578 49339.176 48905.492 49321.652 49546.148 47706.117
## [603] 48960.789 46942.219 49058.668 48902.402 48829.832 47054.984 47166.688
## [610] 48847.027 49327.723 50025.375 49944.625 51753.410 52633.535 46811.129
## [617] 46091.391 46391.422 44883.910 45201.457 46063.270 44963.074 47092.492
## [624] 48176.348 47783.359 47267.520 48278.363 47260.219 42843.801 40693.676
## [631] 43574.508 44895.098 42839.750 42716.594 43208.539 42235.730 41034.543
## [638] 41564.363 43790.895 48116.941 47711.488 48199.953 49112.902 51514.812
## [645] 55361.449 53805.984 53967.848 54968.223 54771.578 57484.789 56041.059
## [652] 57401.098 57321.523 61593.949 60892.180 61553.617 62026.078 64261.992
## [659] 65992.836 62210.172 60692.266 61393.617 60930.836 63039.824 60363.793
## [666] 58482.387 60622.137 62227.965 61888.832 61318.957 61004.406 63226.402
## [673] 62970.047 61452.230 61125.676 61527.480 63326.988 67566.828 66971.828
## [680] 64995.230 64949.961 64155.941 64469.527 65466.840 63557.871 60161.246
## [687] 60368.012 56942.137 58119.578 59697.195 58730.477 56289.289 57569.074
## [694] 56280.426 57274.680 53569.766 54815.078 57248.457 57806.566 57005.426
## [701] 57229.828 56477.816 53598.246 49200.703 49368.848 50582.625 50700.086
## [708] 50504.797 47672.121 47243.305 49362.508 50098.336 46737.480 46612.633
## [715] 48896.723 47665.426 46202.145 46848.777 46707.016 46880.277 48936.613
## [722] 48628.512 50784.539 50822.195 50429.859 50809.516 50640.418 47588.855
## [729] 46444.711 47178.125 46306.445 47686.812 47345.219 46458.117 45897.574
## [736] 43569.004 43160.930 41557.902 41733.941 41911.602 41821.262 42735.855
## [743] 43949.102 42591.570 43099.699 43177.398 43113.879 42250.551 42375.633
## [750] 41744.328 40680.418 36457.316 35030.250 36276.805 36654.328 36954.004
## [757] 36852.121 37138.234 37784.332 38138.180 37917.602 38483.125 38743.273
## [764] 36952.984 37154.602 41500.875 41441.164 42412.434 43840.285 44118.445
## [771] 44338.797 43565.113 42407.938 42244.469 42197.516 42586.918 44575.203
## [778] 43961.859 40538.012 40030.977 40122.156 38431.379 37075.281 38286.027
## [785] 37296.570 38332.609 39214.219 39105.148 37709.785 43193.234 44354.637
## [792] 43924.117 42451.789 39137.605 39400.586 38419.984 38062.039 38737.270
## [799] 41982.926 39437.461 38794.973 38904.012 37849.664 39666.754 39338.785
## [806] 41143.930 40951.379 41801.156 42190.652 41247.824 41077.996 42358.809
## [813] 42892.957 43960.934 44348.730 44500.828 46820.492 47128.004 47465.730
## [820] 47062.664 45538.676 46281.645 45868.949 46453.566 46622.676 45555.992
## [827] 43206.738 43503.848 42287.664 42782.137 42207.672 39521.902 40127.184
## [834] 41166.730 39935.516 40553.465 40424.484 39716.953 40826.215 41502.750
## [841] 41374.379 40527.363 39740.320 39486.730 39469.293 40458.309 38117.461
## [848] 39241.121 39773.828 38609.824 37714.875 38469.094 38529.328 37750.453
## [855] 39698.371 36575.141 36040.922 35501.953 34059.266 30296.953 31022.906
## [862] 28936.355 29047.752 29283.104 30101.266 31305.113 29862.918 30425.857
## [869] 28720.271 30314.334 29200.740 29432.227 30323.723 29098.910 29655.586
## [876] 29562.361 29267.225 28627.574 28814.900 29445.957 31726.391 31792.311
## [883] 29799.080 30467.488 29704.391 29832.914 29906.662 31370.672 31155.479
## [890] 30214.355 30111.998 29083.805 28360.811 26762.648 22487.389 22206.793
## [897] 22572.840 20381.650 20471.482 19017.643 20553.271 20599.537 20710.598
## [904] 19987.029 21085.877 21231.656 21502.338 21027.295 20735.479 20280.635
## [911] 20104.023 19784.727 19269.367 19242.256 19297.076 20231.262 20190.115
## [918] 20548.246 21637.588 21731.117 21592.207 20860.449 19970.557 19323.914
## [925] 20212.074 20569.920 20836.328 21190.316 20779.344 22485.689 23389.434
## [932] 23231.732 23164.629 22714.979 22465.479 22609.164 21361.701 21239.754
## [939] 22930.549 23843.887 23804.633 23656.207 23336.896 23314.199 22978.117
## [946] 22846.508 22630.957 23289.314 22961.279 23175.891 23809.486 23164.318
## [953] 23947.643 23957.529 24402.818 24424.068 24319.334 24136.973 23883.291
## [960] 23335.998 23212.738 20877.553 21166.061 21534.121 21398.908 21528.088
## [967] 21395.020 21600.904 20260.020 20041.738 19616.814 20297.994 19796.809
## [974] 20049.764 20127.141 19969.771 19832.088 19986.713 19812.371 18837.668
## [981] 19290.324 19329.834 21381.152 21680.539 21769.256 22370.449 20296.707
## [988] 20241.090 19701.211 19772.584 20127.576 19419.506 19544.129 18890.789
## [995] 18547.400 19413.551 19297.639 18937.012 18802.098 19222.672 19110.547
## [1002] 19426.721 19573.051 19431.789 19312.096 19044.107 19623.580 20336.844
## [1009] 20160.717 19955.443 19546.850 19416.568 19446.426 19141.484 19051.418
## [1016] 19157.445 19382.904 19185.656 19067.635 19268.094 19550.758 19334.416
## [1023] 19139.535 19053.740 19172.469 19208.189 19567.008 19345.572 20095.857
## [1030] 20770.441 20285.836 20595.352 20818.477 20635.604 20495.773 20485.273
## [1037] 20159.504 20209.988 21147.230 21282.691 20926.486 20602.816 18541.271
## [1044] 15880.780 17586.771 17034.293 16799.186 16353.365 16618.199 16884.613
## [1051] 16669.439 16687.518 16697.777 16711.547 16291.832 15787.284 16189.770
## [1058] 16610.707 16604.465 16521.842 16464.281 16444.627 16217.322 16444.982
## [1065] 17168.566 16967.133 17088.660 16908.236 17130.486 16974.826 17089.504
## [1072] 16848.127 17233.475 17133.152 17128.725 17104.193 17206.438 17781.318
## [1079] 17815.650 17364.865 16647.484 16795.092 16757.977 16439.680 16906.305
## [1086] 16817.535 16830.342 16796.953 16847.756 16841.986 16919.805 16717.174
## [1093] 16552.572 16642.342 16602.586 16547.496 16625.080 16688.471 16679.857
## [1100] 16863.238 16836.736 16951.969 16955.078 17091.145 17196.555 17446.293
## [1107] 17934.896 18869.588 19909.574 20976.299 20880.799 21169.633 21161.520
## [1114] 20688.781 21086.793 22676.553 22777.625 22720.416 22934.432 22636.469
## [1121] 23117.859 23032.777 23078.729 23031.090 23774.566 22840.139 23139.283
## [1128] 23723.770 23471.871 23449.322 23331.848 22955.666 22760.109 23264.291
## [1135] 22939.398 21819.039 21651.184 21870.875 21788.203 21808.102 22220.805
## [1142] 24307.842 23623.475 24565.602 24641.277 24327.643 24829.148 24436.354
## [1149] 24188.844 23947.492 23198.127 23175.375 23561.213 23522.871 23147.354
## [1156] 23646.551 23475.467 22362.680 22353.350 22435.514 22429.758 22219.770
## [1163] 21718.080 20363.021 20187.244 20632.410 22163.949 24197.533 24746.074
## [1170] 24375.961 25052.789 27423.930 26965.879 28038.676 27767.236 28175.816
## [1177] 27307.438 28333.973 27493.285 27494.707 27994.330 27139.889 27268.131
## [1184] 28348.441 28033.562 28478.484 28411.035 28199.309 27790.221 28168.090
## [1191] 28177.984 28044.141 27925.859 27947.795 28333.051 29652.980 30235.059
## [1198] 30139.053 30399.066 30485.699 30318.496 30315.355 29445.045 30397.553
## [1205] 28822.680 28245.988 27276.910 27817.500 27591.385 27525.340 28307.598
## [1212] 28422.701 29473.787 29340.262 29248.488 29268.807 28091.568 28680.537
## [1219] 29006.309 28847.711 29534.385 28904.623 28454.979 27694.273 27658.775
## [1226] 27621.756 27000.789 26804.990 26784.078 26930.639 27192.693 27036.650
## [1233] 27398.803 26832.209 26890.129 27129.586 26753.826 26851.277 27225.727
## [1240] 26334.818 26476.207 26719.291 26868.354 28085.646 27745.885 27702.350
## [1247] 27219.658 26819.973 27249.590 27075.129 27119.066 25760.098 27238.783
## [1254] 26345.998 26508.217 26480.375 25851.240 25940.168 25902.500 25918.729
## [1261] 25124.676 25576.395 26327.463 26510.676 26336.213 26851.029 28327.488
## [1268] 30027.297 29912.281 30695.469 30548.695 30480.262 30271.131 30688.164
## [1275] 30086.246 30445.352 30477.252 30590.078 30620.770 31156.439 30777.582
## [1282] 30514.166 29909.338 30342.266 30292.541 30171.234 30414.471 30620.951
## [1289] 30391.646 31476.049 30334.068 30295.807 30249.133 30145.889 29856.562
## [1296] 29913.924 29792.016 29908.744 29771.803 30084.539 29176.916 29227.391
## [1303] 29354.973 29210.689 29319.246 29356.918 29275.309 29230.111 29675.732
## [1310] 29151.959 29178.680 29074.092 29042.127 29041.855 29180.578 29765.492
## [1317] 29561.494 29429.592 29397.715 29415.965 29282.914 29408.443 29170.348
## [1324] 28701.779 26664.551 26049.557 26096.205 26189.584 26124.141 26031.656
## [1331] 26431.641 26162.373 26047.668 26008.463 26089.693 26106.150 27727.393
## [1338] 27297.266 25931.473 25800.725 25868.799 25969.566 25812.416 25779.982
## [1345] 25753.236 26240.195 25905.654 25895.678 25832.227 25162.654 25833.344
## [1352] 26228.324 26539.674 26608.693 26568.281 26534.188 26754.281 27211.117
## [1359] 27132.008 26567.633 26579.568 26579.391 26256.826 26298.480 26217.250
## [1366] 26352.717 27021.547 26911.721 26967.916 27983.750 27530.785 27429.979
## [1373] 27799.395 27415.912 27946.598 27968.840 27935.090 27583.678 27391.020
## [1380] 26873.320 26756.799 26862.375 26861.707 27159.652 28519.467 28415.748
## [1387] 28328.342 28719.807 29682.949 29918.412 29993.896 33086.234 33901.527
## [1394] 34502.820 34156.648 33909.801 34089.574 34538.480 34502.363 34667.781
## [1401] 35437.254 34938.242 34732.324 35082.195 35049.355 35037.371 35443.562
bit_close_zoo <- as.zoo(bitcoin_close_ts)
bit_close_df <- fortify.zoo((bit_close_zoo))
bit_close_df$Year <- floor(bit_close_df$Index)
bit_close_df$Days <- round((bit_close_df$Index - bit_close_df$Year) * 365.25)
bit_close_df$Date <- as.Date(paste0(bit_close_df$Year, "-01-01")) + bit_close_df$Days
hchart(bit_close_df, "line", hcaes(x = Date, y = bit_close_zoo)) %>%
hc_add_theme(hc_theme_darkunica())eth_chart <- hchart(eth_close_df, "line", hcaes(x = Date, y = eth_close_zoo),
name = "Ethereum") %>%
hc_add_theme(hc_theme_darkunica()) %>%
hc_title(text = "Comparación Ethereum vs Bitcoin") %>%
hc_xAxis(title = list(text = "Fecha")) %>%
hc_yAxis(title = list(text = "Precio de cierre"))
# Luego, agregamos la serie de Bitcoin al gráfico de Ethereum
combined_chart <- eth_chart %>%
hc_add_series(data = bit_close_df, type = "line",
hcaes(x = Date, y = bit_close_zoo), name = "Bitcoin")
# Mostrar el gráfico combinado
combined_chartprimer_valor_bit <- bit_close_df$`(bit_close_zoo)`[1]
# Normalizar las series de precios
eth_close_df$Close_norm <- eth_close_df$eth_close_zoo / eth_close_df$eth_close_zoo[1]
bit_close_df$Close_norm <- bit_close_df$`(bit_close_zoo)` / primer_valor_bit
# Crear gráfico combinado con series normalizadas
combined_chart_norm <- hchart(eth_close_df, "line", hcaes(x = Date, y = Close_norm), name = "Ethereum") %>%
hc_add_theme(hc_theme_darkunica()) %>%
hc_title(text = "Comparación de Tendencias Normalizadas: Ethereum vs Bitcoin") %>%
hc_xAxis(title = list(text = "Fecha")) %>%
hc_yAxis(title = list(text = "Cambio Relativo desde el Inicio")) %>%
hc_add_series(data = bit_close_df, type = "line", hcaes(x = Date, y = Close_norm), name = "Bitcoin")
# Mostrar el gráfico
combined_chart_normprimer_valor_bit <- bit_close_df$`(bit_close_zoo)`[1]
# Normalizar las series de precios
eth_close_df$Close_norm <- eth_close_df$eth_close_zoo / eth_close_df$eth_close_zoo[1]
bit_close_df$Close_norm <- bit_close_df$`(bit_close_zoo)` / primer_valor_bit
# Convertir las series normalizadas en una matriz con nombres de columnas
series_matrix <- cbind(eth = eth_close_df$Close_norm, btc = bit_close_df$Close_norm)
# Verifica que la matriz tiene los nombres de columnas correctos
colnames(series_matrix) <- c("eth", "btc")
# Utiliza la matriz para la prueba de cointegración
vecm <- ca.jo(series_matrix, ecdet = "const", type = "eigen", K = 18)
# Resumen de los resultados de la prueba de cointegración
summary(vecm)##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 1.103235e-02 3.749186e-03 3.469447e-18
##
## Values of teststatistic and critical values of test:
##
## test 10pct 5pct 1pct
## r <= 1 | 5.22 7.52 9.24 12.97
## r = 0 | 15.41 13.75 15.67 20.20
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
## eth.l18 btc.l18 constant
## eth.l18 1.000000 1.00000 1.000000
## btc.l18 -3.837225 13.57153 -1.273475
## constant 1.749204 -73.77702 18.441222
##
## Weights W:
## (This is the loading matrix)
##
## eth.l18 btc.l18 constant
## eth.d -0.018541122 -1.610937e-05 1.115584e-18
## btc.d -0.003090166 -1.958748e-04 8.367718e-20
# Determinar el número óptimo de retrasos
lag_selection <- VARselect(series_matrix, lag.max=20, type="both")
print(lag_selection)## $selection
## AIC(n) HQ(n) SC(n) FPE(n)
## 18 2 2 18
##
## $criteria
## 1 2 3 4 5
## AIC(n) -5.065682834 -5.115188478 -5.113933300 -5.110561888 -5.112267668
## HQ(n) -5.054390360 -5.098249768 -5.091348353 -5.082330704 -5.078390246
## SC(n) -5.035488755 -5.069897360 -5.053545143 -5.035076691 -5.021685431
## FPE(n) 0.006309601 0.006004847 0.006012389 0.006032695 0.006022416
## 6 7 8 9 10
## AIC(n) -5.119960198 -5.13087295 -5.129526139 -5.127456707 -5.133459822
## HQ(n) -5.080436539 -5.08570306 -5.078710007 -5.070994338 -5.071351216
## SC(n) -5.014280922 -5.01009663 -4.993652784 -4.976486313 -4.967392388
## FPE(n) 0.005976269 0.00591141 0.005919382 0.005931651 0.005896157
## 11 12 13 14 15
## AIC(n) -5.129121024 -5.131743149 -5.130771479 -5.133274490 -5.128491719
## HQ(n) -5.061366182 -5.058342069 -5.051724163 -5.048580936 -5.038151929
## SC(n) -4.947956551 -4.935481636 -4.919412927 -4.906818898 -4.886939088
## FPE(n) 0.005921804 0.005906308 0.005912063 0.005897298 0.005925588
## 16 17 18 19 20
## AIC(n) -5.135275947 -5.137447717 -5.143545723 -5.139053494 -5.140157410
## HQ(n) -5.039289920 -5.035815453 -5.036267222 -5.026128756 -5.021586435
## SC(n) -4.878626277 -4.865701008 -4.856701974 -4.837112705 -4.823119582
## FPE(n) 0.005885543 0.005872796 0.005837117 0.005863424 0.005856985
# Ajusta un modelo VECM a tus datos
# El argumento 'r' es el número de relaciones de cointegración, que parece ser 1 basado en tus resultados
# El argumento 'lag' debe ser seleccionado basado en criterios de información como AIC o BIC
vecm_model <- VECM(series_matrix, lag=18, r=1, include="const")
# Muestra el resumen del modelo
summary(vecm_model)## #############
## ###Model VECM
## #############
## Full sample size: 1407 End sample size: 1388
## Number of variables: 2 Number of estimated slope parameters 76
## AIC -7134.037 BIC -6730.895 SSR 595.3997
## Cointegrating vector (estimated by 2OLS):
## eth btc
## r1 1 -3.339873
##
##
## ECT Intercept eth -1
## Equation eth -0.0178(0.0048)*** 0.0046(0.0174) -0.1741(0.0374)***
## Equation btc -0.0034(0.0012)** 0.0021(0.0043) -0.0294(0.0092)**
## btc -1 eth -2 btc -2
## Equation eth 1.0102(0.1530)*** 0.0726(0.0375). -0.2771(0.1559).
## Equation btc 0.0592(0.0377) -0.0021(0.0092) 0.0244(0.0384)
## eth -3 btc -3 eth -4
## Equation eth 0.0310(0.0375) -0.0324(0.1565) 0.0313(0.0374)
## Equation btc -0.0004(0.0092) 0.0232(0.0385) 0.0150(0.0092)
## btc -4 eth -5 btc -5
## Equation eth 0.0827(0.1564) -0.1032(0.0374)** 0.1576(0.1565)
## Equation btc -0.0279(0.0385) -0.0171(0.0092). 0.0518(0.0385)
## eth -6 btc -6 eth -7
## Equation eth 0.1307(0.0374)*** -0.2765(0.1562). 0.0389(0.0376)
## Equation btc 0.0045(0.0092) 0.0102(0.0384) 0.0016(0.0093)
## btc -7 eth -8 btc -8
## Equation eth -0.2065(0.1566) -0.0151(0.0376) -0.2256(0.1568)
## Equation btc -0.0649(0.0386). -0.0057(0.0093) -0.0396(0.0386)
## eth -9 btc -9 eth -10
## Equation eth -0.0409(0.0376) 0.4625(0.1568)** 0.0154(0.0376)
## Equation btc -0.0181(0.0092). 0.1394(0.0386)*** 0.0065(0.0093)
## btc -10 eth -11 btc -11
## Equation eth -0.0133(0.1573) -0.1220(0.0376)** 0.3227(0.1571)*
## Equation btc -0.0077(0.0387) -0.0208(0.0093)* 0.0559(0.0387)
## eth -12 btc -12 eth -13
## Equation eth 0.0840(0.0377)* -0.4515(0.1572)** 0.0405(0.0376)
## Equation btc 0.0090(0.0093) -0.0751(0.0387). -0.0058(0.0092)
## btc -13 eth -14 btc -14
## Equation eth -0.3127(0.1572)* -0.0032(0.0375) -0.0997(0.1578)
## Equation btc 0.0246(0.0387) -0.0011(0.0092) -0.0130(0.0388)
## eth -15 btc -15 eth -16
## Equation eth -0.1082(0.0374)** 0.3682(0.1574)* 0.0071(0.0375)
## Equation btc -0.0115(0.0092) 0.0134(0.0387) -0.0016(0.0092)
## btc -16 eth -17 btc -17
## Equation eth -0.3090(0.1582). 0.0225(0.0374) 0.2660(0.1582).
## Equation btc -0.0167(0.0389) 0.0091(0.0092) -0.0231(0.0389)
## eth -18 btc -18
## Equation eth -0.0268(0.0367) 0.0394(0.1575)
## Equation btc -0.0114(0.0090) 0.0324(0.0388)
# Pronosticar los próximos valores usando el modelo VECM
forecast <- predict(vecm_model, n.ahead = 10)
# La salida de 'forecast' incluirá los pronósticos para cada una de las variables en el modelo
# Puedes extraer los pronósticos para Ethereum y Bitcoin así:
eth_forecast <- forecast[, "eth", drop = FALSE]
# Revertir la normalización para Ethereum
eth_forecast_real <- eth_forecast * eth_close_df$eth_close_zoo[1]
tabla_predicciones <- data.frame(
Fecha = fechas_correctas,
Real = ultimos_10_dias,
ProphetLog = forecast_prophet_log_values,
RedNeuronal = predicciones_desnorm_values,
RedNeuronal_Jordan = predictions_desnorm_values_jor,
Ethereum_vec = eth_forecast_real
)
tabla_predicciones## Fecha Real ProphetLog RedNeuronal RedNeuronal_Jordan eth
## [1398,] 2023-11-08 1888.25 1692.825 1749.890 1822.712 1884.876
## [1399,] 2023-11-09 2060.14 1684.167 1783.962 1827.257 1905.037
## [1400,] 2023-11-10 2094.24 1674.565 1813.334 1840.494 1909.345
## [1401,] 2023-11-11 2044.75 1666.843 1817.619 1881.253 1920.794
## [1402,] 2023-11-12 2060.08 1666.858 1832.389 1830.064 1923.933
## [1403,] 2023-11-13 2061.00 1659.992 1878.446 1855.733 1929.599
## [1404,] 2023-11-14 1981.95 1661.086 1798.769 1866.145 1921.229
## [1405,] 2023-11-15 2048.93 1660.127 1844.933 1897.740 1933.981
## [1406,] 2023-11-16 1956.32 1657.106 1851.229 1920.360 1939.024
## [1407,] 2023-11-17 1946.60 1653.903 1890.232 1921.662 1941.101
grafico <- ggplot(tabla_predicciones, aes(x=Fecha)) +
geom_line(aes(y=Real, colour="Real")) +
geom_line(aes(y=ProphetLog, colour="Prophet Log")) +
geom_line(aes(y=RedNeuronal, colour="Red Neuronal Elman")) +
geom_line(aes(y=RedNeuronal_Jordan, colour = "Red Neuronal Jordan"))+
geom_line(aes(y=eth, colour = "Modelo Vec"))+
labs(title="Comparación de Predicciones vs Datos Reales", x="Fecha", y="Valor") +
scale_color_manual(name="Leyenda",
values=c("Real"="black",
"Prophet Log"="blue",
"Red Neuronal Elman"="purple",
"Modelo Vec" = "red",
"Red Neuronal Jordan"="green")) +
theme_minimal() +
theme(legend.position="bottom")
grafico# Asumiendo que 'vec' es tu modelo VEC ajustado
var_model <- vec2var(vecm, r = 1) # 'r' es el número de relaciones de cointegración
serial_test <- serial.test(var_model, lags.pt = 18, type = "PT.asymptotic")
print(serial_test$serial)##
## Portmanteau Test (asymptotic)
##
## data: Residuals of VAR object var_model
## Chi-squared = 6.7057, df = 2, p-value = 0.03498
## $JB
##
## JB-Test (multivariate)
##
## data: Residuals of VAR object var_model
## Chi-squared = 10591, df = 4, p-value < 2.2e-16
##
##
## $Skewness
##
## Skewness only (multivariate)
##
## data: Residuals of VAR object var_model
## Chi-squared = 171.93, df = 2, p-value < 2.2e-16
##
##
## $Kurtosis
##
## Kurtosis only (multivariate)
##
## data: Residuals of VAR object var_model
## Chi-squared = 10419, df = 2, p-value < 2.2e-16
##
## ARCH (multivariate)
##
## data: Residuals of VAR object var_model
## Chi-squared = 983.33, df = 162, p-value < 2.2e-16