由于我无法使用您的数据,这里有一个示例,它使用您的方法来 a) 模拟一些具有(某种)季节性的数据,以及 b) 预测下一个时期。
A) 模拟数据
用三个分量模拟数据,一个正弦函数、一个余弦函数和一个随机分量。
# 1. simulate some data:
set.seed(123) # set seed for reproducability
n <- 1000
# simulate the random components
sin.comp <- sin((1:n)/10)*10
cos.comp <- cos((1:n)/5)*5
rand.comp <- rnorm(n)
df <- data.frame(time = seq(from = as.Date("2000-01-01"), by = "day",
length.out = n),
value = sin.comp + cos.comp + rand.comp)
# plot the data
plot(x = df$time, y = df$value, main = "Seasonal Series", type = "l")
lines(x = df$time, y = sin.comp, col = "red")
lines(x = df$time, y = cos.comp, col = "blue")
lines(x = df$time, y = rand.comp, col = "green")
legend("bottomleft",
c("Series", "Sin", "Cos", "Rand"),
lty = c(1, 1),
col = c("black", "red", "blue", "green"), cex = 0.7)
B) 预测系列
y <- msts(df$value, seasonal.periods = c(7, 36)) # cut down to 36
fit <- tbats(y) #takes some time to calculate..
fc <- forecast(fit)
plot(fc)
附加说明
如果这种方法对您不起作用,则意味着您的数据可能以某种方式不适合预测...
要检查您的数据,您可以使用str(mydata)(在我的情况下为str(df))、summary(mydata) 和head/tail(mydata) 来检查类型。
最后一点,您的dput 显然有点太长了...要么发布dput(head(mydata, 100)),它提供前 100 个条目,要么将 csv 上传到托管商并发布链接。
这是否为您指明了正确的方向?