进行单位根检验有如下方法:
TSA包的adf.test(x, alternative = c("stationary", "explosive"), k = trunc((length(x)-1)^(1/3)))这个不能设置漂移项和趋势项。
urca包的ur.df(y, type = c("none", "drift", "trend"), lags = 1, selectlags = c("Fixed", "AIC", "BIC"))这个可以选择漂移项和趋势项,Lags注意增加,根据具体的值进行差分。然后看value of test-statistic的第一个值,这个值跟z.lag.1的值一样,看最后的p值来判断是否平稳。
urca包的ur.pp(x, type = c("Z-alpha", "Z-tau"), model = c("constant", "trend"), lags = c("short", "long"), use.lag = NULL)
urca包的ur.kpss(y, type = c("mu", "tau"), lags = c("short", "long", "nil"),use.lag = NULL)。将value of test-statistic的值与5%对应的值比较,小于5%则平稳。