When computing the discrete wavelets up to a given scale
we use the inverse wavelet transform to do this. However, to
generate a wavelet within the range of a wavelet decomposition
you have to use more scales in the inverse wavelet transform
than first requested. This is because wavelet coefficients at
the coarsest scales are associated with wavelets whose support
is greater than the whole extent of the series. Hence, you
have to have a larger wavelet transform, with more levels, insert
a coefficient mid-level to generate a discrete wavelet whose
support lies entirely within the extent of the series. This
function figures out what the extra number of levels should be.
References
Nason, G.P. (2013) A test for second-order stationarity and
approximate confidence intervals for localized autocovariances
for locally stationary time series. J. R. Statist. Soc. B,
75, 879-904.
whichlevel(6)
# [1] 11## E.g. mkcoef wanted to generate 6 levels of discrete wavelets and# whichlevel tells it that it needs to generate a wavelet transform# of at least 11 levels.