global_thresh: Determine threshold values to extract signal from a detrended...

View source: R/Global_Thresh.R

global_threshR Documentation

Determine threshold values to extract signal from a detrended timeseries.

Description

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). This is based on Phil Higuera's CharThreshLocal.m Matlab code. It determines a positive and a negative threshold value for each interpolated sample, based on the distribution of values within the entire record. The procedure uses a Gaussian mixture model with the assumption that the noise component is normally distributed around 0 (because input values were detrended!). A figure is generated and saved to the output directory and a list is returned with the threshold data for the analyzed proxy.

Usage

global_thresh(
  series = NA,
  proxy = NULL,
  t.lim = NULL,
  thresh.value = 0.95,
  noise.gmm = 1,
  smoothing.yr = NULL,
  keep_consecutive = F,
  minCountP = 0.05,
  MinCountP_window = 150,
  out.dir = NULL,
  plot.global_thresh = T
)

Arguments

series

The output of 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

Restricted portion of the timeseries. With t.lim = NULL (by default), the analysis is performed with the entire timeseries.

thresh.value

Threshold: the nth-percentile of the Gaussian Model of the noise component. Defaults to thresh.value = 0.95.

noise.gmm

Specifies which of the two GMM components should be considered as the noise component. By default noise.gmm = 1.

smoothing.yr

Width of the moving window for computing SNI. By default, this value is inherited from the smoothing.yr value set in the SeriesDetrend() function.

keep_consecutive

Logical. When FALSE (by default), consecutive peak samples exceeding the threshold will be removed, and only the first sample (the oldest) is retained.

minCountP

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

MinCountP_window

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

out.dir

Path to the folder where figures will be written to. Use out.dir = NULL to plot to current device instead.

plot.global_thresh

Logical. If TRUE, then *.pdf files are produced and written to out.dir folder.

Details

Requires output from the SeriesDetrend() function.

Value

A list similar to series with additional data appended.

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_glob <- tapas::global_thresh(co_detr, proxy = "charAR")


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