我很难(gg)绘制实际值与预测值。
这里有一些数据:
# I use caret in order to split the data into train and test
library(caret)
data(economics) # from caret
library(forecast)
# that is recommended for time series data
timeSlices <- createTimeSlices(1:nrow(economics),
initialWindow = 36, horizon = 10, fixedWindow = TRUE)
trainSlices <- timeSlices[[1]]
testSlices <- timeSlices[[2]]
# I'm not really sure about the periods
fit <- tbats(economics[trainSlices[[1]],]$unemploy, seasonal.periods=c(4,12), use.trend=TRUE, use.parallel=TRUE)
# Using forecast for prediction
pred <- forecast(fit,h=length(economics[testSlices[[1]],]$unemploy))
# Here I plot the forecast
plot(pred)
这里我实际上卡住了,并且真的不知道如何将测试数据aka testSlices添加到具有相应测试/训练标签的特定pred对象。也许还有一种方法可以在置信区间使用不同的风格。 谢谢!