Description Usage Arguments Value Author(s) Examples
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.
1 2 3 4 | 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.