折扣旧时间序列值,指数平滑
我想从另一个时间序列构建一个时间序列,折扣旧值。即,通常将最新值包含在总和中,并使用 delta^t 折扣先前的值。然后添加一个新值,该值通常再次包含在新时间序列中,然后使用 delta^t 和 delta^(tk) 对旧值进行折扣。整个事情应该是这样的:
Data: df<- c(0.4387738, 0.05203873, 0.3238407, 0.1117364)
> test[[1]][["se_ne"]][[1]]
[1] 0.4387738
>
> test[[2]][["se_ne"]][[2]] + 0.4^(2-1)*test[[2]][["se_ne"]][[2-1]]
[1] 0.2275482
>
> test[[3]][["se_ne"]][[3]] + 0.4^(3-2)*test[[3]][["se_ne"]][[3-1]] + 0.4^(3-1)*test[[3]][["se_ne"]][[3-2]]
[1] 0.41486
但是数据集有超过 700 个观察值,是否有比手动计算所有内容更智能的解决方案?
感谢您的反馈!
I would like to build a time series from another time series, discounting older values. That is, the most recent value is included in the sum normally, and the previous value is discounted with delta^t. Then a new value is added, which is again normally included in the new time series, the older values are then discounted with delta^t and delta^(t-k). The whole thing should look like this:
Data: df<- c(0.4387738, 0.05203873, 0.3238407, 0.1117364)
> test[[1]][["se_ne"]][[1]]
[1] 0.4387738
>
> test[[2]][["se_ne"]][[2]] + 0.4^(2-1)*test[[2]][["se_ne"]][[2-1]]
[1] 0.2275482
>
> test[[3]][["se_ne"]][[3]] + 0.4^(3-2)*test[[3]][["se_ne"]][[3-1]] + 0.4^(3-1)*test[[3]][["se_ne"]][[3-2]]
[1] 0.41486
But the dataset has over 700 observations, is there a smarter solution than calculating everything by hand?
Thanks for the feedback!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这个答案可能对您有帮助:
指数平滑方法
如果没有,那么下一步将是一个很好的选择是为了解释该帖子和您的问题之间的差异。
Perhaps this SO answer might help you:
Exponential smoothing method
If it does not, then a good next step would be to explain the differences between that post and your question.