A R Software for Wavelets and Statistics
Total Page:16
File Type:pdf, Size:1020Kb
A R Software for Wavelets and Statistics Here is a list and a brief description of some important R packages related to/that make use of wavelets. Such packages are important as they enable ideas to be reproduced, checked, and modified by the scientific community. This is probably just as important as the advertisement of the ideas through scientific papers and books. This is the ‘reproducible research’ view expressed by Buckheit and Donoho (1995). Making software packages freely available is an extremely valuable service to the community and so we choose to acclaim the author(s) of each package by displaying their names! The descriptions are extracted from each package description from CRAN. The dates refer to the latest updates on CRAN, not the original publication date. Please let me know of any omissions. adlift performs adaptive lifting (generalized wavelet transform) for irregu- larly spaced data, see Nunes et al. (2006). Written by Matt Nunes and Marina Knight, University of Bristol, UK, 2006. brainwaver computes a set of scale-dependent correlation matrices between sets of preprocessed functional magnetic resonance imaging data and then performs a ‘small-world’ analysis of these matrices, see Achard et al. (2006). Written by Sophie Achard, Brain Mapping Unit, University of Cambridge, UK, 2007. CVThresh carries out level-dependent cross-validation for threshold selection in wavelet shrinkage, see Kim and Oh (2006). Written by Donghoh Kim, Hongik University and Hee-Seok Oh, Seoul National University, Korea, 2006. DDHFm implements the data-driven Haar–Fisz transform as described in 6.5, see references therein. Written by Efthimios Motakis, Piotr Fryzlewicz and Guy Nason, University of Bristol, Bristol, UK. EbayesThresh carries out Empirical Bayes thresholding as described in section 3.10.4, see papers listed there. Written by Bernard Silverman, Oxford University, UK, 2005. 230 A R Software for Wavelets and Statistics nlt non-decimated lifting transform (generalized wavelet transform) for ir- regularly spaced data, see Knight and Nason (2008). Written by Marina Knight, University of Bristol, UK, 2008. rwt The Rice Wavelet Toolbox wrapper. The Rice Wavelet Toolbox is a collection of Matlab files for 1D and 2D wavelet and filter bank design, analysis, and processing. Written by P. Roebuck, Rice University, Texas, USA, 2005. SpherWave carries out the wavelet transform of functions on the sphere and related function estimation techniques. See Li (1999), Oh (1999), Oh and Li (2004). Written by Hee-Seok Oh, Seoul National University and Donghoh Kim, Hongik University, Korea, 2007. unbalhaar computes the unbalanced Haar transform and related function estimation, see Fryzlewicz (2007). Written by Piotr Fryzlewicz, Bristol University, UK, 2006. waved wavelet deconvolution of noisy signals, see Section 4.9, Raimondo and Stewart (2007). Written by Marc Raimondo and Michael Stewart, University of Sydney, Australia, 2007. wavelets computes and plots discrete wavelet transform and maximal over- lap discrete wavelet transforms. Written by Eric Aldrich, Duke University, North Carolina, USA, 2007. waveslim computes 1D, 2D, and 3D wavelet transforms, packet transforms, maximal overlap transforms, dual-tree complex wavelet transforms, and much more! Based on methodology described in Percival and Walden (2000) and Gencay et al. (2001). Written by Brandon Whitcher, dude, Translational Medicine and Genetics, GlaxoSmithKline, Cambridge, UK, 2007. wmtsa software to accompany the book Percival and Walden (2000). Written by William Constantine, Insightful Corporation, and Donald Percival, Applied Physics Laboratory, University of Washington, Seattle, USA, 2007. B Notation and Some Mathematical Concepts This appendix gives some extra information, notation, and definitions on the more mathematical aspects underlying the concepts of this book. More details can be found in a number of elementary mathematical texts. In the wavelet context the book, Daubechies (1992) is precise and concise and Burrus et al. (1997) is a very readable introduction. B.1 Notation and Concepts B.1.1 Function spaces In mathematical terms the book deals mostly with measurable functions f on R such that ∞ |f(x)|2 dx < ∞. (B.1) −∞ The space of functions satisfying (B.1) is denoted L2(R). In engineering terms this means that the function, interpreted as a signal, has finite energy. We let C the space of continuous functions (on R), Ck the space of all continuous functions with continuous derivatives of orders up to, and including, k,andC∞ the space of all continuous functions with continuous derivatives of all orders. B.1.2 Support of a function The support of a function, f (denoted supp f), is the complement of the largest open set E with the property that x ∈ E =⇒ f(x) = 0. It is the ‘maximal set on which f is non-zero and inclusive’. The function f is compactly supported if supp f is a compact set (closed and bounded). 232 B Notation and Some Mathematical Concepts B.1.3 Inner product, norms, and distance Given two functions f,g ∈ L2(R) we can define the inner product of these by <f,g>= f(x)g(x) dx, (B.2) R where g(x) denotes the complex conjugate of g(x). The inner product can be 2 used to gauge the ‘size’ of a function by defining the L norm ||·||2 as follows: || ||2 f 2 =<f,f>, (B.3) which leads naturally to the notion of the ‘distance’ between two functions 2 f,g ∈ L (R)as||f − g||2. B.1.4 Orthogonality and orthonormality Two functions f,g ∈ L2(R) are said to be orthogonal if and only if <f,g>=0. Define the Kronecker delta by 1ifi = j δ = (B.4) ij 0ifi = j, for integers i, j. A set of functions {φ1,...,φn} for some n =1, 2,...forms an orthonormal set if and only if <φi,φj >= δij . (B.5) B.1.5 Vector space sums Let V,W be subspaces of L2(R). We define the following spaces. The vector space sum of V and W is defined as V + W = {f + g : f ∈ V,g ∈ W }. (B.6) The subspaces V and W are said to be orthogonal and denoted V ⊥ W if every function V is orthogonal to every function in W (i.e. V ⊥ W if and only if <f,g>= 0 for all f ∈ V,g ∈ W ). We further define V ⊕ W = {f + g : f ∈ V,g ∈ W, V ⊥ W }. (B.7) B.1.6 Fourier transform The Fourier transform of a function f ∈ L2 is given by ∞ fˆ(ω)=(2π)−1/2 f(x)exp(−iωx) dx. (B.8) −∞ The inverse Fourier transform of fˆ(ω) is given by ∞ f(x)=(2π)−1/2 fˆ(ω)exp(iωx) dω. (B.9) −∞ B.1 Notation and Concepts 233 B.1.7 Fourier series Statisticians are probably most familiar with Fourier series that occur rou- tinely in time series analysis. Given a stationary time series {Xt} with auto- covariance function γ(τ) for integers τ, the spectral density function, f(ω), can be written as ∞ f(ω)=(2π)−1 γ(τ)exp(−iωτ), (B.10) τ=−∞ where ω ∈ (−π, π]. The inverse Fourier relationship is π γ(τ)= f(ω)exp(iωτ) dω, (B.11) −π for integer τ. There are many other slightly different formulations of this. For example, Formulae (2.50) and (2.84) are both forms of (B.10) but with different scale factors. B.1.8 Besov spaces In this book much of what we do applies to functions that belong to more interesting function spaces. The natural home for wavelets are Besov spaces; an informal discussion appears in Section 3.10.3. The Besov sequence space norm for a function f(x) is defined in terms of its wavelet coefficients {dj,k} and coarsest-scale coefficient c0,0 by ⎧ ⎛ ⎞ ⎫ ⎪ q/p⎪1/q ⎨∞ 2j −1 ⎬ jsq ⎝ p⎠ ||d||bs = |c0,0| + 2 |dj,k| , (B.12) p,q ⎩⎪ ⎭⎪ j=0 k=0 if 1 ≤ q<∞ and ⎧ ⎛ ⎞ ⎫ ⎪ 1/p⎪ ⎨ 2j −1 ⎬ js ⎝ p⎠ || || s | | | | d bp,∞ = c0,0 +sup 2 dj,k , (B.13) j≥0 ⎩⎪ ⎭⎪ k=0 1 − where s = s + 2 1/p, see Abramovich et al. (1998). The sequence space || || s norm is equivalent to a Besov function space norm on f, denoted f Bp,q . Hence, one can test membership of a Besov space for a function by examining its wavelet coefficients (for a wavelet with enough smoothness). 234 B Notation and Some Mathematical Concepts B.1.9 Landau notation We use Landau notation to express the computational efficiency of algorithms. Suppose f(x), g(x) are two functions. Then f(x)=O{g(x)} means that there exists x∗ and a constant K>0 such that for x ≥ x∗ we have |f(x)|≤M|g(x)|. For example, we use the notation in the following way. Suppose that we have an algorithm whose (positive) running time is r(n), where the size of the problem is measured by n. Then we can say that the algorithm is O{g(n)} if there exists K>0 such that for large enough n we have r(n) ≤ Kg(n). For example, multiplication of an n × 1 vector by an n × n matrix is O(n2). C Survival Function Code This section contains the code for the remainder of the survival function estimation described in Section 4.8. The function uk computes the Uk values as described in Antoniadis et al. (1999) as follows: uk <- function(z, nbins=32){ anshfc <- hfc(z, nbins=nbins) uk <- anshfc$bincounts/anshfc$del ans <- list(uk=uk, bins=anshfc$bins, del=anshfc$del) ans } The uk function is essentially a ∆-weighted version of hfc.Thesubf function below computes the subdensity estimator of f ∗(t) as follows: subf <- function(z, nbins=32, filter.number=2, lev=1){ tmp <- uk(z, nbins=nbins) zuk <- tmp$uk yywd <- wd(zuk, filter.number=filter.number, bc="interval") levs <- nlevels(yywd) - (1:lev) yywdT <- nullevels(yywd, levelstonull=levs) fhat <- wr(yywdT) fhat[fhat < 0] <- 0 236 C Survival Function Code l <- list(fhat = fhat, bins=tmp$bins, del=tmp$del) l } This function is very similar to the hws linear wavelet smooth in the main text with the addition that negative density values are prohibited and set to zero.