TimeSeriesTests {fSeries}R Documentation

Time Series Tests

Description

A collection and description of functions for testing various aspects of univariate time series, including independence, and neglected nonlinearities.

The family of time series tests includes the following hypothesis tests:

bdsTest Brock–Dechert–Scheinkman test for iid series,
tnnTest Teraesvirta NN test for neglected nonlinearity,
wnnTest White NN test for neglected nonlinearity.

Usage

bdsTest(x, m = 3, eps = NULL, title = NULL, description = NULL) 
tnnTest(x, lag = 1, title = NULL, description = NULL) 
wnnTest(x, lag = 1, qstar = 2, q = 10, range = 4, title = NULL, description = NULL) 

Arguments

description optional description string, or a vector of character strings.
eps [bdsTest] -
a numeric vector of epsilon values for close points. The BDS test is computed for each element of eps. It should be set in terms of the standard deviation of x. If eps is NULL, then the four default values seq(0.5*sd(x), 2*sd(x), length = 4) are used.
lag [tnnTest][wnnTest] -
an integer which specifies the model order in terms of lags.
m [bdsTest] -
an integer indicating that the BDS test statistic is computed for embedding dimensions 2, ..., m.
q [wnnTest] -
an integer representing the number of phantom hidden units used to compute the test statistic.
qstar [wnnTest] -
the test is conducted using qstar principal components of the phantom hidden units. The first principal component is omitted since in most cases it appears to be collinear with the input vector of lagged variables. This strategy preserves power while still conserving degrees of freedom.
range [wnnTest] -
the input to hidden unit weights are initialized uniformly over [-range/2, range/2].
title an optional title string, if not specified the inputs data name is deparsed.
x a numeric vector or an object of class "timeseries".

Details

Brock–Dechert–Sheinkman Test:

The bdsTest test examines the spatial dependence of the observed series. To do this, the series is embedded in m-space and the dependence of x is examined by counting near points. Points for which the distance is less than eps are called near. The BDS test statistic is asymptotically standard Normal. Note, that missing values are not allowed. There is a special print method for objects of class "bdsTest" which by default uses 4 digits to format real numbers.
[tseries:bds.test]

Teraesvirta Neural Network Test:

The null is the hypotheses of linearity in mean. This test uses a Taylor series expansion of the activation function to arrive at a suitable test statistic. If type equals "F", then the F-statistic instead of the Chi-Squared statistic is used in analogy to the classical linear regression. Missing values are not allowed.
[tseries:teraesvirta.test]

White Neural Network Test:

The null is the hypotheses of linearity in ``mean''. This type of test is consistent against arbitrary nonlinearity in mean. If type equals "F", then the F-statistic instead of the Chi-Squared statistic is used in analogy to the classical linear regression.
[tseries:white.test]

Value

In contrast to R's output report from S3 objects of class "htest" a different output report is produced. The tests here return an S4 object of class "fHTEST". The object contains the following slots:

@call the function call.
@data the data as specified by the input argument(s).
@test a list whose elements contail the results from the statistical test. The information provided is similar to a list object of class{"htest"}.
@title a character string with the name of the test. This can be overwritten specifying a user defined input argument.
@description a character string with an optional user defined description. By default just the current date when the test was applied will be returned.
statistic the value(s) of the test statistic.
p.value the p-value(s) of the test.
parameters a numeric value or vector of parameters.
estimate a numeric value or vector of sample estimates.
conf.int a numeric two row vector or matrix of 95
method a character string indicating what type of test was performed.
data.name a character string giving the name(s) of the data.

Note

There is nothing really new in this package. The benefit you will get from this help page, that we bring together a collection of time series tests from several R-packages which may be of interest for economists and financial engineers.

On the other hand the user can still use the underlying function calls from the imported R-packages.

The output of the various hypothesis tests is an object of class htest. The associated print method gives an unique report about the test results.

Author(s)

Adrian Trapletti for the tests from R's tseries package,
Blake LeBaron for the bds C program,
Diethelm Wuertz for the Rmetrics R-port.

References

Brock, W.A., Dechert W.D., Sheinkman J.A. (1987); A Test of Independence Based on the Correlation Dimension, SSRI no. 8702, Department of Economics, University of Wisconsin, Madison.

Conover, W.J. (1980); Practical Nonparametric Statistics, New York, Wiley.

Cromwell J.B., Labys W.C., Terraza M. (1994); Univariate Tests for Time Series Models, Sage, Thousand Oaks, CA, pages 32–36.

Lee T.H., White H., Granger C.W.J. (1993); Testing for neglected nonlinearity in time series models, Journal of Econometrics 56, 269–290.

Teraesvirta T., Lin C.F., Granger C.W.J. (1993); Power of the Neural Network Linearity Test, Journal of Time Series Analysis 14, 209–220.

Examples

## SOURCE("fSeries.5B-TimeSeriesTests")

## bdsTest -
   # iid Time Series:
   par(mfrow = c(3, 1))
   x = rnorm(100)
   plot(x, type = "l", main = "iid Time Series")
   bdsTest(x, m = 3)
   # Non Identically Distributed Time Series:
   x = c(rnorm(50), runif(50))
   plot(x, type = "l", main = "Non-iid Time Series")
   bdsTest(x, m = 3)  
   # Non Independent Innovations from Quadratic Map:
   x = rep(0.2, 100)
   for (i in 2:100) x[i] = 4*(1-x[i-1])*x[i-1]
   plot(x, type = "l", main = "Quadratic Map")
   bdsTest(x, m = 3)
   
## tnnTest -
   # Time Series Non-linear in "mean" regression 
   par(mfrow = c(2, 1))
   n = 1000
   x = runif(1000, -1, 1)  
   tnnTest(x)
   # Generate time series which is nonlinear in "mean"
   x[1] = 0.0
   for (i in (2:n)) {
     x[i] = 0.4*x[i-1] + tanh(x[i-1]) + rnorm (1, sd = 0.5) }
   plot(x, main = "Teraesvirta Test", type = "l")
   tnnTest(x)
   
## wnnTest -
   # Time Series Non-Linear in "mean" Regression
   par(mfrow = c(2, 1))
   n = 1000
   x = runif(1000, -1, 1)
   wnnTest(x)
   # Generate time series which is nonlinear in "mean"
   x[1] = 0.0
   for (i in (2:n)) {
     x[i] = 0.4*x[i-1] + tanh(x[i-1]) + rnorm (1, sd = 0.5) }
   plot(x, main = "White Test", type = "l")
   wnnTest(x)                     

[Package fSeries version 240.10068 Index]