Extract model description from a mable

I am running models to forecast time series data, like the following:

models <- ts_data %>% model(
    Arima = ARIMA(Members),
    ETS = ETS(Members)
)
models

The result is a mable (model table) that shows <ETS(A,N,N)> as the model it chose. How do I get this value as a string so that I can put it in the title of a plot?: "ETS(A,N,N)". When I try to extract the description of the model, I get the specs, attributes, etc. I just want the description as a string. Any thoughts?

Does attr(models, "model") give you the value you wanted as a string?

I haven't used fable or mable, but I'm assuming models is a list with a bunch of information about the model. This list probably has several attributes which you can look at by running attributes(models). If there's an attribute named "model" you can extract it with attr(models, "model") (or it might be called something else; you should be able to tell when you look at the output of attributes). You can see the entire structure of the models object by running str(models).

You can get the formatted text of a model using the format() function.

models %>%
  mutate(arima_text = format(Arima)

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