adaptive_spline() is a way to generate a specification of an Adaptive Spline Surface model before fitting and allows the model to be created using different packages. Currently the only package is BASS.

adaptive_spline(
  mode = "regression",
  splines_degree = NULL,
  max_degree = NULL,
  max_categorical_degree = NULL,
  min_basis_points = NULL
)

Arguments

mode

A single character string for the type of model. The only possible value for this model is "regression".

splines_degree

degree of splines. Stability should be examined for anything other than 1.

max_degree

integer for maximum degree of interaction in spline basis functions. Defaults to the number of predictors, which could result in overfitting.

max_categorical_degree

(categorical input only) integer for maximum degree of interaction of categorical inputs.

min_basis_points

minimum number of non-zero points in a basis function. If the response is functional, this refers only to the portion of the basis function coming from the non-functional predictors. Defaults to 20 or 0.1 times the number of observations, whichever is smaller.

Value

A model spec

Details

The data given to the function are not saved and are only used to determine the mode of the model. For adaptive_spline(), the mode will always be "regression".

The model can be created using the fit() function using the following engines:

Main Arguments

The main arguments (tuning parameters) for the model are:

  • splines_degree

  • max_degree

  • max_categorical_degree

  • min_basis_points

These arguments are converted to their specific names at the time that the model is fit.

Other options and argument can be set using set_engine() (See Engine Details below).

If parameters need to be modified, update() can be used in lieu of recreating the object from scratch.

Engine Details

Other options can be set using set_engine().

stan (default engine)

The engine uses BASS::bass().

Parameter Notes:

  • xreg - This is supplied via the parsnip / bayesmodels fit() interface (so don't provide this manually). See Fit Details (below).

Fit Details

Date and Date-Time Variable

It's a requirement to have a date or date-time variable as a predictor. The fit() interface accepts date and date-time features and handles them internally.

Univariate (No xregs, Exogenous Regressors):

This algorithm only accepts multivariate: you need to pass xregs (read next section).

Multivariate (xregs, Exogenous Regressors)

The xreg parameter is populated using the fit() function:

  • Only factor, ordered factor, and numeric data will be used as xregs.

  • Date and Date-time variables are not used as xregs

  • character data should be converted to factor.

Xreg Example: Suppose you have 3 features:

  1. y (target)

  2. date (time stamp),

  3. month.lbl (labeled month as a ordered factor).

The month.lbl is an exogenous regressor that can be passed to the sarima_reg() using fit():

Note that date or date-time class values are excluded from xreg.

See also

Examples

if (FALSE) { library(dplyr) library(parsnip) library(rsample) library(timetk) library(modeltime) library(bayesmodels) library(lubridate) # Data m750 <- m4_monthly %>% filter(id == "M750") m750 # Split Data 80/20 splits <- rsample::initial_time_split(m750, prop = 0.8) # ---- Adaptive Spline ---- # Model Spec model_spec <- adaptive_spline() %>% set_engine("stan") # Fit Spec model_fit <- model_spec %>% fit(log(value) ~ date + month(date), data = training(splits)) model_fit }