我每天为 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)