1

我每天为 SALES 进行时间序列。我每天都有数据集。(格式 01.11.2015-29.11.2015)。这里的例子:

dput
DAY        STORE    ART     SALES
01.11.2015  1534    343533  62.5000
01.11.2015  25039   20490   686.4480
01.11.2015  1612    295206  185.0000
01.11.2015  1053    16406274    32.5000
01.11.2015  1612    49495   143.1196
01.11.2015  961 15309949    50.9000

如何一次对所有商店和 ART 进行预测,如何将我的分析拆分为两个因素?

#
library('ggplot2')
library('forecast')
library('tseries')


mydat=read.csv("C:/Users/synthex/Downloads/sales.csv", sep=";",dec=",")
View(mydat)
str(mydat)


count_ts = ts(mydat[, c('SALES')])
View(count_ts)

mydat$clean_cnt = tsclean(count_ts)



mydat$cnt_ma = ma(mydat$clean_cnt, order=7) # using the clean count with no outliers
mydat$cnt_ma30 = ma(mydat$clean_cnt, order=30)

count_ma = ts(na.omit(mydat$cnt_ma), frequency=30) 
decomp = stl(count_ma, s.window="periodic")
deseasonal_cnt <- seasadj(decomp)
plot(decomp) 


adf.test(count_ma, alternative = "stationary") 



auto.arima(deseasonal_cnt, seasonal=FALSE)


fit<-auto.arima(deseasonal_cnt, seasonal=FALSE)

tsdisplay(residuals(fit), lag.max=45, main='(1,1,0) Model Residuals')



fit2 = arima(deseasonal_cnt, order=c(1,1,7))


fcast <- forecast(fit2, h=1)
4

2 回答 2

1

D.乔,

您没有start正确指定您的论点。如果您查看?ts,这就是文档中关于上述参数的内容。

start:
第一次观察的时间。单个数字或两个整数的向量,它们指定自然时间单位和时间单位中的(基于 1 的)样本数。请参阅使用第二种形式的示例。

如果您想在特定的一天开始,这不是这样做的方法。您可以在此处查看如何管理此特定场景

在 R 中开始每日时间序列

无论如何,Holt Winters 并不是处理日常数据的最佳选择。您使用这种方法有什么特别的原因吗?您可以在此处找到一些处理日常数据的方法。

R:带有每日数据的 Holt-Winters(预测包)

于 2017-11-01T18:44:19.503 回答
0

假设您的数据实际上是由 ART by STORE 汇总的,并且您希望通过单一方法查找所有 STORE 的所有 ART 类别的预测,这是否公平?如果是这种情况,我相信您需要的是htsR 中的 package 功能。它将同时为所有 ART 和 STORE 提供预测,并提供绘图功能。您需要在 STORE 下提供 ART 的“分组矩阵”以及 TOTAL SALES 假设。如果不知道组结构,就不可能提供示例代码。

于 2018-07-01T07:11:47.033 回答