Description Usage Arguments Details Value Author(s) References See Also Examples

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.

1 2 3 4 |

`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. |

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.

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'.

Adrian Trapletti and Diethelm Wuertz for the 'fUnitRoots' functions used, and Spencer Graves for the 'FinTS' interface, with help from Javier Lopez de Lacalle and Bernard Pfaff.

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ```
##
## 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.
``` |

FinTS documentation built on May 29, 2017, 9:08 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.