test_functions: Test Functions

test_functionsR Documentation

Test Functions

Description

Functions for testing low-discrepancy sequences.

Usage

sum_of_squares(u)
sobol_g(u, copula = copula::indepCopula(dim = ncol(u)), alpha = 1:ncol(u), ...)
exceedance(x, q, p = 0.99, method = c("indicator", "individual.given.sum.exceeds",
                                      "sum.given.sum.exceeds"))

Arguments

u

(n, d)-matrix containing n d-dimensional realizations (of a potential quasi-random number generator). For sum_of_squares() these need to be marginally standard uniform and for sobol_g() they need to follow the copula specified by copula.

copula

Copula object for which the inverse Rosenblatt transformation exists.

alpha

vector of parameters of Sobol's g test function.

...

additional arguments passed to the underlying cCopula().

x

(n, d)-matrix containing n d-dimensional realizations.

q
"indicator"

d-vector containing the componentwise thresholds; if a number it is recycled to a d-vector.

"individual.given.sum.exceeds", "sum.given.sum.exceeds"

threshold for the sum (row sums of x).

p

If q is not provided, the probability p is used to determine q.

"indicator"

d-vector containing the probabilities determining componentwise thresholds via empirical quantiles; if a number, it is recycled to a d-vector.

"individual.given.sum.exceeds", "sum.given.sum.exceeds"

probability determining the threshold for the sum (row sums of x) via the corresponding empirical quantile.

method

character string indicating the type of exceedance computed (see Section Value below).

Details

For examples see the demo man_test_functions.

See ES_np(<matrix>) from qrmtools for another test function.

Value

sum_of_squares() returns an n-vector (numeric(n)) with the rowwise computed scaled sum of squares (theoretically integrating to 1).

sobol_g() returns an n-vector (numeric(n)) with the rowwise computed Sobol' g functions.

exceedance()'s return value depends on method:

"indicator"

returns indicators whether, componentwise, x exceeds the threshold determined by q.

"individual.given.sum.exceeds"

returns all rows of x whose sum exceeds the threshold determined by q.

"sum.given.sum.exceeds"

returns the row sums of those rows of x whose sum exceeds the threshold determined by q.

Author(s)

Marius Hofert and Christiane Lemieux

References

Radovic, I., Sobol', I. M. and Tichy, R. F. (1996). Quasi-Monte Carlo methods for numerical integration: Comparison of different low discrepancy sequences. Monte Carlo Methods and Applications 2(1), 1–14.

Faure, H., Lemieux, C. (2009). Generalized Halton Sequences in 2008: A Comparative Study. ACM-TOMACS 19(4), Article 15.

Owen, A. B. (2003). The dimension distribution and quadrature test functions. Stat. Sinica 13, 1-–17.

Sobol', I. M. and Asotsky, D. I. (2003). One more experiment on estimating high-dimensional integrals by quasi-Monte Carlo methods. Math. Comput. Simul. 62, 255–-263.

Examples

## Generate some (here: copula, pseudo-random) data
library(copula)
set.seed(271)
cop <- claytonCopula(iTau(claytonCopula(), tau = 0.5)) # Clayton copula
U <- rCopula(1000, copula = cop)

## Compute sum of squares test function
mean(sum_of_squares(U)) # estimate of E(3(sum_{j=1}^d U_j^2)/d)

## Compute the Sobol' g test function
if(packageVersion("copula") >= "0.999-20")
    mean(sobol_g(U)) # estimate of E(<Sobol's g function>)

## Compute an exceedance probability
X <- qnorm(U)
mean(exceedance(X, q = qnorm(0.99))) # fixed threshold q
mean(exceedance(X, p = 0.99)) # empirically estimated marginal p-quantiles as thresholds

## Compute 99% expected shortfall for the sum
mean(exceedance(X, p = 0.99, method = "sum.given.sum.exceeds"))
## Or use ES_np(X, level = 0.99) from 'qrmtools'

qrng documentation built on May 29, 2024, 2:02 a.m.

Related to test_functions in qrng...