0

I have run the ADF test (using ur.df from the urca package) on my multivariate zoo object. Now the results are stored in a large list, when I use the show() function, there are too many results reported:

$Company_A

############################################################### 
# Augmented Dickey-Fuller Test Unit Root / Cointegration Test # 
############################################################### 

The value of the test statistic is: -0.5293 


$Company_B


############################################################### 
# Augmented Dickey-Fuller Test Unit Root / Cointegration Test # 
############################################################### 

The value of the test statistic is: -0.4645 

This goes on for several hundred companies and analyzing the output manually would take far too much time, so I would like to simplify the process.

I have found out from other posts that I can directly access the test-statistic of an individual company with the following code:

show(data$Company_A@teststat)

Now I would like to combine this function with the sapply function to quickly retrieve all test-statistics from the results of the ADF test. I've tried the following code:

sapply(data, show, teststat)
sapply(data, show, @teststat)

Both of which unforunately only return errors (first one says "object teststat not found" and second one says "unexpected @ in sapply").

Olorun
  • 419
  • 6
  • 18

1 Answers1

0

Try this:

sapply(data, function(x) show(x@teststat))
Davide Passaretti
  • 2,741
  • 1
  • 21
  • 32
  • Great! This produced a long list of test statistics, but also produced a long list of the company names following by 'NULL'. Is there any way I can save the test-statistics into a new variable, preferably a vector? I've just written test <- sapply(data, function(x) show(x@teststat)) but only the company names are stored in 'test'. – Olorun May 27 '14 at 09:16
  • What about just using `sapply(data, function(x) x@teststat)`? Is the `show` function so necessary? – Davide Passaretti May 27 '14 at 09:20
  • Yeah just realized that myself ^^ Thanks! – Olorun May 27 '14 at 09:22
  • 1
    If you use the function `slot`, you don't need the `function(x)` part and can use `sapply(data, slot, "teststat")` instead. – shadow May 27 '14 at 09:30