# tslm

From forecast v3.24
by Rob Hyndman

##### Fit a linear model with time series components

`tslm`

is used to fit linear models to time series including trend and seasonality components.

- Keywords
- stats

##### Usage

`tslm(formula, data, lambda=NULL, ...)`

##### Arguments

- formula
- an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.
- data
- an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which lm is c
- lambda
- Box-Cox transformation parameter. Ignored if NULL. Otherwise, data are transformed via a Box-Cox transformation.
- ...
- Other arguments passed to
`lm()`

.

##### Details

`tslm`

is largely a wrapper for `lm()`

except that it allows variables "trend" and "season" which are created on the fly from the time series characteristics of the data. The variable "trend" is a simple time trend and "season" is a factor indicating the season (e.g., the month or the quarter depending on the frequency of the data).

##### Value

- Returns an object of class "lm".

##### See Also

##### Examples

```
y <- ts(rnorm(120,0,3) + 1:120 + 20*sin(2*pi*(1:120)/12), frequency=12)
fit <- tslm(y ~ trend + season)
plot(forecast(fit, h=20))
```

*Documentation reproduced from package forecast, version 3.24, License: GPL (>= 2)*

### Community examples

Looks like there are no examples yet.