Trains specified model definition(s) to a dataset. This function will estimate the a set of model definitions (passed via ...) to each series within .data (as identified by the key structure). The result will be a mable (a model table), which neatly stores the estimated models in a tabular structure. Rows of the data identify different series within the data, and each model column contains all models from that model definition. Each cell in the mable identifies a single model.

model(.data, ...)

# S3 method for tbl_ts
model(.data, ..., .safely = TRUE)

## Arguments

.data A data structure suitable for the models (such as a tsibble) Definitions for the models to be used. All models must share the same response variable. If a model encounters an error, rather than aborting the process a NULL model will be returned instead. This allows for an error to occur when computing many models, without losing the results of the successful models.

## Parallel

It is possible to estimate models in parallel using the future package. By specifying a future::plan() before estimating the models, they will be computed according to that plan.

## Examples

if (requireNamespace("fable", quietly = TRUE) && requireNamespace("tsibbledata", quietly = TRUE)) {
library(fable)
library(tsibbledata)

# Training an ETS(M,Ad,A) model to Australian beer production
aus_production %>%
model(ets = ETS(log(Beer) ~ error("M") + trend("Ad") + season("A")))

# Training a seasonal naive and ETS(A,A,A) model to the monthly
# "Food retailing" turnover for selected Australian states.
library(dplyr)
aus_retail %>%
filter(
Industry == "Food retailing",
State %in% c("Victoria", "New South Wales", "Queensland")
) %>%
model(
snaive = SNAIVE(Turnover),
ets = ETS(log(Turnover) ~ error("A") + trend("A") + season("A")),
)
}#> Warning: 1 error encountered for ets
#> [1] .data contains implicit gaps in time. You should check your data and convert implicit gaps into explicit missing values using tsibble::fill_gaps() if required.#> Warning: 3 errors (1 unique) encountered for snaive
#> [3] .data contains implicit gaps in time. You should check your data and convert implicit gaps into explicit missing values using tsibble::fill_gaps() if required.#> Warning: 3 errors (1 unique) encountered for ets
#> [3] .data contains implicit gaps in time. You should check your data and convert implicit gaps into explicit missing values using tsibble::fill_gaps() if required.#> # A mable: 3 x 4
#> # Key:     State, Industry [3]
#>   State           Industry             snaive          ets
#>   <chr>           <chr>               <model>      <model>
#> 1 New South Wales Food retailing <NULL model> <NULL model>
#> 2 Queensland      Food retailing <NULL model> <NULL model>
#> 3 Victoria        Food retailing <NULL model> <NULL model>