简体   繁体   中英

HoltWinters Nested Seasons in R

I have a dataset of daily demand over the last 2 years. The data has weekly seasons and nested daily seasons. I converted the data into a time series using ts function with frequency=365. When using HoltWinters method now, he interprets every day as an own season, resulting in non-robust outcomes. How can I tell him to only include 59 seasons (52 weekly and 7 daily seasons)?

First of all, weekly seasonality means that a pattern may repeats itself every week. Daily seasonality means that a pattern may repeat itself every day. To allow your model to contain daily seasonality you need a higher frequency time series than daily. I assume that with the '52 weekly and 7 daily seasons' you mean that you want to specify 52 seasonal factors for your annual seasonality and 7 seasonal factors (logically) for your weekly seasonality.

The frequency specifies the number of observations per cycle (season). With daily data a weekly seasonality is introduced by:

ts(x, frequency = 7)

You might want to restrict yourself to use just that. ( https://robjhyndman.com/hyndsight/dailydata/ )

Instead of the ts object, you can use the msts (Multi-Seasonal Time Series) object as follows to specify weekly and annual seasonality.

msts(x, seasonal.periods = c(7, 365.25))

Or omit leap day observations and just use 365. You can use bats or tbats:

y <- msts(x, seasonal.periods=c(7,365.25))
fit <- tbats(y)
fc <- forecast(fit)
plot(fc)

You should have a look at https://robjhyndman.com/hyndsight/dailydata/

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM