R: Fit a linear model with time series components

TSLM {fable} | R Documentation

## 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)

### Arguments

`formula` | Model specification.

### Value

A model specification.

### Specials

#### xreg

Exogenous regressors can be included in an ARIMA 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

`stats::lm()`, `stats::model.matrix()` Forecasting: Principles and Practices, Time series regression models (chapter 6)

### Examples

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

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

[Package fable version 0.3.1 Index]