adam.888
adam.888

Reputation: 7846

Performing adf test on a data.frame

I can perform an adf test on a vector:

library(tseries)
ht <- adf.test(vector, alternative="stationary", k=0)

but I am having trouble performing it on columns of values in a data.frame:

ht <- adf.test(dataframe, alternative="stationary", k=0)

Is there a way of doing this?

Upvotes: 1

Views: 2748

Answers (2)

Johannes Kutsam
Johannes Kutsam

Reputation: 240

To get the pvalues of all the variables in one table you can us ldply from the plyr package.

pvalues=ldply(ht, function(x){ x$p.value })

Upvotes: 3

schadr
schadr

Reputation: 398

ht <- lapply(dataframe, adf.test, alternative="stationary", k=0)

should do the trick as @Andrie pointed out. It will return you a list with an element for each column in the dataframe

Upvotes: 3

Related Questions