Forecasting using ARDL model in R

Hey, I am working on this data where I have used the ARDL model but, when I try to forecast the next future intervals it gives me an error. Though the model output is good I want to see the forecasting plots. Plus, I have used the ardlDlm function to obtain model output. Can someone please help me? Below is the data attached.

Data:

structure(list(Date = structure(c(1617235200, 1617321600, 1617408000, 
1617494400, 1617580800, 1617667200, 1617753600, 1617840000, 1617926400, 
1618012800, 1618099200, 1618185600, 1618272000, 1618358400, 1618444800, 
1618531200, 1618617600, 1618704000, 1618790400, 1618876800, 1618963200, 
1619049600, 1619136000, 1619222400, 1619308800, 1619395200, 1619481600, 
1619568000, 1619654400, 1619740800, 1619827200, 1619913600, 1.62e+09, 
1620086400, 1620172800, 1620259200, 1620345600, 1620432000, 1620518400, 
1620604800, 1620691200, 1620777600, 1620864000, 1620950400, 1621036800, 
1621123200, 1621209600, 1621296000, 1621382400, 1621468800, 1621555200, 
1621641600, 1621728000, 1621814400, 1621900800, 1621987200, 1622073600, 
1622160000, 1622246400, 1622332800, 1622419200, 1622505600, 1622592000, 
1622678400, 1622764800, 1622851200, 1622937600, 1623024000, 1623110400, 
1623196800, 1623283200, 1623369600, 1623456000, 1623542400, 1623628800, 
1623715200, 1623801600, 1623888000, 1623974400, 1624060800, 1624147200, 
1624233600, 1624320000, 1624406400, 1624492800, 1624579200, 1624665600, 
1624752000, 1624838400, 1624924800, 1625011200, 1625097600, 1625184000, 
1625270400, 1625356800, 1625443200, 1625529600, 1625616000, 1625702400, 
1625788800, 1625875200, 1625961600, 1626048000, 1626134400, 1626220800, 
1626307200, 1626393600, 1626480000, 1626566400, 1626652800, 1626739200, 
1626825600, 1626912000, 1626998400, 1627084800, 1627171200, 1627257600, 
1627344000, 1627430400, 1627516800, 1627603200, 1627689600, 1627776000, 
1627862400, 1627948800, 1628035200, 1628121600, 1628208000, 1628294400, 
1628380800, 1628467200, 1628553600, 1628640000, 1628726400, 1628812800, 
1628899200, 1628985600, 1629072000, 1629158400, 1629244800, 1629331200, 
1629417600, 1629504000, 1629590400, 1629676800, 1629763200, 1629849600, 
1629936000, 1630022400, 1630108800, 1630195200, 1630281600, 1630368000, 
1630454400, 1630540800, 1630627200, 1630713600, 1630800000, 1630886400, 
1630972800, 1631059200, 1631145600, 1631232000, 1631318400, 1631404800, 
1631491200, 1631577600, 1631664000, 1631750400, 1631836800, 1631923200, 
1632009600, 1632096000, 1632182400, 1632268800, 1632355200, 1632441600, 
1632528000, 1632614400, 1632700800, 1632787200, 1632873600, 1632960000, 
1633046400, 1633132800, 1633219200, 1633305600, 1633392000, 1633478400, 
1633564800, 1633651200, 1633737600, 1633824000, 1633910400, 1633996800, 
1634083200, 1634169600, 1634256000, 1634342400, 1634428800, 1634515200, 
1634601600, 1634688000, 1634774400, 1634860800, 1634947200, 1635033600, 
1635120000, 1635206400, 1635292800, 1635379200, 1635465600, 1635552000, 
1635638400, 1635724800, 1635811200, 1635897600, 1635984000, 1636070400, 
1636156800, 1636243200, 1636329600, 1636416000, 1636502400, 1636588800, 
1636675200, 1636761600, 1636848000, 1636934400, 1637020800, 1637107200, 
1637193600, 1637280000, 1637366400, 1637452800, 1637539200, 1637625600, 
1637712000, 1637798400, 1637884800, 1637971200, 1638057600, 1638144000, 
1638230400, 1638316800, 1638403200, 1638489600, 1638576000, 1638662400, 
1638748800, 1638835200, 1638921600, 1639008000, 1639094400, 1639180800, 
1639267200, 1639353600, 1639440000, 1639526400, 1639612800, 1639699200, 
1639785600, 1639872000, 1639958400, 1640044800, 1640131200, 1640217600, 
1640304000, 1640390400, 1640476800, 1640563200, 1640649600, 1640736000, 
1640822400, 1640908800, 1640995200, 1641081600, 1641168000, 1641254400, 
1641340800, 1641427200, 1641513600, 1641600000, 1641686400, 1641772800, 
1641859200, 1641945600, 1642032000, 1642118400, 1642204800, 1642291200, 
1642377600, 1642464000, 1642550400, 1642636800, 1642723200, 1642809600, 
1642896000, 1642982400, 1643068800, 1643155200, 1643241600, 1643328000, 
1643414400, 1643500800, 1643587200, 1643673600, 1643760000, 1643846400, 
1643932800, 1644019200, 1644105600, 1644192000, 1644278400, 1644364800, 
1644451200, 1644537600, 1644624000, 1644710400, 1644796800, 1644883200, 
1644969600, 1645056000, 1645142400, 1645228800, 1645315200, 1645401600, 
1645488000, 1645574400, 1645660800, 1645747200, 1645833600, 1645920000, 
1646006400, 1646092800, 1646179200, 1646265600, 1646352000, 1646438400, 
1646524800, 1646611200, 1646697600, 1646784000, 1646870400, 1646956800, 
1647043200, 1647129600, 1647216000, 1647302400, 1647388800, 1647475200, 
1647561600, 1647648000, 1647734400, 1647820800, 1647907200, 1647993600, 
1648080000, 1648166400, 1648252800, 1648339200, 1648425600, 1648512000, 
1648598400, 1648684800, 1648771200, 1648857600, 1648944000, 1649030400, 
1649116800, 1649203200, 1649289600, 1649376000, 1649462400, 1649548800, 
1649635200, 1649721600, 1649808000, 1649894400, 1649980800, 1650067200, 
1650153600, 1650240000, 1650326400, 1650412800, 1650499200, 1650585600, 
1650672000, 1650758400, 1650844800, 1650931200, 1651017600, 1651104000, 
1651190400, 1651276800, 1651363200, 1651449600, 1651536000, 1651622400, 
1651708800, 1651795200, 1651881600, 1651968000, 1652054400, 1652140800, 
1652227200, 1652313600, 1652400000, 1652486400, 1652572800, 1652659200, 
1652745600, 1652832000, 1652918400, 1653004800), class = c("POSIXct", 
"POSIXt"), tzone = "UTC"), Inflation = structure(c(2.62, 2.723, 
2.774, 2.825, 2.877, 2.928, 2.979, 3.031, 3.082, 3.133, 3.185, 
3.236, 3.287, 3.339, 3.39, 3.441, 3.493, 3.544, 3.595, 3.647, 
3.698, 3.749, 3.801, 3.852, 3.903, 3.955, 4.006, 4.057, 4.109, 
4.16, 4.16, 4.214, 4.24, 4.267, 4.294, 4.321, 4.347, 4.374, 4.401, 
4.428, 4.455, 4.481, 4.508, 4.535, 4.562, 4.588, 4.615, 4.642, 
4.669, 4.695, 4.722, 4.749, 4.776, 4.803, 4.829, 4.856, 4.883, 
4.91, 4.936, 4.963, 4.99, 4.99, 5.016, 5.029, 5.042, 5.055, 5.067, 
5.08, 5.093, 5.106, 5.119, 5.132, 5.145, 5.158, 5.171, 5.184, 
5.196, 5.209, 5.222, 5.235, 5.248, 5.261, 5.274, 5.287, 5.3, 
5.313, 5.325, 5.338, 5.351, 5.364, 5.377, 5.39, 5.389, 5.388, 
5.387, 5.387, 5.386, 5.385, 5.385, 5.384, 5.384, 5.383, 5.382, 
5.382, 5.381, 5.38, 5.38, 5.379, 5.378, 5.378, 5.377, 5.376, 
5.376, 5.375, 5.375, 5.374, 5.373, 5.373, 5.372, 5.371, 5.371, 
5.37, 5.37, 5.362, 5.358, 5.355, 5.351, 5.347, 5.343, 5.339, 
5.335, 5.331, 5.327, 5.324, 5.32, 5.316, 5.312, 5.308, 5.304, 
5.3, 5.296, 5.293, 5.289, 5.285, 5.281, 5.277, 5.273, 5.269, 
5.265, 5.262, 5.258, 5.254, 5.25, 5.22, 5.231, 5.237, 5.243, 
5.248, 5.254, 5.26, 5.265, 5.271, 5.277, 5.282, 5.288, 5.294, 
5.299, 5.305, 5.311, 5.316, 5.322, 5.328, 5.333, 5.339, 5.345, 
5.35, 5.356, 5.362, 5.367, 5.373, 5.379, 5.384, 5.39, 5.39, 5.444, 
5.47, 5.497, 5.524, 5.551, 5.577, 5.604, 5.631, 5.658, 5.685, 
5.711, 5.738, 5.765, 5.792, 5.818, 5.845, 5.872, 5.899, 5.925, 
5.952, 5.979, 6.006, 6.033, 6.059, 6.086, 6.113, 6.14, 6.166, 
6.193, 6.22, 6.22, 6.259, 6.279, 6.299, 6.318, 6.338, 6.358, 
6.377, 6.397, 6.417, 6.436, 6.456, 6.476, 6.495, 6.515, 6.535, 
6.554, 6.574, 6.594, 6.613, 6.633, 6.653, 6.672, 6.692, 6.712, 
6.731, 6.751, 6.771, 6.79, 6.81, 6.8, 6.815, 6.823, 6.831, 6.839, 
6.846, 6.854, 6.862, 6.87, 6.877, 6.885, 6.893, 6.901, 6.908, 
6.916, 6.924, 6.932, 6.939, 6.947, 6.955, 6.963, 6.97, 6.978, 
6.986, 6.994, 7.001, 7.009, 7.017, 7.025, 7.032, 7.04, 7.05, 
7.068, 7.083, 7.097, 7.111, 7.125, 7.139, 7.154, 7.168, 7.182, 
7.196, 7.21, 7.225, 7.239, 7.253, 7.267, 7.281, 7.295, 7.31, 
7.324, 7.338, 7.352, 7.366, 7.381, 7.395, 7.409, 7.423, 7.437, 
7.452, 7.466, 7.48, 7.48, 7.508, 7.522, 7.536, 7.55, 7.564, 7.577, 
7.591, 7.605, 7.619, 7.633, 7.647, 7.661, 7.675, 7.689, 7.703, 
7.717, 7.731, 7.745, 7.759, 7.772, 7.786, 7.8, 7.814, 7.828, 
7.842, 7.856, 7.87, 7.87, 7.913, 7.935, 7.956, 7.978, 8, 8.021, 
8.043, 8.065, 8.086, 8.108, 8.129, 8.151, 8.173, 8.194, 8.216, 
8.237, 8.259, 8.281, 8.302, 8.324, 8.345, 8.367, 8.389, 8.41, 
8.432, 8.454, 8.475, 8.497, 8.518, 8.54, 8.54, 7.976, 7.694, 
7.412, 7.13, 6.849, 6.567, 6.285, 6.003, 5.721, 5.439, 5.157, 
4.875, 4.593, 4.311, 4.029, 3.747, 3.466, 3.184, 2.902, 2.62, 
2.338, 2.056, 1.774, 1.492, 1.21, 0.928, 0.646, 0.365, 8.26, 
8.26, 8.281, 8.291, 8.301, 8.312, 8.322, 8.332, 8.343, 8.353, 
8.363, 8.374, 8.384, 8.394, 8.405, 8.415, 8.425, 8.435, 8.446, 
8.456, 8.466), tsp = c(2021.00821917808, 2022.14246575342, 365
), class = "ts"), `ATOM-USD.Close` = c(0, 0.768450999999999, 
-0.144307999999999, 1.469351, -0.275023000000001, 0.310776000000001, 
-2.190437, 0.935952999999998, 0.880585, -0.343722, 2.290039, 
-1.299675, 1.819661, 3.235397, 0.872935999999999, -2.396992, 
-0.929673999999999, -3.269912, -2.092005, 1.964466, -1.614958, 
-0.862821, 1.705257, -2.08337, 0.256457999999999, 3.423559, 0.974142000000001, 
-0.0914530000000013, -0.831892, 0.602709000000001, 1.091922, 
-0.722394999999999, -0.129787, -1.925188, 3.720419, 0.770569000000002, 
3.213972, 0.687902000000001, -0.655598000000001, -3.443265, 1.569681, 
-4.227759, 0.869804999999999, 2.220243, -1.188532, -0.255972, 
-3.21471, 1.71472, -8.886411, 3.061078, -3.436362, -1.324223, 
-0.499362, 2.704111, -0.531815999999999, 1.353158, -0.844422, 
-1.701433, -0.649756999999999, 0.520512999999999, 1.405285, -0.236704000000001, 
1.095375, 1.784502, -1.552568, -0.210929, 0.225085999999999, 
-1.684433, 0.216416000000001, 0.308268, -1.130974, -0.871013, 
-0.318483000000001, 0.881482, 0.110932999999999, 0.749215000000001, 
0.0211449999999989, 0.218928, -1.170834, -0.487976, 0.0718540000000001, 
-2.465136, -0.574975, 1.124191, 0.242291, -1.198673, 0.402508000000001, 
0.506065999999999, 0.799098000000001, 0.730930000000001, 0.423803999999999, 
-0.893127, 0.654536, 0.0530019999999993, 0.445621000000001, 1.284927, 
-0.389104, -0.232984999999999, -0.997703000000001, 1.236016, 
1.236248, -0.338352, -1.016938, -0.932185, -0.364051, -0.318175, 
-0.252107000000001, -0.178977999999999, -0.0171030000000005, 
-1.02411, -0.473234, 0.931471999999999, 0.959963, 0.0827190000000009, 
-0.0077619999999996, -0.000346000000000402, -0.0436779999999999, 
0.30551, -0.155068, 0.20257, 0.38923, 0.456327, -0.244622999999999, 
0.124689999999999, -0.39812, 0.698427000000001, 0.237, 0.556457999999999, 
0.426603, -0.874836999999999, 0.549841000000001, 0.412205999999999, 
0.505001999999999, -0.560478999999999, 1.168624, 0.344392000000001, 
0.353116, -0.0516909999999999, 0.140777, 2.003192, 0.684851999999999, 
0.239771000000001, 3.172934, -0.237224999999999, -0.0263080000000002, 
-2.206606, 0.348984000000002, -2.003077, 2.489323, 0.876179, 
-0.134996999999998, 0.899183999999998, 0.771856, 2.4799, -1.207744, 
-0.00914799999999971, 0.299163999999998, 1.321087, -0.638766, 
-4.210718, -0.376631, 6.474625, 2.438278, -2.15608, 7.713537, 
0.629016999999997, -1.523784, 0.0270690000000045, 2.773891, -3.49248100000001, 
7.44105500000001, 3.688419, -10.750675, -3.349855, 9.54159, 1.531383, 
1.278389, -3.278534, 0.104503999999999, -2.278534, -3.67284, 
0.282314, 2.261578, 1.625148, 0.919708999999997, 0.0336989999999986, 
-2.073223, 0.0129009999999994, -1.519318, 1.516537, -1.744041, 
0.234271999999997, -2.70319, -0.445202000000002, 1.403038, 1.176601, 
-0.872917000000001, -0.765926, 0.129284000000006, -0.725151000000004, 
-0.528548000000001, 3.243456, 0.751412000000002, -1.551045, -0.288059000000004, 
1.7323, -1.47863, 0.976157999999998, 7.94501899999999, -6.45402199999999, 
1.303494, 1.351371, -2.146354, -0.00766399999999834, 0.0947379999999995, 
-0.291747999999998, 1.352718, -0.902290000000001, -0.614044, 
-0.602741999999999, -0.583190000000002, 0.980506000000005, -0.858833000000004, 
-3.726265, 0.965676000000002, -1.04041700000001, 0.511337000000005, 
-0.667852000000003, -0.448801, -3.02043, 0.959962999999998, -2.72793, 
1.497579, 1.277567, 1.621226, 1.028556, 0.061557999999998, -1.715387, 
-0.628062999999997, -2.8534, -0.147214000000002, 0.618652000000001, 
0.721138, -0.576170000000001, -0.840225, 1.665653, 4.300472, 
-4.549656, -3.500671, -0.207899000000001, -0.0406820000000003, 
0.866524000000002, -2.747341, 0.0804520000000011, 1.835981, 0.161943000000001, 
-2.813638, -0.547495000000001, 1.082788, -0.542214999999999, 
-0.536637000000002, 1.963313, -1.03714, -0.637018000000001, 2.088718, 
3.698553, 1.052443, -1.450688, 2.721859, 2.587021, -2.568958, 
-3.008051, 1.337461, 2.292092, 2.213127, 3.70072200000001, -0.567009000000006, 
3.69661300000001, 2.687057, -3.193767, 1.377167, -1.639939, -2.61787, 
-0.937126000000006, 2.87719300000001, 0.884902999999994, 1.45171800000001, 
-2.558762, 2.830845, -1.238228, 4.382153, -4.396325, -0.894850999999996, 
-1.19896, 1.94291, -4.64021, -5.267585, 5.24646, 1.509849, -0.106417999999998, 
-3.45520800000001, -2.252901, -0.634284999999998, -0.392779000000001, 
-1.905815, 0.978232999999999, 0.798630000000003, -2.560585, 3.105929, 
1.551475, -0.234009, 0.452113000000001, 0.423272999999998, -1.193898, 
0.421952000000001, -1.76335, -2.589596, 0.494384999999998, -0.697737, 
0.833891000000001, 1.758135, -0.404425999999997, -0.539122000000003, 
-1.034979, -0.270755999999999, -0.447303000000002, -2.401129, 
1.021316, 0.425722, -0.342366999999999, 2.280836, 2.581465, -3.055836, 
4.674464, -0.308033000000002, 1.105852, 1.8862, -3.561177, 0.439312000000001, 
-2.860038, 0.281640999999997, -0.564084999999999, 2.25436, -2.054669, 
-0.516483000000001, -0.309881000000001, -0.921832999999999, 0.542701999999998, 
0.0692550000000018, 2.091132, -0.821338999999998, 0.519311999999999, 
-0.053370000000001, -0.850424999999998, 0.190307000000001, 0.0597499999999975, 
0.165512, 0.983316000000002, -1.061737, 0.687360999999999, 1.07477, 
-0.437861999999999, 0.811810999999999, -0.164674999999999, -1.207012, 
0.491052999999997, 2.002691, 0.570558999999999, -1.068854, -1.565735, 
-2.428472, 0.824852, -0.849135999999998, 0.406713, -0.688822000000002, 
-2.805074, 0.860166000000003, 0.0575009999999985, -0.731065999999998, 
0.136664999999997, 0.0878300000000003, -0.899767000000001, 0.758488000000003, 
0.590805, -0.353554000000003, -0.986991999999997, -0.215914000000001, 
0.181602999999999, -0.941174, -0.196431999999998, -1.78718, 1.159562, 
-0.751888999999998, -1.274645, -1.598838, 0.145472999999999, 
-0.213269999999998, -0.219610000000003, 2.283331, -2.023577, 
-0.179175000000001, -1.198112, -0.778647000000001, -2.89238, 
0.799073, -2.876914, -1.017805, 0.604222, 0.511077999999999, 
1.527941, -1.334906, 0.460435, -1.336386, 0.718935, 0.345134)), class = "data.frame", row.names = c("2021-04-01", 
"2021-04-02", "2021-04-03", "2021-04-04", "2021-04-05", "2021-04-06", 
"2021-04-07", "2021-04-08", "2021-04-09", "2021-04-10", "2021-04-11", 
"2021-04-12", "2021-04-13", "2021-04-14", "2021-04-15", "2021-04-16", 
"2021-04-17", "2021-04-18", "2021-04-19", "2021-04-20", "2021-04-21", 
"2021-04-22", "2021-04-23", "2021-04-24", "2021-04-25", "2021-04-26", 
"2021-04-27", "2021-04-28", "2021-04-29", "2021-04-30", "2021-05-01", 
"2021-05-02", "2021-05-03", "2021-05-04", "2021-05-05", "2021-05-06", 
"2021-05-07", "2021-05-08", "2021-05-09", "2021-05-10", "2021-05-11", 
"2021-05-12", "2021-05-13", "2021-05-14", "2021-05-15", "2021-05-16", 
"2021-05-17", "2021-05-18", "2021-05-19", "2021-05-20", "2021-05-21", 
"2021-05-22", "2021-05-23", "2021-05-24", "2021-05-25", "2021-05-26", 
"2021-05-27", "2021-05-28", "2021-05-29", "2021-05-30", "2021-05-31", 
"2021-06-01", "2021-06-02", "2021-06-03", "2021-06-04", "2021-06-05", 
"2021-06-06", "2021-06-07", "2021-06-08", "2021-06-09", "2021-06-10", 
"2021-06-11", "2021-06-12", "2021-06-13", "2021-06-14", "2021-06-15", 
"2021-06-16", "2021-06-17", "2021-06-18", "2021-06-19", "2021-06-20", 
"2021-06-21", "2021-06-22", "2021-06-23", "2021-06-24", "2021-06-25", 
"2021-06-26", "2021-06-27", "2021-06-28", "2021-06-29", "2021-06-30", 
"2021-07-01", "2021-07-02", "2021-07-03", "2021-07-04", "2021-07-05", 
"2021-07-06", "2021-07-07", "2021-07-08", "2021-07-09", "2021-07-10", 
"2021-07-11", "2021-07-12", "2021-07-13", "2021-07-14", "2021-07-15", 
"2021-07-16", "2021-07-17", "2021-07-18", "2021-07-19", "2021-07-20", 
"2021-07-21", "2021-07-22", "2021-07-23", "2021-07-24", "2021-07-25", 
"2021-07-26", "2021-07-27", "2021-07-28", "2021-07-29", "2021-07-30", 
"2021-07-31", "2021-08-01", "2021-08-02", "2021-08-03", "2021-08-04", 
"2021-08-05", "2021-08-06", "2021-08-07", "2021-08-08", "2021-08-09", 
"2021-08-10", "2021-08-11", "2021-08-12", "2021-08-13", "2021-08-14", 
"2021-08-15", "2021-08-16", "2021-08-17", "2021-08-18", "2021-08-19", 
"2021-08-20", "2021-08-21", "2021-08-22", "2021-08-23", "2021-08-24", 
"2021-08-25", "2021-08-26", "2021-08-27", "2021-08-28", "2021-08-29", 
"2021-08-30", "2021-08-31", "2021-09-01", "2021-09-02", "2021-09-03", 
"2021-09-04", "2021-09-05", "2021-09-06", "2021-09-07", "2021-09-08", 
"2021-09-09", "2021-09-10", "2021-09-11", "2021-09-12", "2021-09-13", 
"2021-09-14", "2021-09-15", "2021-09-16", "2021-09-17", "2021-09-18", 
"2021-09-19", "2021-09-20", "2021-09-21", "2021-09-22", "2021-09-23", 
"2021-09-24", "2021-09-25", "2021-09-26", "2021-09-27", "2021-09-28", 
"2021-09-29", "2021-09-30", "2021-10-01", "2021-10-02", "2021-10-03", 
"2021-10-04", "2021-10-05", "2021-10-06", "2021-10-07", "2021-10-08", 
"2021-10-09", "2021-10-10", "2021-10-11", "2021-10-12", "2021-10-13", 
"2021-10-14", "2021-10-15", "2021-10-16", "2021-10-17", "2021-10-18", 
"2021-10-19", "2021-10-20", "2021-10-21", "2021-10-22", "2021-10-23", 
"2021-10-24", "2021-10-25", "2021-10-26", "2021-10-27", "2021-10-28", 
"2021-10-29", "2021-10-30", "2021-10-31", "2021-11-01", "2021-11-02", 
"2021-11-03", "2021-11-04", "2021-11-05", "2021-11-06", "2021-11-07", 
"2021-11-08", "2021-11-09", "2021-11-10", "2021-11-11", "2021-11-12", 
"2021-11-13", "2021-11-14", "2021-11-15", "2021-11-16", "2021-11-17", 
"2021-11-18", "2021-11-19", "2021-11-20", "2021-11-21", "2021-11-22", 
"2021-11-23", "2021-11-24", "2021-11-25", "2021-11-26", "2021-11-27", 
"2021-11-28", "2021-11-29", "2021-11-30", "2021-12-01", "2021-12-02", 
"2021-12-03", "2021-12-04", "2021-12-05", "2021-12-06", "2021-12-07", 
"2021-12-08", "2021-12-09", "2021-12-10", "2021-12-11", "2021-12-12", 
"2021-12-13", "2021-12-14", "2021-12-15", "2021-12-16", "2021-12-17", 
"2021-12-18", "2021-12-19", "2021-12-20", "2021-12-21", "2021-12-22", 
"2021-12-23", "2021-12-24", "2021-12-25", "2021-12-26", "2021-12-27", 
"2021-12-28", "2021-12-29", "2021-12-30", "2021-12-31", "2022-01-01", 
"2022-01-02", "2022-01-03", "2022-01-04", "2022-01-05", "2022-01-06", 
"2022-01-07", "2022-01-08", "2022-01-09", "2022-01-10", "2022-01-11", 
"2022-01-12", "2022-01-13", "2022-01-14", "2022-01-15", "2022-01-16", 
"2022-01-17", "2022-01-18", "2022-01-19", "2022-01-20", "2022-01-21", 
"2022-01-22", "2022-01-23", "2022-01-24", "2022-01-25", "2022-01-26", 
"2022-01-27", "2022-01-28", "2022-01-29", "2022-01-30", "2022-01-31", 
"2022-02-01", "2022-02-02", "2022-02-03", "2022-02-04", "2022-02-05", 
"2022-02-06", "2022-02-07", "2022-02-08", "2022-02-09", "2022-02-10", 
"2022-02-11", "2022-02-12", "2022-02-13", "2022-02-14", "2022-02-15", 
"2022-02-16", "2022-02-17", "2022-02-18", "2022-02-19", "2022-02-20", 
"2022-02-21", "2022-02-22", "2022-02-23", "2022-02-24", "2022-02-25", 
"2022-02-26", "2022-02-27", "2022-02-28", "2022-03-01", "2022-03-02", 
"2022-03-03", "2022-03-04", "2022-03-05", "2022-03-06", "2022-03-07", 
"2022-03-08", "2022-03-09", "2022-03-10", "2022-03-11", "2022-03-12", 
"2022-03-13", "2022-03-14", "2022-03-15", "2022-03-16", "2022-03-17", 
"2022-03-18", "2022-03-19", "2022-03-20", "2022-03-21", "2022-03-22", 
"2022-03-23", "2022-03-24", "2022-03-25", "2022-03-26", "2022-03-27", 
"2022-03-28", "2022-03-29", "2022-03-30", "2022-03-31", "2022-04-01", 
"2022-04-02", "2022-04-03", "2022-04-04", "2022-04-05", "2022-04-06", 
"2022-04-07", "2022-04-08", "2022-04-09", "2022-04-10", "2022-04-11", 
"2022-04-12", "2022-04-13", "2022-04-14", "2022-04-15", "2022-04-16", 
"2022-04-17", "2022-04-18", "2022-04-19", "2022-04-20", "2022-04-21", 
"2022-04-22", "2022-04-23", "2022-04-24", "2022-04-25", "2022-04-26", 
"2022-04-27", "2022-04-28", "2022-04-29", "2022-04-30", "2022-05-01", 
"2022-05-02", "2022-05-03", "2022-05-04", "2022-05-05", "2022-05-06", 
"2022-05-07", "2022-05-08", "2022-05-09", "2022-05-10", "2022-05-11", 
"2022-05-12", "2022-05-13", "2022-05-14", "2022-05-15", "2022-05-16", 
"2022-05-17", "2022-05-18", "2022-05-19", "2022-05-20"))

