mardi 11 juillet 2017

Customizing Output Tests (adf.test, kpss.test, Box.test) in R

I'm working in R with a bunch of different Time Series (actually 17 and will add more) and proceeding some tests. (Here a small piece of my data to show)

> series2 <- list(W, R, M, Ex)
> str(series2)
List of 4
 $ : Time-Series [1:69] from 2000 to 2017: 46 35 23 41 64 69 60 27 10 52 ...
 $ : Time-Series [1:271] from 1995 to 2017: 26 26 26 23.6 23.6 ...
 $ : Time-Series [1:700] from 1959 to 2017: 1.07e+08 8.80e+07 9.50e+07 1.25e+08 1.05e+08 1.08e+08 1.09e+08 1.15e+08 7.90e+07 9.30e+07 ...
 $ : Time-Series [1:700] from 1959 to 2017: 1.23e+08 1.26e+08 1.62e+08 1.36e+08 8.84e+07 ...

I'm running adf.tests like this:

> lapply(series2, adf.test)
[[1]]

    Augmented Dickey-Fuller Test

data:  X[[i]]
Dickey-Fuller = -2.4344, Lag order = 4, p-value = 0.3986
alternative hypothesis: stationary


[[2]]

    Augmented Dickey-Fuller Test

data:  X[[i]]
Dickey-Fuller = -4.6058, Lag order = 6, p-value = 0.01
alternative hypothesis: stationary


[[3]]

    Augmented Dickey-Fuller Test

data:  X[[i]]
Dickey-Fuller = -1.7704, Lag order = 8, p-value = 0.6755
alternative hypothesis: stationary


[[4]]

    Augmented Dickey-Fuller Test

data:  X[[i]]
Dickey-Fuller = 2.6122, Lag order = 8, p-value = 0.99
alternative hypothesis: stationary


Warning messages:
1: In FUN(X[[i]], ...) : p-value smaller than printed p-value
2: In FUN(X[[i]], ...) : p-value greater than printed p-value

I have watched some threads, and this one gives a great help, but as I'll work with some other tests and a lot of ts, I need help.

Is there a way to catch what series the test is running [[1]] to [[4]] and replace by its original name in printing results (instead to i)?

The last one could be:

[[4]]

    Augmented Dickey-Fuller Test

data:  X[[**Ex**]]
Dickey-Fuller = 2.6122, Lag order = 8, p-value = 0.99
alternative hypothesis: stationary

Any hints to improve my results output?

Aucun commentaire:

Enregistrer un commentaire