Suitable for extension packages to create new models for fable.
new_model_class(
model = "Unknown model",
train = function(.data, formula, specials, ...)
abort("This model has not defined a training method."),
specials = new_specials(),
check = function(.data) {
},
prepare = function(...) {
},
...,
.env = caller_env(),
.inherit = model_definition
)
new_model_definition(.class, formula, ..., .env = caller_env(n = 2))
The name of the model
A function that trains the model to a dataset. .data
is a tsibble
containing the data's index and response variables only. formula
is the
user's provided formula. specials
is the evaluated specials used in the formula.
Special functions produced using new_specials()
A function that is used to check the data for suitability with the model. This can be used to check for missing values (both implicit and explicit), regularity of observations, ordered time index, and univariate responses.
This allows you to modify the model class according to user
inputs. ...
is the arguments passed to new_model_definition
, allowing
you to perform different checks or training procedures according to different
user inputs.
Further arguments to R6::R6Class()
. This can be useful to set up
additional elements used in the other functions. For example, to use
common_xregs
, an origin
element in the model is used to store
the origin for trend()
and fourier()
specials. To use these specials, you
must add an origin
element to the object (say with origin = NULL
).
The environment from which functions should inherit from.
A model class to inherit from.
A model class (typically created with new_model_class()
).
The user's model formula.
This function produces a new R6 model definition. An understanding of R6 is
not required, however could be useful to provide more sophisticated model
interfaces. All functions have access to self
, allowing the functions for
training the model and evaluating specials to access the model class itself.
This can be useful to obtain elements set in the %TODO