# hwwn.test: Perform a test for white noise on a time series. In hwwntest: Tests of White Noise using Wavelets

## Description

Often one wishes to know whether a time series is consistent with a white noise model. This function tests whether the underlying spectrum of the time series is flat, which is identical to saying that all the autocorrelations of the series are zero (apart from the lag zero autocorrelation which is always one). This test is exact for Gaussian data but will also work well with heavy-tailed distributions whose periodogram tends to the exponential distribution asymptotically (see accompanying paper for details).

## Usage

 ```1 2``` ```hwwn.test(x, lowlev = 0, plot.it = FALSE, stopeveryscale = FALSE, n.cdf.grid = 1000, mc.method = p.adjust.methods, mac.spread=10) ```

## Arguments

 `x` The data set you wish to test. For now, the length of this series has to be a power of two. In theory, it could be any length. `lowlev` Specifies the coarsest resolution level of wavelet coefficients computed on the spectrum. Typically, this should be left at one, which is the coarsest that can be achieved an still approximate the CDF `plot.it` If `TRUE` then plots of the wavelet coefficients and their modelled underlying distribution are plotted, and their cumulative distributions and the resultant p-values as a histogram for each scale. Theoretical values are in red and data estimated values in black. `stopeveryscale` If `TRUE` the code stops after every plot if `plot.it==TRUE`. This is a way of ensuring that the human can see every plot to stop it whizzing off the screen. Simply press ENTER to continue. `n.cdf.grid` The CDF of the Macdonald distribution is evaluated numerically. This argument controls the resolution of that grid: it controls the number of grid points there are between `-mac.spread` and `mac.spread`. `mc.method` The method of multiple hypothesis comparison. See `p.adjust` for details. `mac.spread` The range (from `-mac.spread` to `mac.spread`) that the CDF of the Macdonald distribution is computed on.

## Details

The null hypothesis of the test contained in this function is H_0: series is white noise (or constant spectrum) versus H_A: it is not white noise. This test works by assessing whether the spectrum of the underlying series is constant or not. It does this by first computing the periodogram of the sample series. This is a well-studied estimate of the spectrum. Then it evaluates the constancy of the spectrum by examining the Haar wavelet coefficients of the periodogram. Under normality much is known about the asymptotic distribution of the periodogram and this can be transferred, through some moderately complex distribution theory to the distribution of the Haar wavelet coefficients of the periodogram. Hence, in this situation, we have a good handle on whether a particular wavelet coefficients is too large or to small as we have near theoretical knowledge of their CDF. Since we are testing many wavelet coefficients simultaneously we have to use multiple hypothesis p-value adjustment techniques, such as Bonferroni to obtain a final p-value.

## Value

An object of class `htest` containing the results of the hypothesis test. Actually a list containing the following components:

 `p.val.collector` All the p-values for all Haar wavelet coefficients of the periodogram. These are the values before p-value adjustment for multiple tests. `p.val.adjust` The p-values after adjustment for multiple tests via `p.adjust`. `p.value` The p-value of the test `method` Character string describing the test.

## Author(s)

Delyan Savchev and Guy Nason

## References

Nason, G.P. and Savchev, D. (2014) White noise testing using wavelets. Stat, 3, 351-362. http://dx.doi.org/10.1002/sta4.69

`compute.rejection`, `Macdonald`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39``` ```# # Invent test data set which IS white noise # x <- rnorm(128) # # Do the test # x.wntest <- hwwn.test(x) # # Print the results # #x.wntest # # Wavelet Test of White Noise # #data: #p-value = 0.9606 # # So p-value indicates that there is no evidence for rejection of # H_0: white noise. # # Let's do an example using data that is not white noise. E.g. AR(1) # x.ar <- arima.sim(n=128, model=list(ar=0.8)) # # Do the test # x.ar.wntest <- hwwn.test(x.ar) # # Print the results # print(x.ar.wntest) # # Wavelet Test of White Noise # #data: #p-value < 2.2e-16 # # p-value is very small. Extremely strong evidence to reject H_0: white noise ```

### Example output

```	Wavelet Test of White Noise

data:
p-value = 1.061e-07
```

hwwntest documentation built on May 2, 2019, 6:39 a.m.