thresholding: Noise reduction from the sequence of detail coefficients...

View source: R/thresholding.R

thresholdingR Documentation

Noise reduction from the sequence of detail coefficients returned by the Tail-Greedy Unbalanced Wavelet (TGUW) transformation

Description

This function is used inside trendsegment and performs the thresholding of the detail coefficients returned by the Tail-Greedy Unbalanced Wavelet (TGUW) transformation. The denoising is achieved by a prespecified threshold in a "connected" way in that it prunes the branches if and only if the detail coefficient itself and all of its children coefficients are below some thresholds in its size. Also, the "two together" rule is applied to any paired detail coefficients returned by Type 3 merging (merging two sets of paired smooth coefficients) in the sense that both detail coefficients should be survived if at least one of their size is over threshold. For details, see H. Maeng and P. Fryzlewicz (2023), Detecting linear trend changes in data sequences.

Usage

thresholding(ts.obj, lambda, minsegL, bal = 0, connected = FALSE)

Arguments

ts.obj

A list returned by TGUW.

lambda

The magnitude of the threshold. It has a form of sigma * th.const * sqrt(2 * log(n)) where n is the length of input data x, the default of th.const is 1.3 and the sigma can be estimated by Median Absolute Deviation (MAD) method under the Gaussian assumption for noise.

minsegL

The minimum segment length of estimated signal returned by trendsegment.

bal

The minimum ratio of the length of the shorter region to the length of the entire merging region especially when the merges of Type 2 (merging one initial and a paired smooth coefficient) or of Type 3 (merging two sets of (paired) smooth coefficients) are performed. Only triplets which satisfy this balancedness condition survives in denoising. Point anomalies can be detected only if bal < 1/n and minsegL = 1. The default is set to 0.

connected

If connected=TRUE, the thresholding puts the connected rule above the minsegL, otherwise it makes keeping the minsegL a priority.

Value

ts.obj

The modified ts.obj containing zero detail coefficients in the merging.hist if not survived from thresholding.

Author(s)

Hyeyoung Maeng hyeyoung.maeng@durham.ac.uk, Piotr Fryzlewicz p.fryzlewicz@lse.ac.uk

See Also

trendsegment, TGUW, invTGUW

Examples

x <- c(1:10, rep(5,9))
n <- length(x)
x <- x + rnorm(n)
tguwfit <- TGUW(x)
th.const <- 1.3
lambda <- (stats::mad(diff(diff(x)))/sqrt(6)) * sqrt(2 * log(n)) * th.const
thrfit <- thresholding(ts.obj = tguwfit, lambda = lambda, minsegL = 5, bal = 0, connected = FALSE)
thrfit

trendsegmentR documentation built on Aug. 24, 2023, 5:07 p.m.