Forecasting: Principles and Practice (3rd ed.) 12.2 Prophet model - assumed packages

Hi!
I am trying to run the examples in section 12.2 Prophet Model from the textbook Forecasting: Principles and Practice (3rd ed.). I am running into some errors probably because I have not loaded the necessary packages. Unfortunately, the necessary packages are not specified in section 12.2.
I have been trying to decipher which packages I may need, but without luck. E.g. I am not even able to run the first line correctly. I have loaded tsibbledata and added attach(aus_production) in the beginning to get rid of the first error message, but I still get
Error in year(Quarter) : could not find function "year".
If I circumvent it somehow (not elegantly at all!), the third line
> fit <- train |>
+ model(
+ arima = ARIMA(Cement),
+ ets = ETS(Cement),
+ prophet = prophet(Cement ~ season(period=4, order=2, type="multiplicative"))
+ )
produces the error below:
Error in UseMethod("model") : no applicable method for 'model' applied to an object of class "c('mts', 'ts')"

Please help. Thank you!


Referred here by Forecasting: Principles and Practice, by Rob J Hyndman and George Athanasopoulos

Please read the preface:

All R examples in the book assume you have loaded the fpp3 package first:

Thank you for your help! The solution works.

However, when I go one step further and run the next example (Half-hourly electricity demand), the following line

fit <- elec |>
  model(
    prophet(Demand ~ Temperature + Cooling + Working_Day +
            season(period = "day", order = 10) +
            season(period = "week", order = 5) +
            season(period = "year", order = 3))
  )

produces this error:

Error in UseMethod("model") : 
  no applicable method for 'model' applied to an object of class "ts"

Is there a cure for that?

The error message shows that the elec object you have is of class ts, most likely because you've loaded the fpp2 or fma packages. You should not load those packages as they are used in the 2nd edition of our book, not the 3rd edition.. You need to use the elec object created in the previous section of the book.

Unloading fpp2 and creating elec and elec_newdata objects using the previous section in the textbook helped. Thank you so much!

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.