Description Usage Arguments Details Author(s) References Examples
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.
1 |
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 |
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:
Basic scatterplot of the data
Estimated CAR1 process from the GAM fitted to the data ( i.e. autocorrelation check)
GAM-based trends fitted to the data
Estimated trends (w 20 random draws of the GAM fit to the data)
95% simultaneous confidence intervals (light grey) and across-the-function confidence intervals (dark grey) on the estimated trends.
Estimated first derivatives (black lines) and 95% simultaneous confidence intervals of the GAM trends fitted to the data. Where the simultaneous interval does not include 0, the models detect significant temporal change in the response.
Adam Jeziorski
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]
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.