Title: | Function Estimation via Unbalanced Haar Wavelets |
---|---|
Description: | Top-down and bottom-up algorithms for nonparametric function estimation in Gaussian noise using Unbalanced Haar wavelets. |
Authors: | Piotr Fryzlewicz |
Maintainer: | Piotr Fryzlewicz <[email protected]> |
License: | GPL-2 |
Version: | 2.1 |
Built: | 2024-12-18 06:47:53 UTC |
Source: | CRAN |
The package implements top-down and bottom-up algorithms for nonparametric function estimation in Gaussian noise using Unbalanced Haar wavelets.
Package: | unbalhaar |
Type: | Package |
Version: | 2.0 |
Date: | 2010-08-09 |
License: | GPL-2 |
LazyLoad: | yes |
The main functions of the package are uh
and uh.bu
.
Piotr Fryzlewicz
Maintainer: Piotr Fryzlewicz <[email protected]>
P. Fryzlewicz (2007) “Unbalanced Haar technique for nonparametric function estimation”. Journal of the American Statistical Association, 102, 1318-1327.
x <- c(rep(0, 100), rep(1, 200)) + rnorm(300) est.topdown <- uh(x) est.bottomup <- uh.bu(x)
x <- c(rep(0, 100), rep(1, 200)) + rnorm(300) est.topdown <- uh(x) est.bottomup <- uh.bu(x)
The function finds the “best” top-down Unbalanced Haar (UH) decomposition of the input vector
x
, according to a selection rule (criterion
) which specifies which
UH vector gets chosen at each scale and location.
best.unbal.haar(x, criterion = inner.prod.max)
best.unbal.haar(x, criterion = inner.prod.max)
x |
a vector |
criterion |
a function which takes a vector of length n and returns an integer between 1 and n-1 |
tree |
A list of J matrices, where J represents the number of “scales”. Each matrix is of size 5 x (the number of UH coefficients at a given scale). Each column (= vector of length 5) contains an Unbalanced Haar coefficient in the following format: 1st component - an index of the coefficient; 2nd component - the value of the coefficient; 3rd component - time point where the corresponding UH vector starts; 4th component - last time point before the breakpoint of the UH vector; 5th component - end point of the UH vector. |
smooth |
the “smooth” component of |
Piotr Fryzlewicz
inner.prod.max
, inner.prod.max.p
, best.unbal.haar.bu
best.unbal.haar(rnorm(100), inner.prod.max.p)
best.unbal.haar(rnorm(100), inner.prod.max.p)
The function finds the “best” bottom-up Unbalanced Haar (UH) decomposition of the input vector
x
.
best.unbal.haar.bu(x, stretch = length(x))
best.unbal.haar.bu(x, stretch = length(x))
x |
a vector |
stretch |
at each iteration, only the first |
detail |
A matrix of size 3 x |
smooth |
the “smooth” component of |
Piotr Fryzlewicz
best.unbal.haar.bu(rnorm(100))
best.unbal.haar.bu(rnorm(100))
Presented with an object returned by best.unbal.haar
, the function
sets to zero those Unbalanced Haar coefficients which fall below a certain threshold
sigma
.
hard.thresh(buh, sigma = 1)
hard.thresh(buh, sigma = 1)
buh |
an object returned by |
sigma |
the threshold (a positive scalar) |
a thresholded object, of the same class as buh
Piotr Fryzlewicz
best.unbal.haar
, hard.thresh.bu
x <- rnorm(1000) x.uh <- best.unbal.haar(x) x.uh.th <- hard.thresh(x.uh) x.uh.th.r <- reconstr(x.uh.th) ts.plot(x.uh.th.r)
x <- rnorm(1000) x.uh <- best.unbal.haar(x) x.uh.th <- hard.thresh(x.uh) x.uh.th.r <- reconstr(x.uh.th) ts.plot(x.uh.th.r)
Presented with an object returned by best.unbal.haar.bu
, the function
sets to zero those Unbalanced Haar coefficients which fall below a certain threshold
sigma
.
hard.thresh.bu(buh.bu, sigma = 1)
hard.thresh.bu(buh.bu, sigma = 1)
buh.bu |
an object returned by |
sigma |
the threshold (a positive scalar) |
a thresholded object, of the same class as buh.bu
Piotr Fryzlewicz
best.unbal.haar.bu
, hard.thresh
x <- rnorm(1000) x.uh <- best.unbal.haar.bu(x) x.uh.th <- hard.thresh.bu(x.uh) x.uh.th.r <- reconstr.bu(x.uh.th) ts.plot(x.uh.th.r)
x <- rnorm(1000) x.uh <- best.unbal.haar.bu(x) x.uh.th <- hard.thresh.bu(x.uh) x.uh.th.r <- reconstr.bu(x.uh.th) ts.plot(x.uh.th.r)
For an input vector of length n, the function computes inner products between the input vector and all possible n-1 Unbalanced Haar vectors of length n.
inner.prod.iter(x)
inner.prod.iter(x)
x |
a vector of length n |
The computation is iterative and is performed in computational time O(n).
a vector of length n-1, containing inner products between x
and consecutive Unbalanced Haar wavelets
of length n
Piotr Fryzlewicz
inner.prod.iter(rnorm(100))
inner.prod.iter(rnorm(100))
The function finds the Unbalanced Haar vector which yields the largest (in absolute value) inner product with the input vector.
inner.prod.max(x)
inner.prod.max(x)
x |
a vector |
The index where abs(inner.prod.iter(x))
is maximised. If two or more maxima are found, the med
of their locations is returned.
Piotr Fryzlewicz
inner.prod.iter
, med
, inner.prod.max.p
inner.prod.max(c(rep(0, 100), rep(1, 200)))
inner.prod.max(c(rep(0, 100), rep(1, 200)))
The function finds the Unbalanced Haar vector which yields the largest (in absolute value) inner product with the input vector, amongst those Unbalanced Haar vectors whose breakpoint is located between 100(1-p)% and 100p% of their support.
inner.prod.max.p(x, p = 0.8)
inner.prod.max.p(x, p = 0.8)
x |
a vector |
p |
a scalar in (0.5, 1] |
The index where abs(inner.prod.iter(x))
is maximised on the subinterval
(1+floor((1-p)*n)):ceiling(p*n)
, where n
is the length of x
.
If two or more maxima are found, the med
of their locations is returned.
Piotr Fryzlewicz
inner.prod.iter
, med
, inner.prod.max
inner.prod.max.p(c(rep(0, 100), rep(1, 200)), .55)
inner.prod.max.p(c(rep(0, 100), rep(1, 200)), .55)
The function computes the median of a vector. Unlike median
, it is guaranteed to
return a value which is a component of the input vector.
med(x)
med(x)
x |
a vector |
a scalar defined as quantile(x, .5, type=3)[[1]]
Piotr Fryzlewicz
med(1:4) median(1:4)
med(1:4) median(1:4)
Reconstructs a vector from its top-down Unbalanced Haar decomposition stored in an object returned
by best.unbal.haar
or hard.thresh
.
reconstr(buh)
reconstr(buh)
buh |
an object of the type returned by |
the inverse Unbalanced Haar transform of buh
Piotr Fryzlewicz
best.unbal.haar
, hard.thresh
, reconstr.bu
x <- rnorm(1000) x.uh <- best.unbal.haar(x) x.uh.th <- hard.thresh(x.uh) x.uh.th.r <- reconstr(x.uh.th) ts.plot(x.uh.th.r)
x <- rnorm(1000) x.uh <- best.unbal.haar(x) x.uh.th <- hard.thresh(x.uh) x.uh.th.r <- reconstr(x.uh.th) ts.plot(x.uh.th.r)
Reconstructs a vector from its bottom-up Unbalanced Haar decomposition stored in an object returned
by best.unbal.haar.bu
or hard.thresh.bu
.
reconstr.bu(buh.bu)
reconstr.bu(buh.bu)
buh.bu |
an object of the type returned by |
the inverse Unbalanced Haar transform of buh.bu
Piotr Fryzlewicz
best.unbal.haar.bu
, hard.thresh.bu
, reconstr
x <- rnorm(1000) x.uh <- best.unbal.haar.bu(x) x.uh.th <- hard.thresh.bu(x.uh) x.uh.th.r <- reconstr.bu(x.uh.th) ts.plot(x.uh.th.r)
x <- rnorm(1000) x.uh <- best.unbal.haar.bu(x) x.uh.th <- hard.thresh.bu(x.uh) x.uh.th.r <- reconstr.bu(x.uh.th) ts.plot(x.uh.th.r)
Given an input vector of the form “signal + iid Gaussian noise”, the function
estimates the noise level via Median Absolute Deviation, finds the best top-down
Unbalanced Haar decomposition (according to the selection rule criterion
),
thresholds it with the universal threshold, and performs the inverse Unbalanced
Haar transform to yield an estimate of the signal.
uh(x, criterion = inner.prod.max)
uh(x, criterion = inner.prod.max)
x |
a vector of the form “signal + iid Gaussian noise” |
criterion |
a function which takes a vector of length n and returns an integer between 1 and n-1 |
an estimate of the signal
Piotr Fryzlewicz
P. Fryzlewicz (2007) “Unbalanced Haar technique for nonparametric function estimation”. Journal of the American Statistical Association, 102, 1318-1327.
uh.bu
, best.unbal.haar
, inner.prod.max
, inner.prod.max.p
,
hard.thresh
, reconstr
x <- c(rep(0, 100), rep(1, 200)) + rnorm(300) est <- uh(x)
x <- c(rep(0, 100), rep(1, 200)) + rnorm(300) est <- uh(x)
Given an input vector of the form “signal + iid Gaussian noise”, the function estimates the noise level via Median Absolute Deviation, finds the best bottom-up Unbalanced Haar decomposition, thresholds it with the universal threshold, and performs the inverse Unbalanced Haar transform to yield an estimate of the signal.
uh.bu(x, stretch = length(x))
uh.bu(x, stretch = length(x))
x |
a vector of the form “signal + iid Gaussian noise” |
stretch |
at each iteration, only the first |
an estimate of the signal
Piotr Fryzlewicz
P. Fryzlewicz (2007) “Unbalanced Haar technique for nonparametric function estimation”. Journal of the American Statistical Association, 102, 1318-1327.
uh
, best.unbal.haar.bu
, hard.thresh.bu
, reconstr.bu
x <- c(rep(0, 100), rep(1, 200)) + rnorm(300) est <- uh.bu(x)
x <- c(rep(0, 100), rep(1, 200)) + rnorm(300) est <- uh.bu(x)
Computes the non-zero part of an Unbalanced Haar vector with a given start-, break- and end-point.
unbal.haar.vector(a)
unbal.haar.vector(a)
a |
a three-component vector of integers such that |
the non-zero part of the corresponding Unbalanced Haar vector
Piotr Fryzlewicz
unbal.haar.vector(c(1, 1, 2)) unbal.haar.vector(c(2, 5, 12))
unbal.haar.vector(c(1, 1, 2)) unbal.haar.vector(c(2, 5, 12))