如何使系列固定

时间:2019-03-26 10:04:00

标签: r time-series

我有如下系列:

dat <- c(9, 8, 10, 10, 11, 12, 16, 20, 18, 18, 21, 22, 25, 14)

如果您可以共享如何使该系列平稳的话,那将是一个很大的帮助。我已经尝试过difflog转换,但是到现在为止还是有帮助的。增强的Dickey-Fuller检验仍然微不足道。

1 个答案:

答案 0 :(得分:0)

例如,可以通过将CoxBoxdiff结合使用来使数据保持不变,例如:

    # getting package for CoxBox transformations
    library(RxODE)      

    # setting up your data
    dat <- c(9, 8, 10, 10, 11, 12, 16, 20, 18, 18, 21, 22, 25, 14)

    # checking the stationarity
    adf.test(diff(coxBox(dat, lambda=5)))
    #   Augmented Dickey-Fuller Test
    # data:  diff(coxBox(dat, lambda = 5))
    # Dickey-Fuller = -3.8838, Lag order = 2, p-value = 0.02973
    # alternative hypothesis: stationary

    adf.test(diff(coxBox(dat, lambda=4)))
    # Augmented Dickey-Fuller Test
    # data:  diff(coxBox(dat, lambda = 4))
    # Dickey-Fuller = -3.7048, Lag order = 2, p-value = 0.04251
    # alternative hypothesis: stationary

    adf.test(diff(coxBox(dat, lambda=-3)))
    # Augmented Dickey-Fuller Test
    # data:  diff(coxBox(dat, lambda = -3))
    # Dickey-Fuller = -4.2585, Lag order = 2, p-value = 0.01424
    # alternative hypothesis: stationary

Box-Cox的倒数可以像this一样完成:

library(bimixt)
dat <- c(9, 8, 10, 10, 11, 12, 16, 20, 18, 18, 21, 22, 25, 14) # Original data
dat_cb <- coxBox(dat, lambda=3)                                # data after Cox Box transformation with lambda=3
dat_inv_cb <- boxcox.inv(dat_cb, lambda=3)                     # data after INVERSE Cox Box transformation with lambda=3

dat_inv_cb
#  [1]  9  8 10 10 11 12 16 20 18 18 21 22 25 14