Description Usage Arguments Details Value Author(s) Examples
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.
1 2 | seasonaldummy(x,h)
fourier(x,K,h)
|
x |
Seasonal time series: a |
h |
Number of periods ahead to forecast (optional) |
K |
Maximum order(s) of Fourier terms |
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.
Numerical matrix.
Rob J Hyndman
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.