[R] Issues with R's forecast function

Paul Bernal p@u|bern@|07 @end|ng |rom gm@||@com
Mon May 27 21:48:31 CEST 2024


Dear Sarah,

I installed the latest R version available (4.4.0), installed the forecast
package and related packages from scratch and the issue was resolved.

Kind regards,
Paul

El lun, 27 may 2024 a las 13:51, Sarah Goslee (<sarah.goslee using gmail.com>)
escribió:

> Hi Paul,
>
> Looking at this, you aren't running the most recent version of forecast.
>
> If I were having a problem of this sort, I'd update R (if you can),
> run update.packages() and then try again with a minimal set of
> packages. As one of the other responses suggested, you probably have
> mismatched versions of packages with dependencies.
>
> Sarah
>
> On Mon, May 27, 2024 at 2:48 PM Paul Bernal <paulbernal07 using gmail.com>
> wrote:
> >
> > Dear Sarah,
> >
> > Here is the sessionInfo() output, I forgot to include it in my reply.
> >
> > sessionInfo()
> > R version 4.3.2 (2023-10-31 ucrt)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> > Running under: Windows 11 x64 (build 22631)
> >
> > Matrix products: default
> >
> >
> > locale:
> > [1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United
> States.utf8
> > [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
> > [5] LC_TIME=English_United States.utf8
> >
> > time zone: America/Bogota
> > tzcode source: internal
> >
> > attached base packages:
> >  [1] parallel  grid      stats4    stats     graphics  grDevices utils
>    datasets  methods   base
> >
> > other attached packages:
> >  [1] mvgam_1.1.1            insight_0.19.7
>  marginaleffects_0.20.1 brms_2.21.0
> >  [5] mgcv_1.9-0             nlme_3.1-163           gbm_2.1.9
>   yardstick_1.3.1
> >  [9] workflowsets_1.1.0     workflows_1.1.4        tune_1.2.1
>  rsample_1.2.1
> > [13] recipes_1.0.10         parsnip_1.2.1          modeldata_1.3.0
>   infer_1.0.7
> > [17] dials_1.2.1            scales_1.3.0           broom_1.0.5
>   tidymodels_1.2.0
> > [21] ggthemes_5.1.0         janitor_2.2.0          tictoc_1.2.1
>  Ckmeans.1d.dp_4.3.5
> > [25] magrittr_2.0.3         data.table_1.14.10     reticulate_1.34.0
>   tensorflow_2.15.0
> > [29] keras_2.13.0           matlabr_1.5.2          R.matlab_3.7.0
>  distrMod_2.9.1
> > [33] RandVar_1.2.3          distrEx_2.9.2          distr_2.9.3
>   sfsmisc_1.1-17
> > [37] startupmsg_0.9.6.1     qcc_2.7                pdp_0.8.1
>   doParallel_1.0.17
> > [41] iterators_1.0.14       foreach_1.5.2          tsintermittent_1.10
>   ivreg_0.6-2
> > [45] vars_1.6-0             urca_1.3-3             strucchange_1.5-3
>   Amelia_1.8.1
> > [49] Rcpp_1.0.12            VIM_6.2.2              colorspace_2.1-0
>  mi_1.1
> > [53] Hmisc_5.1-1            missForest_1.5         mice_3.16.0
>   gghighlight_0.4.1
> > [57] caret_6.0-94           lattice_0.21-9         xgboost_1.7.7.1
>   smooth_4.0.0
> > [61] e1071_1.7-14           greybox_2.0.0          rio_1.0.1
>   fitdistrplus_1.1-11
> > [65] AER_1.2-12             survival_3.5-7         sandwich_3.1-0
>  lmtest_0.9-40
> > [69] zoo_1.8-12             car_3.1-2              carData_3.0-5
>   forcats_1.0.0
> > [73] stringr_1.5.1          purrr_1.0.2            readr_2.1.5
>   tidyr_1.3.1
> > [77] tibble_3.2.1           tidyverse_2.0.0        dplyr_1.1.4
>   Metrics_0.1.4
> > [81] corrgram_1.14          corrplot_0.92          readxl_1.4.3
>  glmnet_4.1-8
> > [85] Matrix_1.6-1.1         MASS_7.3-60.0.1        actuar_3.3-4
>  neuralnet_1.44.2
> > [89] nnfor_0.9.9            generics_0.1.3         ggplot2_3.5.1
>   lubridate_1.9.3
> > [93] tseries_0.10-55        forecast_8.21.1
> >
> > loaded via a namespace (and not attached):
> >   [1] matrixStats_1.3.0    DiceDesign_1.10      httr_1.4.7
>  RColorBrewer_1.1-3   tools_4.3.2
> >   [6] doRNG_1.8.6          backports_1.4.1      utf8_1.2.4
>  R6_2.5.1             jomo_2.7-6
> >  [11] withr_3.0.0          sp_2.1-3             Brobdingnag_1.2-9
> gridExtra_2.3        cli_3.6.2
> >  [16] labeling_0.4.3       tsutils_0.9.4        mvtnorm_1.2-4
> robustbase_0.99-2    randomForest_4.7-1.1
> >  [21] proxy_0.4-27         QuickJSR_1.1.3       StanHeaders_2.32.7
>  foreign_0.8-85       R.utils_2.12.3
> >  [26] parallelly_1.36.0    scoringRules_1.1.1   itertools_0.1-3
> TTR_0.24.4           rstudioapi_0.16.0
> >  [31] shape_1.4.6          distributional_0.4.0 inline_0.3.19
> loo_2.7.0            fansi_1.0.6
> >  [36] abind_1.4-5          R.methodsS3_1.8.2    lifecycle_1.0.4
> multcomp_1.4-25      whisker_0.4.1
> >  [41] snakecase_0.11.1     crayon_1.5.2         mitml_0.4-5
> zeallot_0.1.0        pillar_1.9.0
> >  [46] knitr_1.45           boot_1.3-28.1        estimability_1.4.1
>  future.apply_1.11.1  codetools_0.2-19
> >  [51] pan_1.9              glue_1.7.0           vcd_1.4-12
>  vctrs_0.6.5          png_0.1-8
> >  [56] Rdpack_2.6           cellranger_1.1.0     gtable_0.3.4
>  gower_1.0.1          xfun_0.41
> >  [61] rbibutils_2.2.16     prodlim_2023.08.28   MAPA_2.0.6
>  pracma_2.4.4         uroot_2.1-3
> >  [66] coda_0.19-4.1        timeDate_4032.109    hardhat_1.3.1
> lava_1.7.3           statmod_1.5.0
> >  [71] TH.data_1.1-2        ipred_0.9-14         xts_0.13.1
>  rstan_2.32.6         tensorA_0.36.2.1
> >  [76] rpart_4.1.21         nnet_7.3-19          tidyselect_1.2.0
>  emmeans_1.10.0       compiler_4.3.2
> >  [81] curl_5.2.0           ahead_0.10.0         htmlTable_2.4.2
> posterior_1.5.0      checkmate_2.3.1
> >  [86] DEoptimR_1.1-3       fracdiff_1.5-2       quadprog_1.5-8
>  tfruns_1.5.1         digest_0.6.34
> >  [91] minqa_1.2.6          rmarkdown_2.25       htmltools_0.5.7
> pkgconfig_2.0.3      base64enc_0.1-3
> >  [96] lme4_1.1-35.1        lhs_1.1.6            fastmap_1.1.1
> rlang_1.1.3          htmlwidgets_1.6.4
> > [101] quantmod_0.4.26      farver_2.1.1         jsonlite_1.8.8
>  ModelMetrics_1.2.2.2 R.oo_1.26.0
> > [106] Formula_1.2-5        bayesplot_1.11.1     texreg_1.39.3
> GPfit_1.0-8          munsell_0.5.0
> > [111] furrr_0.3.1          stringi_1.8.3        pROC_1.18.5
> pkgbuild_1.4.3       plyr_1.8.9
> > [116] expint_0.1-8         listenv_0.9.1        splines_4.3.2
> hms_1.1.3            ranger_0.16.0
> > [121] rngtools_1.5.2       reshape2_1.4.4       rstantools_2.4.0
>  evaluate_0.23        RcppParallel_5.1.7
> > [126] laeken_0.5.3         nloptr_2.0.3         tzdb_0.4.0
>  future_1.33.1        xtable_1.8-4
> > [131] class_7.3-22         snow_0.4-4           arm_1.13-1
>  cluster_2.1.4        timechange_0.2.0
> > [136] globals_0.16.2       bridgesampling_1.1-2
> >
> > Cheers,
> >
> > Paul
> >
> > El lun, 27 may 2024 a las 12:15, Sarah Goslee (<sarah.goslee using gmail.com>)
> escribió:
> >>
> >> Hi Paul,
> >>
> >> It looks like you're using the forecast package, right? Have you loaded
> it?
> >>
> >> What is the output of sessionInfo() ?
> >>
> >> It looks to me like you either haven't loaded the needed packages, or
> >> there's some kind of conflict. Your examples don't give me errors when
> >> I run them, so we need more information.
> >>
> >> Sarah
> >>
> >>
> >>
> >> On Mon, May 27, 2024 at 12:25 PM 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]]



More information about the R-help mailing list