Skip to contents

npsymtest implements the consistent metric entropy test of asymmetry as described in Maasoumi and Racine (2009).

Usage

npsymtest(data = NULL,
          method = c("integration","summation"),
          B = 399,
          bw = NULL,
          boot.method = c("iid", "geom"),
          random.seed = 42,
          ...)

Arguments

Data, Bandwidth Inputs And Formula Interface

These arguments identify the data, statistic variant, and any supplied bandwidth.

bw

a numeric (scalar) bandwidth. Defaults to plug-in (see details below).

data

a vector containing the variable.

method

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.

Bootstrap Controls

These arguments control bootstrap execution and reproducibility settings.

boot.method

a character string used to specify the bootstrap method. Can be set as iid or geom (see below for details). Defaults to iid.

B

an integer value specifying the number of bootstrap replications to use. Defaults to 399.

random.seed

an integer used to seed R's random number generator. This is to ensure replicability. Defaults to 42.

Additional Arguments

Further arguments are passed to the bandwidth-selection routines used by the test.

...

additional arguments supplied to specify the bandwidth type, kernel types, and so on. This is used since we specify bw as a numeric scalar and not a bandwidth object, and is of interest if you do not desire the default behaviours. To change the defaults, you may specify any of bwscaling, bwtype, ckertype, ckerorder, ukertype, okertype.

Bootstrap P-Values

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 reported zero is possible with a finite number of replications.

Value

npsymtest returns an object of type symtest with the following components

Srho

the statistic Srho

Srho.bootstrap

contains the bootstrap replications of Srho

P

the P-value of the statistic

boot.num

number of bootstrap replications

data.rotate

the rotated data series

bw

the numeric (scalar) bandwidth

summary supports object of type symtest.

Book And Method Pointers

npsymtest tests symmetry by comparing the density or probability function of the observed data with that of the data reflected around the relevant center. The same entropy-distance logic used by the univariate density tests underlies the statistic.

For book-length background, see Racine (2019), Chapter 2 Continuous Density and Cumulative Distribution Functions and Li and Racine (2007), Chapter 13 Nonsmoothing Tests and Chapter 12 Model Specification Tests where related density-feature tests are treated.

References

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 (2009), “A robust entropy-based test of asymmetry for discrete and continuous processes,” Econometric Reviews, 28, 246-261.

Politis, D.N. and J.P. Romano (1994), “The stationary bootstrap,” Journal of the American Statistical Association, 89, 1303-1313.

Author

Tristen Hayfield tristen.hayfield@gmail.com, Jeffrey S. Racine racinej@mcmaster.ca

Details

Documentation guide: see np.kernels for kernels, np.options for global options, and plot for plotting options.

npsymtest computes the nonparametric metric entropy (normalized Hellinger of Granger, Maasoumi and Racine (2004)) for testing symmetry using the densities/probabilities of the data and the rotated data, \(D[f(y), f(\tilde y)]\). See Maasoumi and Racine (2009) for details. Default bandwidths are of the plug-in variety (bw.SJ for continuous variables and direct plug-in for discrete variables).

Missing observations are omitted before computing the statistic. For categorical data, declared levels, including unused levels, are retained in the pooled null sample and every bootstrap draw. The discrete entropy sum uses the full declared domain and the plug-in selector uses its category count. Kernel normalization and the existing reflection rule are unchanged; this does not define a new reflection for arbitrary nominal labels. If an observed or bootstrap reflection produces a category outside the declared domain, the call stops rather than discarding that observation. Numeric factor levels must therefore accommodate the existing reflection rule. No p-value is returned from incomplete bootstrap statistics.

For bootstrapping the null distribution of the statistic, iid conducts simple random resampling, while geom conducts Politis and Romano's (1994) stationary bootstrap using automatic block length selection via the b.star function in the np package. See the boot package for details.

The summation version of this statistic may be numerically unstable when y 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.

For numeric data using the fixed second-order Gaussian density estimator, the integration statistic uses deterministic corrected composite trapezoidal quadrature with four evaluation points per bandwidth and a domain extending eight bandwidths beyond the observed support. The density of each reflected bootstrap sample is obtained by reversing the density values on a grid symmetric about that sample's mean; the same reflection identity also avoids fitting a second density on the summation route. For summation, the selected iid or stationary bootstrap plan is generated once with the boot sampling law, converted to bounded chunks of multiplicities, and evaluated by a registered native routine without a sample-by-sample kernel matrix.

The accelerated route is also used when ... contains only bwtype="fixed", ckertype="gaussian", and ckerorder=2. Other density options retain the general kernel-specific route. Generalized and adaptive nearest-neighbour bandwidths therefore continue to use the ordered, duplicate-preserving bootstrap sample and recompute realized neighbour radii rather than treating multiplicities as fixed-bandwidth weights.

Usage Issues

When using data of type factor it is crucial that the variable not be an alphabetic character string (i.e. the factor must be integer-valued). The rotation is conducted about the median after conversion to type numeric which is then converted back to type factor. Failure to do so will have unpredictable results. See the example below for proper usage.

Examples

if (FALSE) { # \dontrun{
set.seed(1234)

n <- 100

## Asymmetric discrete probability distribution function

x <- factor(rbinom(n,2,.8))
npsymtest(x,B=99)

if (interactive()) Sys.sleep(5)

## Symmetric discrete probability distribution function

x <- factor(rbinom(n,2,.5))
npsymtest(x,B=99)

if (interactive()) Sys.sleep(5)

## Asymmetric continuous distribution function

y <- rchisq(n,df=2)
npsymtest(y,B=99)

if (interactive()) Sys.sleep(5)

## Symmetric continuous distribution function

y <- rnorm(n)
npsymtest(y,B=99)

## Time-series bootstrap

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)
}

## Asymmetric time-series

yt <- ar.series(0.5,rchisq(n,df=3))
npsymtest(yt,B=99,boot.method="geom")

## Symmetric time-series

yt <- ar.series(0.5,rnorm(n))
npsymtest(yt,B=99,boot.method="geom")

} # }