# seasonaldummy

From forecast v3.21
by Rob Hyndman

##### Seasonal dummy variables

`seasonaldummy`

and `seasonaldummyf`

return matrices of dummy variables suitable for use in `arima`

, `lm`

or `tslm`

. The last season is omitted and used as the control.

`fourier`

and `fourierf`

return matrices containing terms from a Fourier series, up to order `K`

, suitable for use in `arima`

, `lm`

or `tslm`

.

- Keywords
- ts

##### Usage

```
seasonaldummy(x)
seasonaldummyf(x,h)
fourier(x,K)
fourierf(x,K,h)
```

##### Arguments

- x
- Seasonal time series
- h
- Number of periods ahead to forecast
- K
- Maximum order of Fourier terms

##### Value

- Numerical matrix with number of rows equal to the
`length(x)`

and number of columns equal to`frequency(x)-1`

(for`seasonaldummy`

and`seasonaldummyf`

or`2*K`

(for`fourier`

or`fourierf`

).

##### Examples

```
plot(ldeaths)
# Using seasonal dummy variables
month <- seasonaldummy(ldeaths)
deaths.lm <- tslm(ldeaths ~ month)
tsdisplay(residuals(deaths.lm))
ldeaths.fcast <- forecast(deaths.lm,
data.frame(month=I(seasonaldummyf(ldeaths,36))))
plot(ldeaths.fcast)
# A simpler approach to seasonal dummy variables
deaths.lm <- tslm(ldeaths ~ season)
ldeaths.fcast <- forecast(deaths.lm, h=36)
plot(ldeaths.fcast)
# Using Fourier series
X <- fourier(ldeaths,3)
deaths.lm <- tslm(ldeaths ~ X)
ldeaths.fcast <- forecast(deaths.lm,
data.frame(X=I(fourierf(ldeaths,3,36))))
plot(ldeaths.fcast)
```

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

### Community examples

Looks like there are no examples yet.