Learn R Programming

hwwntest (version 1.3.2)

compute.rejection: Function to compute empirical size or power for various tests of white noise.

Description

Can generate white noise sequences, or ARMA time series and subject multiple realizations of these to various tests for white noise. The function then counts how many have been rejected to give some idea of empirical size (if no ar or ma term is specified) or power (if such terms are specified).

Usage

compute.rejection(ar = NULL, ma = NULL, npow = 100, nom.size = 0.05,
	ndata = 1024, lapplyfn = lapply, Box.lag = 1, rand.gen = rnorm,
	hwwn = TRUE, box = TRUE, bartlett = TRUE, 
	d00test = TRUE, genwwn = TRUE, hywn = TRUE, hywavwn = TRUE,
	filter.number = 10, family = "DaubExPhase",
	away.from = "standard", ...)

Value

A list with eight components. Each component is a number, between zero and one, which corresponds to the empirical size or power of each test. Note, if any component is NULL this means that it was not evaluated and was `turned off' in the command line by setting its name equal to FALSE.

Arguments

ar

Any autoregressive terms to go directly to the arima.sim function. Leave as it is if you wish to simulate white noise.

ma

As ar but for moving average terms.

npow

The number of realizations to carry out. The best assessments are carried out with high values of npow, e.g. 1000 or even 10000.

nom.size

The nominal statistical size of the test. Note: this does not change the nomimal size for ALL tests. You need to check each help pages for each function to check what can be changed.

ndata

The length of the white noise or ARMA realizations. Power for both these tests depends on sample size.

lapplyfn

If you have the library parallel and a suitable multicore machine then this function can run the realizations in parallel. If so, then you can change this argument to lapplyfn=mclapply to take advantage of this.

Box.lag

The Box test tests for white noise by examining autocorrelation coefficients. This argument specifies the max number of autocorrelation coefficients, ie. coefficients from lag 1 up to Box.lag.

rand.gen

Alternative innovation generator. By default Gaussian innovations are used, but you can specify alternatives to get heavy-tailed innovations, for example.

hwwn

If TRUE then the hwwn.test will be evaluated, if FALSE then it won't be.

box

If TRUE then the Box.test will be evaluated, if FALSE then it won't be.

bartlett

If TRUE then the bartlettB.test will be evaluated, if FALSE then it won't be.

d00test

If TRUE then the d00.test will be evaluated, if FALSE then it won't be.

genwwn

If TRUE then the genwwn.test will be evaluated, if FALSE then it won't be.

hywn

If TRUE then the hywn.test will be evaluated, if FALSE then it won't be.

hywavwn

If TRUE then the hywavwn.test will be evaluated, if FALSE then it won't be.

filter.number

The number of vanishing moments of wavelets used in the general wavelet tests (genwwn, hywn and hywavwn).

family

Wavelet family, as for filter.number argument.

away.from

The number of finer scales not to use for the general wavelet tests. These tests work by relying on the asymptotic normality of wavelet coefficients, but this only becomes useful away from the finer scales. This argument can be an integer in which case it defines the number of fine scales to ignore. Alternatively, you can supply the argument "standard" which chooses an automatically selected number of scales to stay away from which works well up to time series in length of 1000. Better performance can be obtained for series longer than 1000 by adapting the away.from argument.

...

Other arguments to hwwn.test.

Author

Delyan Savchev and Guy Nason

Details

This function repeatedly runs the hypothesis tests on realizations from a stochastic process which can be white noise (if ar and ma are NULL) or an ARMA process specified by ar and ma. It then counts how many times the null was rejected and returns this as proportion of the total number of realizations. In this way, this function can compute the empirical size and power of the tests.

References

Nason, G.P. and Savchev, D. (2014) White noise testing using wavelets. Stat, 3, 351-362. tools:::Rd_expr_doi("10.1002/sta4.69")

See Also

bartlettB.test, d00.test, genwwn.test, hwwn.test, hywn.test, hywavwn.test

Examples

Run this code
#
# Compute empirical size of both tests using 1000 realizations
# with data of length 32
#
answer <- compute.rejection(npow=100, ndata=32)
#
# Print the answer
#
print(answer)
#$hwwntest.rejprop
#[1] 0.03
#
#$box.rejprop
#[1] 0.02
#
#$bartlett.rejprop
#[1] 0.01
#
#$d00.pow
#[1] 0.03
#
#$genwwn.pow
#[1] 0.02
#
#$hywn.pow
#[1] 0.01
#
#$hywavwn.pow
#[1] 0.03
#
#
# So, all empirical sizes should be close to their nominal value of 0.05
#
# Now let's try and ascertain the empirical power on an AR(1)
#
answer <- compute.rejection(ar=0.8, npow=100, ndata=32)
#
# Print the answer
#
print(answer)
#$hwwntest.rejprop
#[1] 0.79
#
#$box.rejprop
#[1] 0.98
#
#$bartlett.rejprop
#[1] 0.97
#
#$d00.pow
#[1] 0.97
#
#$genwwn.pow
#[1] 0.94
#
#$hywn.pow
#[1] 0.95
#
#$hywavwn.pow
#[1] 0.85
#
# Most powers are pretty good. 

Run the code above in your browser using DataLab