peak_detection: Performs peak-detection analysis of a time series.

View source: R/peak_detection.R

peak_detectionR Documentation

Performs peak-detection analysis of a time series.

Description

This wrapper function calls the following functions in correct order: check_pretreat(), pretreatment_data(), SeriesDetrend(), global_thresh() or local_thresh(), Plot.Anomalies(), and Plot_ReturnIntervals().

Usage

peak_detection(
  series = NULL,
  out = "accI",
  series_name = NULL,
  check_series = TRUE,
  interp_missing = TRUE,
  proxy = NULL,
  first = NULL,
  last = NULL,
  yrInterp = NULL,
  smoothing_yr = 500,
  detr_type = "mov.median",
  thresh_type = "local",
  thresh_value = 0.95,
  t_lim = NULL,
  noise_gmm = 1,
  keep_consecutive = F,
  min_CountP = 0.05,
  MinCountP_window = 150,
  out_dir = NULL,
  plotit = TRUE,
  x_lim = t_lim,
  plot_crosses = TRUE,
  plot_x = TRUE,
  plot_neg = FALSE,
  sens = TRUE,
  smoothing_yr_seq = NULL
)

Arguments

series

A data.frame with the following columns: CmTop, CmBot, AgeTop, AgeBot, Volume, and one or more columns with the data to be resampled.

out

Desired return value:

"accI"

the function returns resampled accumulation rates (default)

"conI"

the function returns resampled concentrations

"countI"

the function returns resampled counts

series_name

A character string defining typically the site name (NULL by default).

check_series

Logical. If TRUE (default), the input data set will be checked with the check_pretreatment() function.

interp_missing

Logical. Specifies whether the function interpolates missing values. By default interp_missing = TRUE. Missing values are identified when the value of a variable is equal to -999 or NA, or when the sample Volume = 0.

proxy

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

first, last

Age boundaries of the resampled time serie. If unspecified (first=NULL and last=NULL), then resampling is done over the entire sequence, from min(series$AgeTop) to max(series$AgeBot).

yrInterp

Resolution of the resampled timeseries.

smoothing_yr

Smoothing-window width (in years) used for:

  • detrending the data

  • smoothing the signal-to-noise index (SNI)

  • the window width (in years) for the local thresholds

detr_type

Smoothing function used:

"rob.loess"

robust Loess

"rob.lowess"

robust Lowess with 4 iterations

"mov.median"

moving median (aka. method #4 in Matlab CharAnalysis version)

thresh_type

Determines whether to use a single 'global' GMM, or local GMMs to determine the threshold. Defaults to thresh_type = "local".

thresh_value

Determines threshold as the nth-percentile of the Gaussian Model of the noise component. Defaults to thresh_value = 0.95.

t_lim

Allows defining a portion of the time series. With t_lim = NULL (by default) the analysis is performed with the entire time series.

noise_gmm

Determines which of the two GMM components should be considered as the noise component. This is only needed if thresh_type = "global". Defaults to noise_gmm = 1.

keep_consecutive

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

min_CountP

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

MinCountP_window

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

out_dir

Path to the output directory where *.pdf figures files are written files. Defaults to out_dir = NULL, so the default device is used.

plotit

Logical. If TRUE (by default), results obtained with the selected settings are plotted in the display.

x_lim

Age limits of the x-axis scale (the time scale). By default, x_lim = t_lim.

plot_crosses

Logical. If TRUE (by default), crosses are added to indicate the location of the events.

plot_x

Logical. If FALSE (by default), the x-axis labels are omitted.

plot_neg

Logical. If FALSE (by default), both positive and negative events are marked with colored shaded areas.

sens

Logical. Determines whether a sensitivity analysis is performed. This involves performing the peak-detection analysis with different smoothing-window widths (smoothing_yr), and plotting boxplots for the SNI distributions, the Return Intervals, and the number of detected events.

smoothing_yr_seq

The smoothing-window widths used for the sensitivity analysis. If smoothing_yr_seq = NULL (by default), the analysis is performed for the following smoothing-window widths: 500, 600, 700, 800, 900, 1000 years.

Author(s)

Walter Finsinger

Examples

## Not run: 
co <- tapas::co_char_data
co_loc <- tapas::peak_detection(co, proxy = "char")

## End(Not run)


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