R 绘制滚动预测日内时间序列自定义间隔
我想从SPY中绘出日内30分钟数据的历史预测。数据是 我首先根据过去10天的时间窗口绘制预测图。h=13是一个交易日的30分钟间隔数R 绘制滚动预测日内时间序列自定义间隔,r,time-series,forecasting,R,Time Series,Forecasting,我想从SPY中绘出日内30分钟数据的历史预测。数据是 我首先根据过去10天的时间窗口绘制预测图。h=13是一个交易日的30分钟间隔数 require(forecast) a.win <- window(spy.close,start = end(spy.close)[1]-10*1440*60,end =end(spy.close)[1]) a.fit <- auto.arima(a.win) a.pred <- forecast(a.fit, h=13) plot(a
require(forecast)
a.win <- window(spy.close,start = end(spy.close)[1]-10*1440*60,end =end(spy.close)[1])
a.fit <- auto.arima(a.win)
a.pred <- forecast(a.fit, h=13)
plot(a.pred, type="l", xlab="period", ylab="price",
main="Overlay historic forecasts & actual prices")
require(预测)
a、 赢
for (j in seq(1, 5, by=1)) { ## Loop to overlay early forecasts
result1 <- tryCatch({
b.end <- end(spy.close)[1]-j*1440*60 ## Window the time series
b.start <- b.end[1]-10*1440*60
b.window <- window(spy.close, start=b.start, end=b.end)
b.fit <-auto.arima(b.window)
b.pred <- forecast(b.fit, h=13)
lines(b.pred$mean, col="green", lty="dashed" )
}, error = function(e) {return(e$message)} ) ## Skip Errors
}