| npdeptest | R Documentation |
npdeptest implements the consistent metric entropy test of
pairwise independence as described in Maasoumi and Racine (2002).
npdeptest(data.x = NULL,
data.y = NULL,
method = c("integration","summation"),
bootstrap = TRUE,
B = 399,
random.seed = 42)
These arguments identify the paired samples being tested.
data.x, data.y |
two univariate vectors containing two variables that are of type
|
method |
a character string used to specify whether to compute the integral
version or the summation version of the statistic. Can be set as
|
These arguments control bootstrap execution and reproducibility settings.
B |
an integer value specifying the number of bootstrap
replications to use. Defaults to |
bootstrap |
a logical value which specifies whether to conduct
the bootstrap test or not. If set to |
random.seed |
Temporary caller-state restoration requires a certifiable initialized state; see np_rng_scope. an integer used to seed R's random number generator. This is to ensure replicability. Defaults to 42. |
Documentation guide: see np.kernels for kernels, np.options for global options, and plot for plotting options.
npsdeptest computes the nonparametric metric entropy
(normalized Hellinger of Granger, Maasoumi and Racine (2004)) for
testing pairwise nonlinear dependence between the densities of two
data series. See Maasoumi and Racine (2002) for details. Default
bandwidths are of the Kullback-Leibler variety obtained via
likelihood cross-validation. The null distribution is obtained via
bootstrap resampling under the null of pairwise independence.
npdeptest computes the distance between the joint distribution
and the product of marginals (i.e. the joint distribution under the
null), D[f(y, \hat y), f(y)\times f(\hat y)]. Examples include, (a) a measure/test of “fit”,
for in-sample values of a variable y and its fitted values,
\hat y, and (b) a measure of “predictability” for
a variable y and its predicted values \hat y (from
a user implemented model).
The summation version of this statistic will be numerically unstable
when data.x and data.y lack common support or are 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 result includes total.time, the elapsed wall-clock time in
seconds for the test call, displayed by summary.
npdeptest returns an object of type deptest with the
following components
Srho |
the statistic |
Srho.bootstrap.vec |
contains the bootstrap replications of
|
P |
the P-value of the Srho statistic |
bootstrap |
a logical value indicating whether bootstrapping was performed |
boot.num |
number of bootstrap replications |
bw.data.x |
the numeric bandwidth for |
bw.data.y |
the numeric bandwidth for
|
bw.joint |
the numeric matrix of bandwidths for |
summary supports object of type deptest.
The bootstrap upper-tail p-value is the proportion of bootstrap statistics greater than or equal to the observed statistic. Ties count as at least as extreme, giving the conservative tie convention for discrete statistics. This is the ordinary bootstrap proportion, without an add-one correction; a zero is displayed as ‘0 (0 of B)’, with the actual number of draws.
npdeptest compares the joint density or probability law of two
variables with the product of their marginals. Departures from the
product form indicate dependence, lack of fit, or predictability
depending on how the two inputs are constructed.
For book-length background, see Li and Racine (2007), Chapter 13 Nonsmoothing Tests, especially Sections 13.4 and 13.5, and Chapter 12 Model Specification Tests, especially Sections 12.4.1 and 12.4.3. For entropy and density context, see Racine (2019), Chapter 2.
The integration version uses deterministic tensor-product,
corrected composite trapezoidal quadrature. Along each axis the domain
extends eight relevant bandwidths beyond the observed support and uses
two evaluation points per smallest relevant bandwidth. A registered
native callback evaluates the Gaussian marginal and joint densities in
bounded tiles, so package-owned working memory does not grow as a dense
sample-by-quadrature array. The integration version is generally more
computationally demanding than summation, but avoids the density
division that can make the summation statistic unstable.
The summation version fuses both marginal density sums and the
joint density sum in one registered native pass with constant auxiliary
storage. During bootstrapping, bounded groups of sampled data.x
indices share the invariant data.y marginal work while retaining
every draw's positionwise pairing, reduction order, and output order.
Workspace grows only with the sample size times the bounded group size;
no dense sample-by-sample kernel matrix is retained. Counts alone are not
used because they would discard the required pairing with data.y.
Tristen Hayfield tristen.hayfield@gmail.com, Jeffrey S. Racine racinej@mcmaster.ca
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.
Maasoumi, E. and J.S. Racine (2002), “Entropy and Predictability of Stock Market Returns,” Journal of Econometrics, 107, 2, pp 291-312.
np.kernels, np.options, plot
npdeneqtest,npsdeptest,npsymtest,npunitest
## Not run:
set.seed(1234)
## Test/measure lack of fit between y and its fitted value from a
## regression model when x is relevant using the `summation' version.
n <- 100
x <- rnorm(n)
y <- 1 + x + rnorm(n)
model <- lm(y~x)
y.fit <- fitted(model)
npdeptest(y,y.fit,method="summation")
if (interactive()) Sys.sleep(5)
## Test/measure lack of fit between y and its fitted value from a
## regression model when x is irrelevant using the `summation' version.
n <- 100
x <- runif(n,-2,2)
y <- 1 + rnorm(n)
model <- lm(y~x)
y.fit <- fitted(model)
npdeptest(y,y.fit,method="summation")
## Test/measure lack of fit between y and its fitted value from a
## regression model when x is relevant using the `integration'
## version (default, slower than summation version).
n <- 100
x <- rnorm(n)
y <- 1 + x + rnorm(n)
model <- lm(y~x)
y.fit <- fitted(model)
npdeptest(y,y.fit)
if (interactive()) Sys.sleep(5)
## Test/measure lack of fit between y and its fitted value from a
## regression model when x is irrelevant using the `integration'
## version (default, slower than summation version).
n <- 100
x <- runif(n,-2,2)
y <- 1 + rnorm(n)
model <- lm(y~x)
y.fit <- fitted(model)
npdeptest(y,y.fit)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.