以下是我的代码,
auto<-auto.arima(x)
auto_for<-forecast(auto,h=30)
> auto_for$x
Time Series:
Start = 1
End = 74
Frequency = 1
[1] 151 151 151 151 151 219 465 465 465 465 465 743 743 743 743 743 743 743 743 743 743 743
[23] 743 743 743 743 743 743 743 829 829 829 829 829 829 1004 1004 1004 1424 1424 1424 1822 1941 1941
[45] 1941 1941 1941 1941 1941 2076 2076 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2940 2940 2940
[67] 2940 2940 3134 3134 3134 3207 3207 3465
> auto_for
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
75 3510.397 3359.577 3661.217 3279.738 3741.056
76 3555.795 3342.503 3769.086 3229.594 3881.996
77 3601.192 3339.964 3862.419 3201.679 4000.705
78 3646.589 3344.949 3948.229 3185.271 4107.907
79 3691.986 3354.743 4029.230 3176.217 4207.755
80 3737.384 3367.952 4106.815 3172.387 4302.380
81 3782.781 3383.749 4181.812 3172.515 4393.047
82 3828.178 3401.595 4254.761 3175.776 4480.580
83 3873.575 3421.116 4326.035 3181.599 4565.552
84 3918.973 3442.039 4395.907 3189.565 4648.380
85 3964.370 3464.157 4464.582 3199.361 4729.379
86 4009.767 3487.312 4532.222 3210.741 4808.793
87 4055.164 3511.376 4598.953 3223.512 4886.817
88 4100.562 3536.246 4664.878 3237.515 4963.608
89 4145.959 3561.836 4730.081 3252.621 5039.297
90 4191.356 3588.077 4794.635 3268.720 5113.992
91 4236.753 3614.908 4858.599 3285.722 5187.785
我有预测值,但我无法从模型中获取日期。图表中没有日期,它已从0更改为91,而不是我的实际日期。我在开始时使用了xts变量。
更新
> a<-ts(ana)
> a
Time Series:
Start = 1
End = 68
Frequency = 1
final.day final.cumsum135
1 16535 318
2 16536 318
3 16537 318
4 16538 318
5 16539 318
6 16540 318
7 16541 318
8 16542 318
9 16543 318
10 16544 318
11 16545 318
12 16546 318
13 16547 318
14 16548 318
15 16549 318
16 16550 318
17 16551 318
18 16552 318
19 16553 318
20 16554 318
21 16555 318
22 16556 318
23 16557 318
24 16558 318
25 16559 318
26 16560 369
27 16561 369
28 16562 369
29 16563 369
30 16564 369
31 16565 369
32 16566 369
33 16567 369
34 16568 369
35 16569 369
> auto<-arima(a)
Error in arima(a) : only implemented for univariate time series
我有什么办法可以在这里找回日期吗?
答案 0 :(得分:0)
惠特日常系列,有时适合和预测&#34;失去&#34;日期。您可以使用索引手动获取日期:
y=x # x is your xts series
n=length(y)
model_a1 <- auto.arima(y)
# the plot
plot(x=1:n,y,xaxt="n",xlab="")
axis(1,at=seq(1,n,length.out=20),labels=index(y)[seq(1,n,length.out=20)],
las=2,cex.axis=.5)
lines(fitted(model_a1), col = 2)
#the forecast
auto_for<-forecast(model_a1,h=30)
fcs=xts(auto_for$mean,seq.Date(as.Date(index(y)[n]),by=1,length.out=30))
fcs