【问题标题】:decomposition of xts weekly time series in RR中xts每周时间序列的分解
【发布时间】:2019-07-24 21:47:09
【问题描述】:

我有一个每周的时间序列数据 x(x 是一个 'xts' 对象)如下:

date    value
2/1/19  3801
2/8/19  5114
2/15/19 6437
2/22/19 5772
3/1/19  4878
3/8/19  5913
3/15/19 7466
3/17/19 1630

我想分解时间序列数据。但是如果我使用,我会收到错误:

plot(decompose(x))
Error in decompose(x) : time series has no or less than 2 periods

我发现:

frequency(x)
[1] 1

所以我这样做了:

attr(x, 'frequency') <- 7

但我仍然收到分解错误:

plot(decompose(ts(x,frequency = 7)))
Error in decompose(ts(x, frequency = 7)) : 
  time series has no or less than 2 periods

任何帮助将不胜感激。 TIA。

【问题讨论】:

标签: r


【解决方案1】:

嗯,也许可以尝试不同的频率值。来自ts 帮助页面:

"参数频率的值用于在每个单位时间间隔内对序列进行整数次采样。例如,当数据每天采样时,频率可以使用值 7,自然时间可以使用period 是一周,或 12(当数据按月进行采样且自然时间段是一年时)。在(例如)打印方法中假定值 4 和 12 分别表示季度和月度系列。"

因此对于您的数据,以下可能会起作用

decompose(ts(x,frequency = 4))

或者

decompose(ts(x,frequency = 52))

每周

【讨论】:

    最近更新 更多