Code:

ardl_model1 <- ardlDlm(ATOM_12 ~ Inflation, data = data_1, p = 1, q = 2)
summary(ardl_model1)
checkresiduals(ardl_model1)

fcst1 <- forecast(ardl_model1, h = 3)

Error:

Error in is.constant(y) : 
  'list' object cannot be coerced to type 'double'

Hello,

your error is straightforward after looking on the documentation of dLagM::forecast() (as a side note, I told you a few weeks ago to include all packages you use in your code. There are several forecast functions in R so try to avoid confusion and make it clear from the beginning :slight_smile: ).

According to the documentation, you have to specify a model, a vector x of new independent values and the forecasting horizon h. Adjusting for this, there is a result given without error:


library('dLagM')

# badly chosen name
Data$ATOM <- Data$`ATOM-USD.Close`
# changed the independent variable name and dataset name
# ardl_model1 <- ardlDlm(ATOM_12 ~ Inflation, data = data_1, p = 1, q = 2)
ardl_model <- dLagM::ardlDlm(ATOM ~ Inflation, data = Data, p = 1, q = 2)
summary(ardl_model)
#> 
#> Time series regression with "ts" data:
#> Start = 3, End = 415
#> 
#> Call:
#> dynlm(formula = as.formula(model.text), data = data)
#> 
#> Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -9.1318 -0.9143 -0.0080  0.9420  7.8857 
#> 
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)   
#> (Intercept)  0.05529    0.38923   0.142  0.88712   
#> Inflation.t -0.19904    0.24727  -0.805  0.42133   
#> Inflation.1  0.18539    0.24668   0.752  0.45276   
#> ATOM.1      -0.14353    0.04888  -2.937  0.00351 **
#> ATOM.2      -0.15705    0.04888  -3.213  0.00142 **
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 1.972 on 408 degrees of freedom
#> Multiple R-squared:  0.04077,    Adjusted R-squared:  0.03137 
#> F-statistic: 4.335 on 4 and 408 DF,  p-value: 0.001912
forecast::checkresiduals(ardl_model)
#> Time Series:
#> Start = 3 
#> End = 415 
#> Frequency = 1 
#>            3            4            5            6            7            8 
#> -0.041997673  1.562036621 -0.093186217  0.496183609 -2.194212709  0.666075791 
#>            9           10           11           12           13           14 
#>  0.667125042 -0.073425352  2.376810747 -1.026651317  1.991790044  3.292363334 
#>           15           16           17           18           19           20 
#>  1.623512377 -1.762457388 -1.134606047 -3.777281113 -2.704125135  1.154764488 
#>           21           22           23           24           25           26 
#> -1.656932860 -0.780773251  1.333995452 -1.967401348  0.232666462  3.141482627 
#>           27           28           29           30           31           32 
#>  1.514624269  0.595563221 -0.681612506  0.479869655  1.049247186 -0.458797599 
#>           33           34           35           36           37           38 
#> -0.054601513 -2.049335316  3.432017856  1.010874396  3.917713883  1.279616149 
#>           39           40           41           42           43           44 
#> -0.042337962 -3.419194256  0.983007739 -4.532568186  0.520742770  1.692696320 
#>           45           46           47           48           49           50 
#> -0.721296978 -0.065737261 -3.425428762  1.226164698 -9.131757342  2.068506880 
#>           51           52           53           54           55           56 
#> -4.378498784 -1.322180665 -1.214237215  2.439712920 -0.206705602  1.717485312 
#>           57           58           59           60           61           62 
#> -0.717387937 -1.593407812 -1.009704450  0.177469916  1.395746908  0.059537079 
#>           63           64           65           66           67           68 
#>  1.300073063  1.920281156 -1.108495000 -0.137417102 -0.032954713 -1.668822068 
#>           69           70           71           72           73           74 
#>  0.026609471  0.091571595 -1.035776267 -0.967785852 -0.603803168  0.716471051 
#>           75           76           77           78           79           80 
#>  0.205105956  0.921426526  0.163930349  0.357820510 -1.117721752 -0.603095761 
#>           81           82           83           84           85           86 
#> -0.163343960 -2.512559895 -0.898431425  0.673764694  0.332777072 -0.967729676 
#>           87           88           89           90           91           92 
#>  0.288104244  0.395534381  0.955077030  0.945409155  0.674697848 -0.696843364 
#>           93           94           95           96           97           98 
#>  0.610957238  0.024717278  0.574049346  1.375420619 -0.116682485 -0.069034593 
#>           99          100          101          102          103          104 
#> -1.074070486  1.074208858  1.275129640  0.051175322 -0.853389283 -1.113142987 
#>          105          106          107          108          109          110 
#> -0.639617184 -0.498900213 -0.336835333 -0.247217722 -0.064484051 -1.036586736 
#>          111          112          113          114          115          116 
#> -0.605021992  0.720584182  1.037393706  0.384652722  0.172921393  0.029378206 
#>          117          118          119          120          121          122 
#> -0.027113301  0.317205378 -0.100258317  0.246100444  0.411942424  0.561799571 
#>          123          124          125          126          127          128 
#> -0.100019202  0.177632338 -0.401569425  0.678085005  0.291696096  0.717086759 
#>          129          130          131          132          133          134 
#>  0.560560483 -0.709400385  0.508034069  0.370433118  0.667169286 -0.406464234 
#>          135          136          137          138          139          140 
#>  1.184044804  0.440598771  0.602526825  0.069469609  0.205151456  2.031560701 
#>          141          142          143          144          145          146 
#>  1.010705044  0.669045106  3.331037182  0.271917606  0.453982878 -2.231671305 
#>          147          148          149          150          151          152 
#>  0.044052320 -2.283682457  2.272435161  0.934829773  0.397423397  1.033067847 
#>          153          154          155          156          157          158 
#>  0.895312817  2.742272841 -0.712462658  0.224255682  0.125529163  1.379829464 
#>          159          160          161          162          163          164 
#> -0.384659079 -4.077330067 -1.063840426  5.777002627  3.326247572 -0.771554382 
#>          165          166          167          168          169          170 
#>  7.804985544  1.415571681 -0.204134224 -0.074646632  2.556747198 -3.071926732 
#>          171          172          173          174          175          176 
#>  7.393863477  4.226443096 -9.034241224 -4.294949820  7.391114790  2.393410176 
#>          177          178          179          180          181          182 
#>  3.015618397 -2.835558807 -0.146423790 -2.759305804 -3.964250989 -0.583600431 
#>          183          184          185          186          187          188 
#>  1.744632304  2.012339823  1.537150921  0.445100423 -1.899227345 -0.254290425 
#>          189          190          191          192          193          194 
#> -1.817618543  1.326118548 -1.738810243  0.248671289 -2.916558573 -0.769115135 
#>          195          196          197          198          199          200 
#>  0.942045767  1.336062238 -0.455316830 -0.677686080 -0.088832563 -0.797421630 
#>          201          202          203          204          205          206 
#> -0.582491732  3.083907692  1.164303521 -0.902878200 -0.361376146  1.479019946 
#>          207          208          209          210          211          212 
#> -1.243205507  1.068191631  7.885655682 -5.127249610  1.658426872  0.558497747 
#>          213          214          215          216          217          218 
#> -1.713463533 -0.068912338 -0.213877903 -0.242016953  1.359809855 -0.719594695 
#>          219          220          221          222          223          224 
#> -0.496667126 -0.797690004 -0.730973181  0.837377944 -0.773995753 -3.659571565 
#>          225          226          227          228          229          230 
#>  0.332009456 -1.450531502  0.550443653 -0.721011351 -0.427043358 -3.152153954 
#>          231          232          233          234          235          236 
#>  0.493611034 -3.026401348  1.295190582  1.102543941  2.078710261  1.501084836 
#>          237          238          239          240          241          242 
#>  0.503067640 -1.505292124 -0.824608682 -3.172882753 -0.614872705  0.190188417 
#>          243          244          245          246          247          248 
#>  0.827686133 -0.334172594 -0.774031945  1.495040238  4.446867281 -3.631422874 
#>          249          250          251          252          253          254 
#> -3.438777090 -1.385470568 -0.580603590  0.867850578 -2.589432673 -0.137946370 
#>          255          256          257          258          259          260 
#>  1.456181647  0.478335118 -2.461699984 -0.885642289  0.602870612 -0.432126004 
#>          261          262          263          264          265          266 
#> -0.403634354  1.841815387 -0.798650705 -0.436449092  1.875596325  3.939404903 
#>          267          268          269          270          271          272 
#>  1.952732074 -0.677255565  2.720549178  2.791381189 -1.728347057 -2.928542159 
#>          273          274          275          276          277          278 
#>  0.544296227  2.053585374  2.794406569  4.421102285  0.356211964  4.240568245 
#>          279          280          281          282          283          284 
#>  3.172714647 -2.183206317  1.385294119 -1.899156258 -2.591863485 -1.525320122 
#>          285          286          287          288          289          290 
#>  2.376839441  1.196172621  2.076275220 -2.165354482  2.737656112 -1.187515195 
#>          291          292          293          294          295          296 
#>  4.695477086 -3.915178551 -0.790787696 -1.970625140  1.677517550 -4.502221834 
#>          297          298          299          300          301          302 
#> -5.580838200  3.809454812  1.483777565  0.982460933 -3.184964441 -2.716955229 
#>          303          304          305          306          307          308 
#> -1.451518057 -0.788477565 -2.012636859  0.692366143  0.686487071 -2.239985953 
#>          309          310          311          312          313          314 
#>  2.913770315  1.645245178  0.526783192  0.712695674  0.501911387 -1.011265347 
#>          315          316          317          318          319          320 
#>  0.368134674 -1.839035276 -2.724971888 -0.102597879 -0.981651020  0.863410718 
#>          321          322          323          324          325          326 
#>  1.820453494  0.031285877 -0.268455266 -1.123089965 -0.451000378 -0.595543542 
#>          327          328          329          330          331          332 
#> -2.454694035  0.659968716  0.248933718 -0.066945578  2.352665475  2.909361851 
#>          333          334          335          336          337          338 
#> -2.272618142  4.695968989 -0.064951046  1.856421524  2.053596304 -3.059622356 
#>          339          340          341          342          343          344 
#>  0.282049117 -3.298337757 -0.001824103 -0.914312806  2.276454712 -1.760766928 
#>          345          346          347          348          349          350 
#> -0.397923575 -0.647189830 -0.987426685  0.422022746  0.062772031  2.247190067 
#>          351          352          353          354          355          356 
#> -0.449337110  0.791315288 -0.046054921 -0.714652760  0.122222748  0.015962931 
#>          357          358          359          360          361          362 
#>  0.266921392  1.079701181 -0.831261584  0.753234984  1.070810197 -0.111415683 
#>          363          364          365          366          367          368 
#>  0.982479291 -0.052103591 -1.037845082  0.353175596  1.832578026  0.932529326 
#>          369          370          371          372          373          374 
#> -0.678877413 -1.639829857 -2.835006354  0.212420270 -1.133962579  0.388715582 
#>          375          376          377          378          379          380 
#> -0.793319755 -2.873426260  0.312165319 -0.300640286 -0.632625168 -0.007984754 
#>          381          382          383          384          385          386 
#> -0.059968748 -0.922142976  0.583044793  0.494232661 -0.217607885 -1.016771617 
#>          387          388          389          390          391          392 
#> -0.488772043 -0.083913170 -1.032382368 -0.390208189 -2.054246277  0.777292899 
#>          393          394          395          396          397          398 
#> -0.964892515 -1.302852747 -0.378793800 -0.226786759 -0.381905456 -0.167689897 
#>          399          400          401          402          403          404 
#>  2.278136031 -1.670186587 -0.050908042 -1.481393872 -0.918172659 -3.131775782 
#>          405          406          407          408          409          410 
#>  0.322308892 -3.155477898 -1.244277716  0.067399136  0.499377107  1.757565833 
#>          411          412          413          414          415 
#> -0.973823505  0.570452204 -1.417966724  0.661371676  0.300510661


