QBoard » Statistical modeling » Stats - Tech » Performing adf test on a data.frame

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? This post was edited by Rakesh Racharla at September 22, 2020 11:33 AM IST
      June 11, 2019 4:31 PM IST
    0
    • Jasmine Chacko
      Jasmine Chacko lapply is going to be your friend. The answer is going to be something like lapply(dataframe, adf.test, ...)
      September 22, 2020
  • 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 })​
    This post was edited by Raji Reddy A at September 22, 2020 11:35 AM IST
      June 11, 2019 4:33 PM IST
    0
  • ht <- lapply(dataframe, adf.test, alternative="stationary", k=0)​

    should do the trick . It will return you a list with an element for each column in the dataframe This post was edited by Pranav B at September 22, 2020 11:36 AM IST
      June 14, 2019 1:04 PM IST
    0
  • 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

     
      January 13, 2022 1:41 PM IST
    0