使用 R 对不均匀间隔的单变量时间序列进行缺失值插补
我有以下数据集:
timestamp value
1 90
3 78
6 87
8 NA
12 98
15 100
18 NA
24 88
27 101
如您所见,连续的时间戳之间的差距不是宽度的。有没有办法使用时间戳依赖性方法来替换NA的值?
我发现的所有包装仅适用于Equi间隔时间序列... 谢谢!
I have the following dataset:
timestamp value
1 90
3 78
6 87
8 NA
12 98
15 100
18 NA
24 88
27 101
As you can see, the gaps between the consecutive timestamps are not equi-spaced. Is there a way to imputate values to replace the NA using a timestamp dependend method?
All packages I found are only suitable for equi-spaced time series...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Zoo < / strong> r软件包可用于处理不规则间隔 /不均匀的时间序列。
首先,您必须创建一个Zoo TS对象。您可以指定索引或使用Posixct时间戳。
之后,您可以在此对象上使用插补方法。动物园的插补方法有限,但它们也用于不规则规格的时间序列。您可以使用线性插值(Na.Approx)或样条插值(NA.Spline),这也解释了时间戳记不均。
您的动物园对象看起来像这样:
以后的估算系列:
当您有时间戳记并且该系列仅略微 /几秒钟,您也可以尝试通过映射您的时间序列值适用于正确的常规间隔。 (仅在差异很小的情况下合理)。通过这样做,您还可以使用其他插补方法,例如质量软件包(仅适用于常规间隔数据)。
The zoo R package can be used to handle irregular spaced / unevenly spaced time series.
First you have to create a zoo ts object. You can either specify indices or use POSIXct timestamps.
Afterwards you can use a imputation method on this object. Zoo's imputation methods are limited, but they also work on irregular speced time series. You can use linear interpolation (na.approx) or spline interpolation (na.spline), which also account for the uneven time stamps.
Your zoo object looks like this:
Your imputed series like this afterwards:
When you have time stamps and the series is only slightly / few seconds off for each time stamp, you could also try to transform the series into a regular time series by mapping your values to the correct regular intervals. (only reasonably if the differences are small). By doing this you could also use additional imputation methods e.g. by the imputeTS package (which only works for regular spaced data).