我不明白R中如何创建时间序列对象。 我有数据:data = c(101,99,97,95,93,91,89,87,85,83,81)
(为了简洁起见,较小的数据集)。 这个数据是每天从2016-07-05
到2016-07-15
开始11天。根据docs,每天采样数据的频率应为7.但我不明白start
和end
参数的值。对于start
,文档说: the time of the first observation. Either a single number or a vector of two integers, which specify a natural time unit and a (1-based) number of samples into the time unit.
我不明白1-based number of samples
是什么意思。我试图谷歌它,但它没有帮助。为R中每日采样的数据创建时间序列R
如果我只是用2016,7
作为开始和结束日期,我只是得到:
Time Series:
Start = c(2016, 7)
End = c(2016, 7)
Frequency = 7
[1] 101
如果我使用2016,7,1
和2016,7,11
作为开始和结束日期,我仍然得到同样的输出。
我在做什么错?
我使用的时间序列预测。我尝试使用'xts',它保持数据的格式我预期(如时间戳和该时间戳的值)。但是我使用xts对象调用'forecast'的输出是一个不再包含这些时间戳的ts对象。我只是看到了价值。 –
解决此问题的唯一方法是通过手动添加日期返回到ts对象,如此处所述http://stackoverflow.com/a/10347205/5795592 不知道只是使用数据会更容易。带日期列的框架。 – hannes101