我有一个时间序列,该序列代表了某种产品在2018年全年的销售量。我试图分解该时间序列,但是遇到以下错误Error in decompose(myzoo) : time series has no or less than 2 periods
。这是我在R
## requiere packages
library(forecast)
library(sweep)
library(timetk)
library(zoo)
## Read the Data
Data <- read.delim("R Project/Dataset/MyData.txt")
## Create a daily Date object
inds <- seq(as.Date("2018-01-01"), as.Date("2018-12-31"), by = "day")
## Create a time series object
myzoo <- zoo(Data, inds)
## print myzoo
print(myzoo)
## plot myzoo
plot(myzoo)
plot(myzoo, xaxt = "n")
Axis(inds, side = 1, at = seq(inds[1], tail(inds, 1) + 60, by = "1 months"), format = "%b %Y")
## Decompose myzoo
composition = decompose(myzoo)
stl(myzoo)
## use auto.arima to choose ARIMA terms
fit <- auto.arima(myzoo)
## forecast for next 60 time points
fore <- forecast(fit, h = 15, level=c(99.5))
## plot it with no x-axis
plot(fore, xaxt = "n")
Axis(inds, side = 1, at = seq(inds[1], tail(inds, 1) + 60, by = "1 months"), format = "%b %Y")
这是我的数据(MyData.txt):
X
0
2621
3407
3644
3569
1212
0
0
4473
3885
3671
3641
1453
0
4182
3812
3650
3444
3557
1612
0
4004
3631
3342
3203
3424
1597
0
4280
3644
3642
3696
3793
1753
0
4416
3935
3522
3544
3569
1649
0
3871
3442
3144
3158
3693
1780
0
4322
3682
3499
3279
3485
1716
0
4255
3713
3470
3673
3983
1931
0
4771
3986
3833
3501
3620
1710
0
4407
3799
3654
3332
3693
1780
0
0
4574
4016
3748
3559
1625
0
4548
3726
2780
0
0
122
0
5005
4300
3772
3929
3917
2021
0
4820
4117
3668
3664
3639
1742
0
4473
4151
3844
3499
3736
1838
0
4346
3693
3297
3327
3639
1773
0
4519
0
4352
4079
4143
1970
0
4693
4018
3679
3838
3606
1601
0
0
4289
4011
3742
3710
1781
0
4186
3707
3600
3484
3702
1747
0
4195
3838
3504
3609
3934
1943
0
0
5243
4754
4164
4121
1854
0
0
5173
4518
3875
3889
1904
0
5105
4056
4186
4079
3953
1846
0
4543
4341
4013
2998
4048
1767
0
0
4317
5260
5185
4969
2046
0
5683
5004
4567
4542
4266
2065
0
4357
5281
4830
4510
0
1567
0
5818
4906
4518
4218
4275
2074
0
5005
4645
4543
4558
4574
2129
0
4755
0
4458
3845
3746
1689
0
4285
3476
3447
2959
3470
1584
0
0
4159
3881
3533
3360
1643
0
4152
3748
3329
3112
3303
1790
0
3852
4190
3482
3313
3400
1582
0
4042
3706
3451
3137
3178
1518
0
4077
3754
3429
3369
3307
1467
0
3918
3620
3442
3302
3168
1630
0
3967
3707
3397
3294
3314
1646
0
4196
3812
3478
3111
3113
1411
0
0
3717
3501
3282
3366
1554
0
3737
3428
3028
2960
2977
1513
0
3608
3306
2941
2918
3238
1543
0
0
3959
3678
3367
3237
1024
0
0
4057
3562
3344
3367
1602
0
3784
3581
3395
2948
3009
1446
0
3676
3276
3112
3125
3133
1502
0
4200
4027
3739
3531
3222
2
0
4446
4342
4066
3811
2932
1643
0
4587
4534
4146
3994
3350
1400
0
1248
0
4248
4629
4346
1844
0
168
零代表假日和星期日的销售额。该脚本的目的是能够进行预测。
谢谢。