| seasonaldummy {forecast} | R Documentation |
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.
seasonaldummy(x) seasonaldummyf(x,h) fourier(x,K) fourierf(x,K,h)
x |
Seasonal time series |
h |
Number of periods ahead to forecast |
K |
Maximum order of Fourier terms |
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).
Rob J Hyndman
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)