有会用R语言的大佬嘛求什么时候均值回转,我就只有265论坛币了跪求代码

265 | CinandJac |浏览65次
2019/09/25 22:20
收藏关注
回答该问题即可获得 2 经验值,问题被采纳即可获得 5 经验值 + 267 财富值!
我来回答
全部回答(1)
  • 回答于 2019/09/29 22:08

    It seems you asked the same question twice. I have responded in the other post. Let me copy the same response to here, in case you are checking this response. 


    If you are asking about how to check whether an AR model is mean-reverting, here are some ideas for your reference. 


    Given an AR model: r(t) = phi_0 + phi_1 r(t−1) + a(t), 

    The necessary and sufficient condition for stationarity is |phi_1| < 1. Please note that the criterion does not include the case when |phi_1| equals 1. Please also note that this condition is also the condition for the AR process to be mean-reverting. 


    Now, under the stationarity condition, what mean level does the process revert to? It is

           E(r(t)) = phi_0 / (1 − phi_1)


    For the R code, I assume you just need to fit your time series to an AR model. The function is just "ar", which you can type "help(ar)" to get the help page. 


    For example, the code line can be: 

           ar(x, order.max = 1, method = "mle")

    Here x is your time series data.


0人关注该问题
+1
 加载中...