mgcv2tapas: Import a trend determined by GAM into tapas

View source: R/mgcv2tapas.R

mgcv2tapasR Documentation

Import a trend determined by GAM into tapas

Description

mgcv2tapas() makes it easy to import a trend that was generated with the mgcv::gam() function into the tapas environment, such that the data can be further analysed for peaks with the tapas::global_thresh() or the tapas::local_thresh() functions.

Usage

mgcv2tapas(series = NULL, data_type = "accI", series.name = NA, plotit = TRUE)

Arguments

series

A list generated with the mgcv::gam() function

data_type

The dimension of the input variable. By default, data_type = "accI", i.e. binned accumulation rates. Other options include: "acc", "con", or "count" for non-binned accumulation rates, concentrations, or counts, respectively. Or "conI" and "countI" for binned concentrations and counts, respectively.

series.name

A string defining the name of the input matrix, typically the site name. Defaults to NA.

plotit

Logical. If plotit == TRUE, figures are plotted to the current device.

Details

mgcv2tapas() extracts data from the list that was generated with the mgcv::gam() function. In addition, it fetches data from the data frame that was called by the mgcv::gam() function. Thus, that data frame has to be available in the R environment.

The function additionally plots the data along with the GAM-modeled trend (red line) and the 2 standard errors of the GAM model (blue lines), and plots the detrended data with the GAM-modeled trend.

Value

mgcv2tapas() returns a list that can be further processed to detect peaks with the tapas::global_thresh() or the tapas::local_thresh() functions.

mgcv2tapas() returns a tapas::SeriesDetrend()-styled list. The GAM-modeled trend is stored in the $detr sublist. To populate the $int sublist, which is typically generated by the tapas::pretreatment_data() function, mgcv2tapas() pulls the necessary data from the data frame that was called by the mgcv::gam() function. Thus, either from a data frame that was generated with the tapas::tapas2mgcv() function (if the data was binned), or from a non-binned data frame (that has the same format as the input data frame for the tapas::pretreatment_data() function).

The $int sublist includes three sublists:

  • the $series.int sublist contains the data that was used by the mgcv::gam() function and that can be further processed with the tapas::global_thresh() or the tapas::local_thresh() functions. In the case of sedimentary charcoal records, this data has typically the dimension of charcoal-accumulation rates.

  • the $series.conI and the $series.countI sublists should contain the concentration and count values, respectively. To generate these data sets, mgcv2tapas() requires a user-determined parameter (data_type) that declares the dimension of the input data. If data_type == "accI" or "acc", the data for the $series.conI and the $series.countI sublists is calculated by mgcv2tapas(). If data_type == "conI", or "con", the $series.int and the $series.conI will contain the same data. If data_type == "countI" or "count", the $series.int and the $series.countI will contain the same data.

Author(s)

Walter Finsinger

See Also

tapas2mgcv()


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