Learn R Programming

sknifedatar (version 0.1.2)

modeltime_multifit: Fit Multiple Models to Multiple Time Series

Description

allows multiple models to be fitted over multiple time series, using models from the 'modeltime' package.

Usage

modeltime_multifit(serie, .prop, ...)

Arguments

serie

nested time series.

.prop

series train/test partition ratio.

...

models or workflows to train (model_1, model2, ...).

Value

A list of 2 items. The first component is a tibble with a first column that contains the name of the series, and a second column called "nested_column" that stores the time series, then a column for each model where the trained models or workflows for each series are stored. The last 2 columns, "nested_model" and "calibration", store the "n" trained models for each series and the adjustment metrics on the test partition. The second element is a tibble saved with the name of 'models_accuracy', it allows to visualize the performance of each model for each series according to a set of metrics.

Details

the focus of this function is not related to panel series, it is oriented to multiple individual series. Receiving as the first argument "series" a set of nested series (for example through the nest() function), then specifying a desired train/test partition ratio for series. The final input to the function are the models to be trained, simply by typing the name of the models separated by commas. The function admits as many models as required.

See Also

sknifedatar website

Examples

Run this code
# NOT RUN {
library(modeltime)
library(earth)
nested_serie <- 
tidyr::nest(dplyr::filter(sknifedatar::emae_series, date < '2007-02-01'),
            nested_column = -sector)

## Models
mars <- parsnip::mars(mode = 'regression') %>% parsnip::set_engine('earth')

# modeltime_multifit
sknifedatar::modeltime_multifit(serie = head(nested_serie,2),
                                .prop = 0.9,
                                mars)
# }

Run the code above in your browser using DataLab