简体   繁体   English

HoltWinters 在 R 中嵌套季节

[英]HoltWinters Nested Seasons in R

I have a dataset of daily demand over the last 2 years.我有过去 2 年的每日需求数据集。 The data has weekly seasons and nested daily seasons.该数据具有每周季节和嵌套的每日季节。 I converted the data into a time series using ts function with frequency=365.我使用频率 = 365 的 ts 函数将数据转换为时间序列。 When using HoltWinters method now, he interprets every day as an own season, resulting in non-robust outcomes.现在使用 HoltWinters 方法时,他将每一天都解释为自己的季节,导致结果不可靠。 How can I tell him to only include 59 seasons (52 weekly and 7 daily seasons)?我怎么能告诉他只包括 59 个赛季(52 个每周和 7 个每日赛季)?

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.我假设“每周 52 个季节和每天 7 个季节”的意思是您要为年度季节性指定 52 个季节性因素,为每周季节性指定 7 个季节性因素(逻辑上)。

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/ ) ( 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(多季节时间序列)对象代替 ts 对象,如下所示指定每周和每年的季节性。

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

Or omit leap day observations and just use 365. You can use bats or tbats:或者省略闰日观察,只使用 365。您可以使用 bats 或 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/你应该看看https://robjhyndman.com/hyndsight/dailydata/

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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