quickGAM: quickGAM

Description Usage Arguments Details Author(s) References Examples

View source: R/quickGAM.R

Description

quickGAM is a function to fit a GAM and perform the related analyses described in Simpson (2018). This function essentially applies the code provided in that article's Supplementary Information, to a pair of vectors.

Usage

1
quickGAM(x, y, xLabel = NULL, yLabel = NULL, yRange = NULL, skipAuto = FALSE)

Arguments

x

vector containing the independent data/linear predictor

y

vector containing the dependent data/response variable

xLabel

(defaults to NULL): optional custom string to ensure consistent x-axis labels across the plots

yLabel

(defaults to NULL): optional custom string to ensure consistent y-axis labels across the plots

yRange

(defaults to NULL): optional custom range to ensure consistent y-axis across all plots

skipAuto

(Defaults to FALSE): logical to indicate whether to skip the autocorrelation calculation and plot

Details

Two input vectors are required (x and y, the independent and dependent variable respectively). The optional arguments allow customization of the x and y axes labels to ensure they remain consistent across all graphs. Similarly the y-range can be manually defined.

The function produces six plots:

Author(s)

Adam Jeziorski

References

Simpson GL (2018) Modelling Palaeoecological Time Series Using Generalised Additive Models. Frontiers in Ecology and Evolution [https://dx.doi.org/10.3389/fevo.2018.00149]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#Fit a GAM to the example chlorophyll a data in 'vrsChlaInput'
data(vrsChlaInput)
plotData <- vrsChla(vrsChlaInput)
#Values/labels to be preserved across all plots
indepVarLabel <- "Core Depth (cm)"
depenVarLabel <- expression(
 "VRS-Inferred Chlorophyll "~italic("a")~" (mg"%.%"g"^"-1"*textstyle(")"))
depenVarRange <- c(0, 0.0825)

#NOTE: drop=FALSE when reading in data columns preserves column names, allowing their use in plots.
quickGAM(plotData[,1, drop=FALSE],plotData[,2, drop=FALSE], xLabel = indepVarLabel, 
yLabel = depenVarLabel, yRange = depenVarRange)

shiggo/jezioro documentation built on Sept. 7, 2020, 7:34 p.m.