[R] Issues with R's forecast function

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Mon May 27 19:16:27 CEST 2024


You have completely ignored mentioning what R contributed packages you may have been using in "back when it worked". It is critical that you keep track of which "library" statements are necessary to run your code, if any.

I searched for "R usemethod forecast" in Google and this [1] came up. Perhaps it is helpful? It seems that some people have had problems when they updated some but not all of their R packages.

[1] https://stackoverflow.com/questions/70283794/forecasting-in-r-usemethod-model-function-error

On May 27, 2024 9:24:50 AM PDT, Paul Bernal <paulbernal07 using gmail.com> wrote:
>Dear all,
>
>I am currently using R 4.3.2 and the data I am working with is the
>following:
>
>ts_ingresos_reservas    = ts(ingresos_reservaciones$RESERVACIONES, start =
>c(1996,11), end = c(2024,4), frequency = 12)
>
>structure(c(11421.54, 388965.46, 254774.78, 228066.02, 254330.44,
>272561.38, 377802.1, 322810.02, 490996.48, 581998.3, 557009.96,
>619568.56, 578893.9, 938765.36, 566374.38, 582678.46, 931035.04,
>855661.3, 839760.22, 745521.4, 816424.96, 899616.64, 921462.88,
>942825, 1145845.74, 1260554.36, 1003983.5, 855516.22, 1273913.68,
>1204626.54, 1034135.18, 904641.14, 1003094.3, 1073084.74, 928515.64,
>854864.4, 928927.48, 1076922.34, 1031265.04, 1043755.7, 1238565.12,
>1343609.54, 1405817.92, 1243192.86, 1235505.44, 1280514.56, 1314029.08,
>1562841.28, 1405662.96, 1315083.12, 1363980.02, 1126195.72, 1542338.98,
>1577437.94, 1474855.98, 1287170.56, 1404118.3, 1528979.66, 1286690.34,
>1544495.16, 1527018.22, 1462908.72, 1682739.76, 1439027.72, 1531060.44,
>1793606.88, 1835054.26, 1616743.96, 1779745.24, 1772628, 1736200.18,
>1736792.72, 1835714.4, 2031238.04, 1937816.14, 1942473.52, 2131666.68,
>2099279.26, 1939093.78, 2135231.54, 2187614.52, 2150766.28, 2179862.62,
>2467330.32, 2421603.34, 2585889.54, 4489381.11, 4915745.55, 5313521.43,
>5185438.48, 5346116.46, 4507418.33, 5028489.81, 4931266.16, 5529189.46,
>5470279.34, 5354912.01, 5937028.11, 6422819.13, 5989941.72, 6549070.26,
>6710738.34, 6745949.78, 6345832.78, 6656868.36, 6836903.51, 6456545.14,
>7039815.42, 7288665.89, 7372047.96, 8116822.48, 7318300.42, 8742429.72,
>8780764.44, 8984081.22, 8221966.77, 8594896.69, 8319125.91, 8027227.8,
>9241082.48, 8765799.78, 9360643.68, 9384937.59, 8237007.99, 9251122.07,
>8703017.5, 9004464.9, 8099029.39, 8883214.99, 8360815.05, 8408082.51,
>9126756.64, 8610501.05, 9109139.05, 8904803.6, 12766215.9, 14055014.03,
>12789865.86, 13251587.21, 13731917.7, 14925330.72, 14295954.4,
>13346681.84, 14233732.03, 12743141.34, 13742979.78, 11770238.46,
>11655300, 12327000, 10096000, 8712000, 6742500, 7199000, 5459000,
>4442000, 7448500, 6322500, 6030500, 5521000, 4752000, 6248500,
>5233000, 7440500, 5604500, 6516500, 6001500, 9364500, 14528500,
>14076000, 11671500, 11778500, 13902500, 13073000, 11097000, 9547500,
>10255000, 8986500, 10807000, 10031500, 9847000, 12216500, 11648500,
>13106000, 10856500, 9679500, 9986500, 8947500, 11105500, 9950500,
>10922000, 9031500, 9720500, 9709000, 9470500, 9316000, 9884500,
>9067500, 8985000, 10888000, 9676500, 10047000, 8952000, 10191500,
>12763000, 14885000, 13592000, 13364500, 11924000, 13888000, 12833500,
>12239000, 9450000, 10028000, 10171500, 13648000, 13989000, 14488000,
>14195000, 12800500, 12703000, 15300000, 14963000, 15049000, 13513000,
>14155500, 14047500, 12923500, 13298500, 12814000, 13492000, 14405500,
>12597500, 14486000, 12103500, 12815000, 11912000, 12353500, 12718500,
>12972000, 12499000, 13683500, 17437000, 18147000, 17008000, 17180000,
>16160000, 15096500, 13707000, 16254000, 14673500, 13661500, 17014000,
>16104500, 17113000, 17200500, 15304500, 17131000, 16551000, 16356000,
>14702000, 14488000, 14902500, 14435500, 15598500, 14754500, 15015000,
>16444500, 14620000, 15701000, 14211000, 15243000, 13898000, 14889000,
>18571000, 15950500, 20171000, 20096000, 19647000, 20394500, 18213000,
>18714500, 18301000, 14581000, 12333000, 14482500, 17538500, 17480500,
>19574000, 18464500, 19410000, 19013000, 16523500, 18755000, 18194000,
>18918000, 34130500, 34421500, 36727000, 33406500, 34779500, 35916500,
>36193000, 35878500, 32274500, 35097000, 34319500, 36459000, 35222500,
>35972000, 37382000, 34482000, 35776000, 35330000, 35990000, 34788500,
>32173500, 34879000, 33195500, 35243500, 33581000, 35632000, 32716000,
>33966500, 31778000, 28164500, 25729500, 23034500, 24427500, 26506500,
>26655500), tsp = c(1996.83333333333, 2024.25, 12), class = "ts")
>
>Now that I have my time series data, I tried generating forecasts with the
>following code:
>
>ingresos_reservas_arimamod      = auto.arima(ts_ingresos_reservas)
>ingresos_reservas_arimafor      = forecast(ingresos_reservas_arimamod, h =
>151)
>
>ingresos_reservas_holtwintersmod = HoltWinters(ts_ingresos_reservas)
>ingresos_reservas_holtwintersfor =
>forecast(ingresos_reservas_holtwintersmod, h = 151)
>
>ingresos_reservas_etsmod        = ets(ts_ingresos_reservas)
>ingresos_reservas_etsfor        = forecast(ingresos_reservas_etsmod, level
>= c(90,99), h = 151)
>
>ingresos_reservas_batsmod       = bats(ts_ingresos_reservas)
>ingresos_reservas_batsfor       = forecast(ingresos_reservas_batsmod, level
>= c(90,99), h = 151, robust = TRUE)
>
>ingresos_reservas_tbatsmod      = tbats(ts_ingresos_reservas)
>ingresos_reservas_tbatsfor      = forecast(ingresos_reservas_tbatsmod,
>level = c(90,99), h = 151, robust = TRUE)
>
>ingresos_reservas_nnetarmod       = nnetar(ts_ingresos_reservas)
>ingresos_reservas_nnetarfor       = forecast(ingresos_reservas_nnetarmod,
>PI = TRUE, h = 151, robust = TRUE)
>
>This code used to work, but now, I keep getting the following error:
>Error in UseMethod("forecast", object) :
>  no applicable method for 'forecast' applied to an object of class "ets"
>
>Error in UseMethod("forecast", object) :
>  no applicable method for 'forecast' applied to an object of class "nnetar"
>
>Error in UseMethod("forecast", object) :
>  no applicable method for 'forecast' applied to an object of class "bats"
>
>Error in UseMethod("forecast", object) :
>  no applicable method for 'forecast' applied to an object of class "bats"
>
>It seems like the forecast function is not working for these models
>anymore. Any idea of how to solve this issue?
>
>Kind regards,
>
>Paul
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list