Learn R Programming

fable (version 0.3.3)

TSLM: Fit a linear model with time series components

Description

The model formula will be handled using stats::model.matrix(), and so the the same approach to include interactions in stats::lm() applies when specifying the formula. In addition to stats::lm(), it is possible to include common_xregs in the model formula, such as trend(), season(), and fourier().

Usage

TSLM(formula)

Value

A model specification.

Arguments

formula

Model specification.

Specials

xreg

Exogenous regressors can be included in a TSLM model without explicitly using the xreg() special. Common exogenous regressor specials as specified in common_xregs can also be used. These regressors are handled using stats::model.frame(), and so interactions and other functionality behaves similarly to stats::lm().


xreg(...)

...Bare expressions for the exogenous regressors (such as log(x))

See Also

Examples

Run this code
as_tsibble(USAccDeaths) %>%
  model(lm = TSLM(log(value) ~ trend() + season()))

library(tsibbledata)
olympic_running %>%
  model(TSLM(Time ~ trend())) %>%
  interpolate(olympic_running)

Run the code above in your browser using DataLab