# wavVar: Discrete wavelet variance estimation In wmtsa: Wavelet Methods for Time Series Analysis

## Description

The discrete wavelet variance is a useful alternative to the spectral density function (SDF) and is seen as an octave-band regularization of the SDF. The wavelet variance decomposes the variance of certain stochastic processes on a scale-by-scale basis, and thus, is very appealing to the analyst studying physical phenomena which fluctuate both within and across a wide range of scale.

By definition, the wavelet variance involves an averaged energy summation of MODWT wavelet coefficients. While DWT wavelet coefficients can also be used, the statistical properties are inferior to those of the MODWT wavelet variance. See the references for more details.

The MODWT Wavelet Variance

Let N be the the number of samples in a time series X(t), L be the length of the wavelet filter, L(j)=(2^j-1)(L-1)+1 be the equivalent filter width at level \$j\$ in a MODWT, and tau(j)=2^(j-1) be the scale of the data at level j for j=1,...,J. Then the unbiased wavelet variance is defined as

1/Mj * sum[t=L(j)-1, ..., N-1],

where d(j,t) are the MODWT coefficients at level j and time t, and Mj=N - L(j) + 1. The unbiased wavelet variance estimator avoids so-called boundary coefficients which are those coefficients subject to circular filter operations in a discrete wavelet transform. The biased estimator is defined as

1/N * sum[t=0,...,N-1] (d(j,t))^2,

and includes the effects of the boundary coefficients.

The DWT Wavelet Variance

The DWT can also be used to calculate wavelet variance estimates, but is not preferred over the MODWT due to its poor statistical properties. Let N(j)= floor(N/2^j) be the number of DWT wavelet coefficients at level j, and L'(j)=ceiling((L-2)(1-2^(-j))) be the number of DWT boundary coefficients at level j (assuming N(j) > L'(j)). Then the DWT version of the unbiased wavelet variance is defined as

1/(N-2^j * L'(j)) sum[t=L'(j)-1,...,N(j)-1] (d(j,t))^2,

where d(j,t) are the DWT coefficients at level j and time t. Similarly, the DWT version of the biased wavelet variance is defined as

1/N sum[t=0,...,N(j)-1 (d(j,t))^2].

## Usage

 ```1 2 3 4``` ```wavVar(x, xform="modwt", wavelet="s8", n.levels=NULL, position=list(from=1,by=1,units=character()), units=character(), documentation=character(), sdf=NULL, sdfargs=NULL, sampling.interval=1, n.fft=1024) ```

## Arguments

 `x` a vector containing a uniformly-sampled real-valued time series. `documentation` a character string used to describe the input `data`. Default: `character()`. `n.fft` a positive integer (greater than one) defining the number of frequencies to use in evaluating the SDF. The frequencies are uniformly distributed over the interval [0, Nyquist] ala f=[0, 1/P , 2/P, 3/P, ..., (n.freq-1)/P] where P=2*(n.freq-1)/sampling.interval. Only used when the input SDF is not `NULL`. Default: `1024`. `n.levels` the number of decomposition levels. Default: the maximum level at which there exists at least one interior wavelet coefficient. `position` a `list` containing the arguments `from, by` and `to` which describe the position(s) of the input `data`. All position arguments need not be specified as missing members will be filled in by their default values. Default: `list(from=1, by=1, units=character())`. `sampling.interval` sampling interval of the time series. Default: `1`. `sdf` a spectral density function of the process corresponding to the input time series. This input must be a function whose first argument is `f` (representing frequency). At a minimum, the SDF must be defined over frequencies [0, Nyquist] where `Nyquist=1/(2*sampling.interval)`. Additional arguments that are needed to calculate the SDF should be passed via the `sdfargs` parameter. This argument is used only for calculating mode 2 EDOF. If the EDOF mode 2 estimates are not desired, specify this this argument as `NULL` and the EDOF mode 2 and corresponding confidence intervals will not be calculated. See the `mutilsSDF` function for more details. Default: `NULL`. `sdfargs` a list of arguments passed directly to the SDF function ala `do.call`. Default: `NULL` (no additional arguments). `units` a string denoting the units of the time series. Default: `character()` (no units). `wavelet` a character string denoting the filter type. See `wavDaubechies` for details. Default: `"s8"`. `xform` a character string denoting the type of wavelet transform: "modwt" or "dwt". Default: `"modwt"`.

## Value

an object of class `wavVar`.

## References

D. B. Percival and A. T. Walden, Wavelet Methods for Time Series Analysis, Cambridge University Press, 2000.

`wavVarTest`, `wavEDOF`, `wavVarConfidence`, `mutilsSDF`.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ```## create sequence x <- make.signal("doppler") ## perform a time independent wavelet variance ## analysis vmod <- wavVar(x) ## plot the result plot(vmod, pch=15, title="Wavelet Variance of Doppler") ## calculate wavelet variance estimaates for the ## ocean series and calculate EDOF mode 2 ## estimates and corresponding 95 percent ## confidence intervals vocean <- wavVar(ocean, sdf=oceansdf, wavelet="d6") ## summarize the results plot(vocean, edof=1:3) summary(vocean) ```