Search code examples
rprecisionsuppress-warningsp-value

How to make adf.test print more precise p-value in R


I make a simple cointegration function using add.test from tseries packages

cointegration <- function(vals)
{
    library(tseries)

    beta <- coef(lm(vals[,2] ~ vals[,1] + 0, data = vals))[1]
    names(beta) <- NULL
    res <- adf.test(vals[,2] - beta*vals[,1], alternative = "stationary", k = 0)
    return( list(beta = beta, p.value = res$p.value) )
}

Apparently, adf.test has a lower bound of printed p-value at 0.01. Any value smaller p-value will create a warning message:

Warning message:
In adf.test(vals[, 2] - beta * vals[, 1], alternative = "stationary",  :
  p-value smaller than printed p-value

Is it possible to have adf.test print out more precise p-value instead?

I know the alternative way is to suppress the warning message:

res <- suppressWarnings(adf.test(vals[,2] - beta*vals[,1],
                        alternative = "stationary", k = 0))

But printing more precise p-value would be nice.

Thanks


Solution

  • From the help file of ?adf.test:

    The p-values are interpolated from Table 4.2, p. 103 of Banerjee et al. (1993). If the computed statistic is outside the table of critical values, then a warning message is generated.

    So the short answer is no, you cannot get "more precise" p-values. At least not directly. Anyway, usually it does not make much sense to report anything other than p<0.01.

    If you really want to get the "exact" p-value, you should probably look at the reference below. I don't have access to it, but they probably explain how they came up with their "table of critical values", so it might be possible to extend it.

    A. Banerjee, J. J. Dolado, J. W. Galbraith, and D. F. Hendry (1993): Cointegration, Error Correction, and the Econometric Analysis of Non-Stationary Data, Oxford University Press, Oxford.