Learn R Programming

FinTS (version 0.4-5)

Unitroot: unit root tests

Description

Test for a unit root, comparable to 'unitroot' from S-PLUS Finmetrics used in the examples on pp. 70-72 of Tsay (2005).

NOTE: This help page is written without access to S-PLUS Finmetrics, and functionality beyond that in those two examples could change in the future.

Usage

Unitroot(x, trend=c("c", "nc", "ct"), method=c('adf', 'McKinnon'), lags=2) "summary"(object, ...)

Arguments

x
a numvariate time series or numeric vector
trend
a character string describing the type of the unit root regression. Valid choices are '"nc"' for a regression with no intercept (constant) nor time trend, and '"c"' for a regression with an intercept (constant) but no time trend, '"ct"' for a regression with an intercept (constant) and a time trend.
method
character string, 'adf' to use 'adfTest' and "McKinnon" to use 'unitrootTest' in 'fUnitRoots' package.
lags
the maximum number of lags used for error term correction.

NOTE: This is one more than the 'lags' argument used in 'adfTest', 'unitrootTest', 'ADF.test' and 'ur.df'. See the comparison in the examples. The default was copied from 'ur.df' and 'UnitrootTests', noting that the 'lags' argument for other R functions are one less than that of 'unitroot' in S-PLUS Finmetrics.

object
an object of class 'fHTEST', as returned by 'unitroot'.
...
optional arguments for 'summary'; not currently used.

Value

an object of class '"fHTEST"' as described with 'UnitrootTests' in the 'fUnitRoots' package, except that the returned vallue may not have a slot 'data.name' described with 'Unitroottests'.

Details

There are 3 functions in different contributed packages in R for the Augmented Dickey-Fuller test (as of 2009.08.24):

adf.test{tseries} by A. Trapletti

adfTest{fUnitRoots} by Diethelm Wuertz, based on Trapletti's algorithm

ur.df{urca} by Bernhard Pfaff

This 'Unitroot' function and the companion 'summary.fHTEST' use 'adfTest'. It is provided for partial compatibility with the S-PLUS Finmetrics examples on pp. 70-72 of Tsay (2005). As noted in the examples below, this function produces a very close match for the numbers on pp. 70-72, except for the ADF p-value in the first example. For this, 'adfTest' (and hence 'Uniroot') uses linear interpolation in a crude table. This could be improved. See the examples below.

NOTE: This function uses diff(x) rather than x as the response, so it tests whether the coefficient of lag(x) is different from 0 rather than testing if the coefficient is different from 1. I mention it, because the formula on the middle of p. 69 in Tsay (2005) describes the "ADF-test" as comparing the regression coefficient to 1, rather than to 0.

References

Ruey Tsay (2005) Analysis of Financial Time Series, 2nd ed. (Wiley)

See Also

UnitrootTests

ur.df

Examples

Run this code
##
## Tsay, pp. 69-71
##
data(q.gdp4703)
adft.gdp <- Unitroot(log(q.gdp4703), trend='c', method='adf', lags=10)
summary(adft.gdp)
# Except for the p-value and degrees of freedom for residual std error,
# all numbers matched the S-Plus Finmetrics answers.

##
## Tsay, pp. 71-72
##
data(d.sp9003lev)
adft.sp <- Unitroot(log(d.sp9003lev), trend='ct', method='adf', lags=14)
summary(adft.sp)

##
## Using adfTest{fUnitRoots} directly
##
adfTest(log(q.gdp4703), lags=9, type='c')
# Gives the ADF statistic and p-value but not the table.

##
## Using ur.df{urca}
##
if(require(urca))ur.df(log(q.gdp4703), type='drift', lags=9)
# prints 2 numbers:
# The first is the ADF statistic on Tsay, p. 70.
# It's not obvious what the second number is.










##
## Using adf.test{tseries}
##
if(require(tseries))
  adf.test(log(as.numeric(q.gdp4703)), alternative="stationary", k=9)
# None of the numbers match;  I don't know why.

Run the code above in your browser using DataLab