用XTS对象预测Arima
我有两个XTS对象(一列火车和一个测试/验证集),我想使用基于火车数据集的Arima模型在测试数据集上进行一步预测(即,一步一步样本预测)。但是,每当我使用“预测”功能时,结果似乎很奇怪。这可能是因为预测()假定一个时间序列对象,而我具有XTS对象。 我想知道是否有人知道我想完成的工作?我也想产生像上载的图一样,但是由于我相信使用XTS对象,这再次非常奇怪。 我真的很感谢您的帮助,因为我真的卡在分析的这一步骤中!:) 我的训练集:
dput(head(xts.data)) 结构(C(2.74983173511717,2.75110969056266,2.79971738962803, 2.81540871942271,2.9343864331294,3.01504458458636,NA,0.0012779554549159, 0.0486076990653772,0.0156913297946755,0.11897992389023,0.080659412734247 ),class = c(“ XTS”,“ Zoo”),index = structure(C(1333324800,1333411200, 1333497600,1333584000,1333929600,1334016000),tzone =“ utc”,tclass =“ date”),.dim = c(6l,6l,, 2L),.dimnames = list(null,c(“ lvixcls”,“ ldvixcls”)))
我的验证集:
dput(头(验证)) 结构(C(3.2846635654062,3.31890213893533,3.33077491736561, 3.38371206732114,3.33434507467431,3.27184770963431),类= C(“ XTS”, “ Zoo”),索引=结构(C(1601510400,1601596800,1601856000, 1601942400,1602028800,1602115200),tzone =“ utc”,tclass =“ date”),.dim = c(6l,,6l,, 1L),.dimnames = list(null,“ lvixcls”))
这是我的训练集(用我的训练集(对LVIXCLS建模lvixcls) arima)
r-code:
data<- read_excel("VIXCLS 10 year data.xls")
data<-na.omit(data)
date <- as.Date(data$Date, "%m/%d/%Y")
ts.data<-data
ts.data$Date<-as.Date(ts.data$Date, format="%m/%d/%Y")
xts.data2 <- xts(ts.data[2],ts.data$Date)
ts.data$Date<-as.Date(ts.data$Date, format="%m/%d/%Y")
xts.data2 <- xts(ts.data[2],ts.data$Date)
xts.data<-xts.data2$lVIXCLS[0:2139]
validation<-xts.data2$lVIXCLS[2140:2517]
I have two xts objects (one train and one test/validation set) and I would like to use ARIMA models based on the train data set to carry out one-step-ahead forecast on the test dataset (namely, one-step out of sample forecasting). However, whenever I use the "forecast" function, the results seem weird. It's probably because forecast() assumes a time series object and I have xts objects.
I was wondering if anyone knows an R command for what I want to accomplish? I would also like to produce a graph like the uploaded one, but once again it turns out very weird due to using xts objects I believe.
I would really appreciate your help as I'm really stuck on this step of my analysis!:)
My training set:
dput(head(xts.data))
structure(c(2.74983173511717, 2.75110969056266, 2.79971738962803,
2.81540871942271, 2.93438864331294, 3.01504458458636, NA, 0.00127795544549159,
0.0486076990653772, 0.0156913297946755, 0.11897992389023, 0.0806559412734247
), class = c("xts", "zoo"), index = structure(c(1333324800, 1333411200,
1333497600, 1333584000, 1333929600, 1334016000), tzone = "UTC", tclass = "Date"), .Dim = c(6L,
2L), .Dimnames = list(NULL, c("lVIXCLS", "ldVIXCLS")))
My validation set:
dput(head(validation))
structure(c(3.2846635654062, 3.31890213893533, 3.33077491736561,
3.38371206732114, 3.33434507467431, 3.27184770963431), class = c("xts",
"zoo"), index = structure(c(1601510400, 1601596800, 1601856000,
1601942400, 1602028800, 1602115200), tzone = "UTC", tclass = "Date"), .Dim = c(6L,
1L), .Dimnames = list(NULL, "lVIXCLS"))
This is my training set (modelling lVIXCLS with ARIMA)
This is my validation dataset
Graph I would like to produce
R-code:
data<- read_excel("VIXCLS 10 year data.xls")
data<-na.omit(data)
date <- as.Date(data$Date, "%m/%d/%Y")
ts.data<-data
ts.data$Date<-as.Date(ts.data$Date, format="%m/%d/%Y")
xts.data2 <- xts(ts.data[2],ts.data$Date)
ts.data$Date<-as.Date(ts.data$Date, format="%m/%d/%Y")
xts.data2 <- xts(ts.data[2],ts.data$Date)
xts.data<-xts.data2$lVIXCLS[0:2139]
validation<-xts.data2$lVIXCLS[2140:2517]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了能够在{tocast}软件包中将功能应用于数据,您只需要使用
as.ts
将数据转换为时间序列即可。例如:然后,您可以使用模型预测值:
绘制预测数据
您还可以使用
plot
:您可以使用与相同的步骤分析测试数据多于。
To be able to apply the functions in {forecast} package to your data, you just need to convert the data to a time series by using
as.ts
. For example:Then, you can use the model to forecast values:
You can also plot the forecast data using
plot
:You can analyze the test data with the same steps as above.