季節的な状況で売上を予測したい。 Quick-Rからいくつかのウェブページを読んだ後、私はいくつかの名詞(例えばラグ)を理解していませんが、私が持っている売上金額データを予測しようとしました。予想販売量は季節ではないので季節的売上高の予測方法R
# load library
library(dplyr)
library(lubridate)
library(forecast)
# fake data
set.seed(4)
amount_2014 <- c(sample(3000:3500, 6), sample(4000:5000, 6))
set.seed(5)
amount_2015 <- c(sample(3000:3500, 6), sample(4000:5000, 6))
set.seed(6)
amount_2016 <- c(sample(3000:3500, 6), sample(4000:5000, 4))
sales <- data.frame(year = c(rep(2014, 12), rep(2014, 12), rep(2016, 10)),
month = c(1:12, 1:12, 1:10),
amount = c(amount_2014, amount_2015, amount_2016))
sales <- sales %>% mutate(Month = ymd(paste(year, month), truncated =2)) %>%
arrange(Month)
sales_ts <- ts(sales$amount, start = c(sales$year[1], sales$month[1]),
frequency = 12)
# first try
sales_ts_fc_1 <- forecast(sales_ts, h = 13)
sales_ts_fc_1 # the forecast for every month is same
# then try
auto.arima(sales_ts)
sales_ts_arima <- arima(sales_ts, order = c(0, 1, 0))
sales_ts_fc_2 <- forecast.Arima(sales_ts_arima, h = 13)
sales_ts_fc_2 # the forecst for evey month is very close
どちらの試みが失敗しました:
はここにいくつかのコードです。
このような季節のデータを予測するにはどうすればよいですか?
ありがとうございます!
thisを読んモデル季節ホルト冬を使用しよう[SO] Q&自己完結型の、具体的な* *コーディングの質問のためのサイトです。あなたが必要とするのは、時系列分析と予測を学ぶことです。それは本当にSOのためではありません&このフレームワーク内で行うには大きすぎます。 – gung