请考虑以下小数据集:
library(xts)
library(ggplot2)
library(forecast)
data <- data.frame(idDate = c("12-12-2012", "13-12-2012", "14-12-2012", "16-12-2012", "19-12-2012"), score= c(110, 120, 130, 200, 180))
date <- as.Date(as.character(data$idDate), "%d-%m-%Y")
score <- as.numeric(data$score)
myxts <- xts(score, date)
autoplot(myxts)
目前为止,沿着x轴的日期(指标)被保留,但是一旦我调用forecast,我沿着x轴的日期就变成了整数。如下所示:
d.arima <- auto.arima(myxts)
d.forecast <- forecast(d.arima, level = c(95), h = 3)
d.forecast
autoplot(d.forecast)
问题: 如何保留myxts
的索引?是否有办法告诉forecast
或auto.arima
保留来自myxts
的日期(索引)?
forecast
还告诉你预测的日期吗? - lebelinoz