# seasonaldummy {forecast}

### Description

`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`

.

### Usage

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

### Arguments

- x
- Seasonal time series: a
`ts`

or a`msts`

object - h
- Number of periods ahead to forecast
- 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 `seasonaldummyf`

and `fourierf`

. 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(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) # Using Fourier series for a "msts" object Z <- fourier(taylor, K = c(3, 3)) taylor.lm <- tslm(taylor ~ Z) taylor.fcast <- forecast(taylor.lm, data.frame(Z = I(fourierf(taylor, K = c(3, 3), h = 270)))) plot(taylor.fcast)

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