0

我在将以下数据集转换为 ts 以与 stats::arima 一起使用时遇到问题我能够转换为 xts 对象,但 arima 似乎不喜欢它。有人可以指导我如何将其转换为 ts 吗?我真的需要在这里使用 arima 模型。谢谢

library(ggfortify)
library(xts)
wt <- structure(list(SampleDate = structure(c(13687, 13694, 13701, 
13708, 13715, 13722, 13729, 13736, 13743, 13750, 13757, 13764, 
13771, 13778, 13785), class = "Date"), DOC = c(3, 10, 17, 24, 
31, 38, 45, 52, 59, 66, 73, 80, 87, 94, 101), AvgWeight = c(1, 
1.66666666666667, 2.06666666666667, 2.275, 3.83333333333333, 
6.2, 7.4, 8.5, 10.25, 11.1, 13.625, 15.2, 16.375, 17.8, 21.5), 
    PondName = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L), .Label = "Pond01", class = "factor")), row.names = c(NA, 
15L), class = "data.frame")

pond <- as.xts(wt$AvgWeight,order.by=seq(as.Date("2007-06-23"), by=7, len=15))
d.arima <- arima(pond)

#arima is not recognized.....probably because I need a ts and not a xts object here.....
autoplot(d.arima, predict = predict(d.arima, n.ahead = 3,prediction.interval = TRUE,level=0.95), 
ts.colour='dodgerblue',predict.colour='green',
predict.linetype='dashed',ts.size=1.5,conf.int.fill='azure3') + xlab('DOC') + ylab('AvgWeight-grs') + 
theme_bw() 

我得到了这个奇怪的情节...... 在此处输入图像描述

4

0 回答 0