【问题标题】:how to extract a subset of time series using windows() function?如何使用 windows() 函数提取时间序列的子集?
【发布时间】:2018-03-22 01:32:07
【问题描述】:

我使用窗口函数来提取时间序列的子集。但有时它无法正常运行。示例如下所示。有什么建议吗?

library(Mcomp)
monthly_m1 <- subset(M1, "monthly")
x <- monthly_m1[[150]]$xx
endx <- end(x)
window(x, end=c(endx[1],endx[2]-17)) # gives the first observation in x

但以下不起作用

monthly_m1 <- subset(M1, "monthly")
y <- monthly_m1[[171]]$xx
endy <- end(y)
window(y, end=c(endy[1],endy[2]-17)) # does not give the first observation in y

【问题讨论】:

    标签: r time-series


    【解决方案1】:

    如果您只想在每个中进行第一次观察,请使用

    subset(x, end=1)
    subset(y, end=1)
    

    使用带有负值的window 似乎有问题,可能是由于时代的一些四舍五入问题。

    【讨论】:

      猜你喜欢
      • 2016-10-09
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 2020-01-05
      • 2021-05-20
      • 2016-09-06
      • 2017-07-04
      相关资源
      最近更新 更多