np.sdeptest.Rdnpsdeptest implements the consistent metric entropy test of
nonlinear serial dependence as described in Granger, Maasoumi and
Racine (2004).
npsdeptest(data = NULL,
lag.num = 1,
method = c("integration","summation"),
bootstrap = TRUE,
boot.num = 399,
random.seed = 42)a vector containing the variable that can be of type
numeric or ts.
an integer value specifying the maximum number of lags to
use. Defaults to 1.
a character string used to specify whether to compute the integral
version or the summation version of the statistic. Can be set as
integration or summation (see below for
details). Defaults to integration.
a logical value which specifies whether to conduct
the bootstrap test or not. If set to FALSE, only the
statistic will be computed. Defaults to TRUE.
an integer value specifying the number of bootstrap
replications to use. Defaults to 399.
an integer used to seed R's random number generator. This is to ensure replicability. Defaults to 42.
npsdeptest returns an object of type deptest with the
following components
the statistic vector Srho
the cumulant statistic vector Srho.cumulant
contains the bootstrap replications of
Srho
contains the bootstrap
replications of Srho.cumulant
the P-value vector of the Srho statistic vector
the P-value vector of the cumulant Srho statistic vector
a logical value indicating whether bootstrapping was performed
number of bootstrap replications
the number of lags
the numeric vector of bandwidths for data
marginal density at lag num.lag
the numeric vector of bandwidths for lagged
data marginal density at lag num.lag
the numeric matrix of bandwidths for data
and lagged data joint density at lag num.lag
summary supports object of type deptest.
Granger, C.W. and E. Maasoumi and J.S. Racine (2004), “A dependence metric for possibly nonlinear processes”, Journal of Time Series Analysis, 25, 649-669.
npsdeptest computes the nonparametric metric entropy
(normalized Hellinger of Granger, Maasoumi and Racine (2004)) for
testing for nonlinear serial dependence, \(D[f(y_t, \hat y_{t-k}),
f(y_t)\times f(\hat y_{t-k})]\). Default bandwidths are of the Kullback-Leibler
variety obtained via likelihood cross-validation.
The test may be applied to a raw data series or to residuals of user estimated models.
The summation version of this statistic may be numerically unstable
when data is sparse (the summation version involves division of
densities while the integration version involves differences). Warning
messages are produced should this occur (‘integration recommended’)
and should be heeded.
The integration version of the statistic uses multidimensional
numerical methods from the cubature package. See
adaptIntegrate for details. The integration
version of the statistic will be substantially slower than the
summation version, however, it will likely be both more
accurate and powerful.
if (FALSE) { # \dontrun{
set.seed(1234)
## A function to create a time series
ar.series <- function(phi,epsilon) {
n <- length(epsilon)
series <- numeric(n)
series[1] <- epsilon[1]/(1-phi)
for(i in 2:n) {
series[i] <- phi*series[i-1] + epsilon[i]
}
return(series)
}
n <- 100
## Stationary persistent time-series
yt <- ar.series(0.95,rnorm(n))
npsdeptest(yt,lag.num=2,boot.num=99,method="summation")
Sys.sleep(5)
## Stationary independent time-series
yt <- ar.series(0.0,rnorm(n))
npsdeptest(yt,lag.num=2,boot.num=99,method="summation")
## Stationary persistent time-series
yt <- ar.series(0.95,rnorm(n))
npsdeptest(yt,lag.num=2,boot.num=99,method="integration")
Sys.sleep(5)
## Stationary independent time-series
yt <- ar.series(0.0,rnorm(n))
npsdeptest(yt,lag.num=2,boot.num=99,method="integration")
} # }