# seasonaldummy {forecast}

Seasonal dummy variables
Package:
forecast
Version:
7.1

### Description

`seasonaldummy` returns matrices of dummy variables suitable for use in `arima`, `lm` or `tslm`. The last season is omitted and used as the control.

`fourier` returns matrices containing terms from a Fourier series, up to order `K`, suitable for use in `arima`, `lm` or `tslm`.

`fourierf` and `seasonaldummyf` are deprecated, instead use the `h` argument in `fourier` and `seasonaldummy`.

### Usage

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

### Arguments

x
Seasonal time series: a `ts` or a `msts` object
h
Number of periods ahead to forecast (optional)
K
Maximum order(s) of Fourier terms

### Details

The number of dummy variables, or the period of the Fourier terms, is determined from the time series characteristics of `x`. The length of `x` also determines the number of rows for the matrices returned by `seasonaldummy` and `fourier`. The value of `h` determines the number of rows for the matrices returned by `seasonaldummy` and `fourier`, typically used for forecasting. The values within `x` are not used in any function.

When `x` is a `ts` object, the value of `K` should be an integer and specifies the number of sine and cosine terms to return. Thus, the matrix returned has `2*K` columns.

When `x` is a `msts` object, then `K` should be a vector of integers specifying the number of sine and cosine terms for each of the seasonal periods. Then the matrix returned will have `2*sum(K)` columns.

### Values

Numerical matrix.

### 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(seasonaldummy(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
deaths.lm  <- tslm(ldeaths ~ fourier(ldeaths,3))
ldeaths.fcast <- forecast(deaths.lm,
data.frame(fourier(ldeaths,3,36)))
plot(ldeaths.fcast)

# Using Fourier series for a "msts" object
taylor.lm <- tslm(taylor ~ fourier(taylor, K = c(3, 3)))
taylor.fcast <- forecast(taylor.lm,
data.frame(fourier(taylor, K = c(3, 3), h = 270)))
plot(taylor.fcast)```

### Author(s)

Rob J Hyndman

Documentation reproduced from package forecast, version 7.1. License: GPL (>= 2)