Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/ext_functional.R
This function performs the Discrete Wavelet Transform (DWT) on a numeric vector representing a curve (i.e. a "functional" datum) observed on a grid and thresholds the wavelet coefficients, thus yielding a denoised and compressed representation of the same curve.
1 2 |
x |
a numeric vector of x coordinates at which the curve is observed. |
y |
a numeric vector of y coordinates representing the curve. |
irreg.grid |
logical. TRUE if |
grid.length |
a positive power of 2 or NULL (default). In order to apply the DWT, |
filter.number |
an integer specifying the smoothness of the wavelet used in the wavelet decomposition of |
family |
a character string specifying the family of wavelets used in the wavelet decomposition of |
bc |
a character string specifying how to handle the boundary condition. See the functions |
verbose |
logical. Controls the printing of "informative" messages whilst the computation progresses. Such messages are generally annoying so it is turned off by default. |
... |
further arguments to control the thresholding of the wavelet coefficients. See |
The function normalizes the input grid to the standard unit interval, i.e. the minimum and the maximum values of x.grid
are respectively 0 and 1.
projectCurveWavelet
is designed to be used as a preliminary step towards functional clustering using the mean shift algorithm. Given a sample of curves, projectCurveWavelet
can be used to represent each curve as a sparse vector of coefficients. These coefficients can be fed as a matrix to msClustering
or bmsClustering
and clustered via the mean shift algorithm or the blurring mean shift algorithm.
The function outputs a list with names
coefficients |
a numeric vector of thresholded wavelet coefficients. |
y.wdT |
an object of class |
y.wavelet |
a numeric vector with the reconstruction of |
x.grid |
the extended and equispaced grid of x values associated to |
Mattia Ciollaro and Daren Wang
Nason, G. (2010) Wavelet methods in statistics with R.
wavethresh
wd
irregwd
threshold.wd
threshold.irregwd
wr
msClustering
bmsClustering
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 | ## generate a noisy curve observed on a regular grid
set.seed( 1 )
n.grid <- 1000
x <- seq( 2, 8, length=n.grid )
sigma.epsilon1 <- 2
sigma.epsilon2 <- 2.5
sigma.epsilon3 <- 3
sigma.epsilon4 <- 1
epsilon <- rnorm( 1000, sd=rep( c( sigma.epsilon1,
sigma.epsilon2, sigma.epsilon3, sigma.epsilon4 ),
rep( 250, 4 ) ) )
y <- x*sin( 3*x ) + 0.3*x^2 + epsilon
## project on wavelet basis with soft universal thresholding
## of the wavelet coefficients
wave <- projectCurveWavelets( x, y, type="soft", policy="universal" )
## plot wavelet reconstruction of the curve
## Not run:
x.norm <- ( x - min( x ) ) / ( max( x ) - min( x ) )
plot( x.norm, y )
lines( wave$x.grid, wave$y.wavelet, col=2, lwd=3 )
## End(Not run)
## inspect wavelet coefficients
wave.coeffs <- wave$coefficients
print( length( wave.coeffs ) ) ## 1023 coefficients
print( sum( wave.coeffs != 0 ) ) ## only 12 are non-zero
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.