dLagM::forecast(ardl_model, x = Data$Inflation[413:415], h = 3)
#> $forecasts
#> [1] -0.21868414 -0.08475143 -0.01556203
#> 
#> $call
#> forecast.ardlDlm(model = ardl_model, x = Data$Inflation[413:415], 
#>     h = 3)
#> 
#> attr(,"class")
#> [1] "forecast.ardlDlm" "dLagM"

Created on 2022-10-09 with reprex v2.0.2

I hope this resolves your error.

Kind regards

1 Like

I got it now, Btw's a nice explanation and once again thanks a lot dear. Will like to disturb you more in the future :slight_smile:

Hey! I have a question.

What if we wanted to plot the values generated by the model for the next intervals, how can we do it?
See this I want to generate a forecast plot with these new entries on it.

fcst_7_days <- dLagM::forecast(ardl_model1, x = data_1$Inflation, h = 7)
fcst_7_days

$forecasts
[1]  0.940897180 -0.190210219 -0.112484621  0.053307044  0.016409215 -0.004843290  0.003306165

Since there are no confidence intervals provided in the forecast output, you could simply do ssomething like this:

forcastvals <- dLagM::forecast(ardl_model, x = Data$Inflation[401:415], h = 15)

plot(Data$Date[1:400], Data$ATOM[1:400], type = 'l',
     ylab = 'ATOM value', xlab = 'Date', xaxt = 'n')
