local_thresh: Decompose a detrended timeseries into _noise_ and _signal_.

View source: R/Local_Thresh.R

local_threshR Documentation

Decompose a detrended timeseries into noise and signal.

Description

This is based on Phil Higuera's CharThreshLocal.m Matlab code. The script determines threshold values to decompose a detrended timeseries into a noise and a signal component using a 2-component Gaussian Mixture Model (GMM). It determines a positive and a negative threshold value for each interpolated sample, based on the distribution of values within the selected window (thresh.yr). The procedure uses a Gaussian mixture model on the assumption that the noise component is normally distributed around 0 (the values were detrended!).

Usage

local_thresh(
  series = NA,
  proxy = NULL,
  t.lim = NULL,
  thresh.yr = NULL,
  thresh.value = 0.95,
  smoothing.yr = NULL,
  keep_consecutive = FALSE,
  minCountP = 0.05,
  MinCountP_window = 150,
  out.dir = NULL,
  plot.local_thresh = FALSE
)

Arguments

series

Output from the SeriesDetrend() function.

proxy

Set proxy = "VariableName" to select the variable for the peak-detection analysis. If the dataset includes only one variable, proxy does not need to be specified.

t.lim

Allows defining a portion of the time series. With t.lim = NULL (by default), the analysis will be performed using the entire timeseries.

thresh.yr

Length of the window width (in years) from which values are selected to determine the local threshold. By default, this value is inherited from the smoothing.yr value set in the SeriesDetrend() function.

thresh.value

Determines the threshold as the nth-percentile of the Gaussian Model of the noise component. Default to thresh.value = 0.95.

smoothing.yr

Width of moving window for computing SNI.

keep_consecutive

Logical. If FALSE (by default), consecutive peak samples exceeding the threshold are removed and only the first (older) sample is retained.

minCountP

Probability that two resampled counts could arise from the same Poisson distribution (default to 0.05). This is used to screen peak samples and remove any that fail to pass the minimum-count test. If MinCountP = NULL, the test will not be performed.

MinCountP_window

Width (in years) of the search window used for the minimum-count test. Default to MinCountP_window = 150.

out.dir

Path to the folder where figures are written to. If out.dir = NULL (by default), the plots are emitted to the default device.

plot.local_thresh

Logical. If TRUE, *.pdf files are produced and written in the out.dir folder. Defaults to FALSE.

Details

Requires an output from the SeriesDetrend() function.

Author(s)

Walter Finsinger

Examples

co <- tapas::co_char_data
tapas::plot_raw(co)
co_i <- tapas::pretreatment_data(co)
co_detr <- tapas::SeriesDetrend(co_i, smoothing.yr = 1000)
co_loc <- tapas::local_thresh(co_detr, proxy = "charAR",
                                plot.local_thresh = TRUE)


wfinsinger/tapas documentation built on Aug. 22, 2024, 4:28 a.m.