Error in UseMethod("model") - forecasting error using time series

Hello,

I have a rds file that has data that looks like this (I named it rds_intake):

image

I have data for all 3 providers from January 1, 2021 to March 23, 2023. So I have almost 2 whole fiscal years worth of data (2021-2022 and 2022-2023). Here, fiscal year and quarter is considered:

Jan 01, 2021 - March 31, 2021 = 2020-2021 (fiscal_yr); Q4 (quarter)
Apr 01, 2021 - June 30, 2021 = 2021-2022; Q1
Jul 01, 2021 - Sep 30, 2021 = 2021-2022; Q2
Oct 01, 2021 - Dec 31, 2021 = 2021-2022; Q3
Jan 01, 2022 - March 31, 2022 = 2021-2022; Q4
Apr 01, 2022 - June 30, 2022 = 2022-2023; Q1...and so forth

I used the following function to aggregate the client_id because I would like to forecast the number of clients for the next 3 years so I used the following function to create this:

p_intake <- rds_intake %>% mutate(start_month = yearmonth(start_month)) %>% group_by(provider, start_month) %>% summarize(intake = n_distinct(client_id))

then I plotted the data that looks like this:

image

Then I tried the forecast models because I want to forecast what the next 3 years would look like so I used this function:

library(forecast)
library(thief)
library(fable)

intake_fit <- p_intake %>% model( seasonal_naive = SNAIVE(intake), naive_p = NAIVE(intake), drift_p = RW(intake ~ drift()), mean_p = mean(intake) )

intake_fit <- p_intake %>% model(hw = ETS(intake~ season("A"))) %>% tidy()

however, this is the error I get:

Error in UseMethod("model") :
no applicable method for 'model' applied to an object of class "c('grouped_df', 'tbl_df', 'tbl', 'data.frame')"

If someone could please help me fix this issue, I would really appreciate your help. Thank you

The data, not just a screenshot, is needed to complete a reprex. See the FAQ.

Also consider using {fpp3} and its companion text with the rest of the tools of the same generation as the {fable} package, particularly tsibble() which is needed for the modeling functions you are using. These are by the same team who produced {forecast} and they intend it to replace that generation of time series tools.

This topic was automatically closed 42 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.