lines(Data$Date[401:415],forcastvals$forecasts, col = 'red')
axis.Date(1, at = seq(from = min(Data$Date), to = max(Data$Date), by = "3 mon"), format="%m-%Y")

Created on 2022-10-10 by the reprex package (v2.0.1)

Kind regards

1 Like

What if we wanted to see the following 7 entries in this plot from 416-424? This code gives us the next 7 entries and I want these to see in the plot.

fcst_7_days <- dLagM::forecast(ardl_model1, x = data_1$Inflation, h = 7)
fcst_7_days

Sure, you can just add your new points as I did above. Here is the code, I added a small tweak to make sure the points are connected.

### Forecast values from your forecast
forecast_7days <- c(0.940897180,-0.190210219,-0.112484621,0.053307044,0.016409215,-0.004843290,0.003306165)

### add the points to the complete Date Range in red
plot(Data$Date, Data$ATOM, type = 'l',
     ylab = 'ATOM value', xlab = 'Date', xaxt = 'n')
lines(seq(from = max(Data$Date), to = max(Data$Date) + 7, by = "1 day"), c(Data[which(Data$Date == max(Data$Date)),]$ATOM,forecast_7days), col = 'red')
axis.Date(1, at = seq(from = min(Data$Date), to = max(Data$Date) + 7, by = "3 mon"), format="%m-%Y")

Created on 2022-10-11 with reprex v2.0.2

Kind regards

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.