Description Usage Arguments Value References Examples
This function carries out the tree-based thresholding algorithm described in section 3 of Evers and Heaton (2009).
1 2 | treethresh(data, beta, criterion="score", control=list(),
rho=sys.frame(sys.parent()))
|
data |
An array (or an object coercible to an array, i.e. a
vector or matrix) containing the data. The
data is assumed to have noise of unit variance, thus the data needs to
be rescaled a priori (e.g. in the case of wavelet coefficients using function |
beta |
Instead of using the original |
criterion |
The criterion to be used. Can be |
control |
A list that allows the user to tweak the behaviour of
|
rho |
The environment used to evaluate the user-speficied criterion function if one is supplied). (You want to change this argument only in very rare circumstances). |
treethresh
returns an object of the class c("treethresh")
,
which is a list containing the following elements:
splits |
A table describing the detailed structure of the fitted tree together with the local loglikelihoods required for the pruning. |
membership |
An array of the same dimension as |
beta |
The values of beta for each observation / coefficient. |
data |
The data used. |
criterion |
The criterion used to decide on splits (see argument |
control |
The control list of tuning options used (see argument |
Evers, L. and Heaton T. (2009) Locally Adaptive Tree-Based Thresholding, Journal of Computational and Graphical Statistics 18 (4), 961-977. Evers, L. and Heaton T. (2017) Locally Adaptive Tree-Based Thresholding, Journal of Statistical Software, Code Snippets, 78(2), 1-22.
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 29 30 31 32 33 34 35 36 37 38 39 40 | # (1) Create a vector with the probabilities of a signal being present
w.true <- c(rep(0.1,400),rep(0.7,300),rep(0.1,300))
# (2) Generate the signal
mu <- numeric(length(w.true))
non.zero.entry <- runif(length(mu))<w.true
num.non.zero.entries <- sum(non.zero.entry)
mu[non.zero.entry] <- rexp(num.non.zero.entries,rate=0.5)*
sample(c(-1,1),num.non.zero.entries,replace=TRUE)
# (3) Split graphics device
par(mfrow=c(2,2))
# (3) Draw the true signal (signal present in red)
plot(mu,col=non.zero.entry+1)
title("True signal")
# (4) Add noise to the signal
x <- mu + rnorm(length(mu))
# (5) Plot the noisy signal (signal present in red)
plot(x,col=non.zero.entry+1)
title("Noisy signal")
# (6) Carry out the tree-based thresholding
tt <- treethresh(x)
# (7) Prune the tree
tt.pruned <- prune(tt)
# (8) Threshold the signal according to the pruned tree
mu.hat <- thresh(tt.pruned)
# (9) Print the denoised signal
plot(mu.hat,col=non.zero.entry+1)
title("Denoised signal")
# (10) Add solid lines for splits (lines removed by the pruing are dashed)
abline(v=tt$split[,"pos"],lty=2)
abline(v=tt.pruned$split[,"pos"],lty=1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.