itsadug: Interpreting Time Series, Autocorrelated Data Using GAMMs (itsadug)
Description
Itsadug provides a set of functions that facilitate the evaluation,
interpretation, and visualization of GAMM models that are implemented in
the package mgcv.Evaluation
- The function
compareMLcompares two GAMM models based
on their selection scores and degrees of freedom. - The function
check_residallows for a quick inspection
of the residuals. It shows the distribution and autocorrelation. - The functions
acf_resid,acf_plot,
andacf_n_plotsallow for a more precise inspection of the
autocorrelation in the model residuals. - The function
resid_gamgives back the corrected
residuals of a GAMM that includes an AR1 model.
Interpretation and visualization
The vignettes "overview" and "plotfunctions"
(vignette("overview", package="itsadug") and
vignette("plotfunctions", package="itsadug"))
provide more
info and examples on the different plot functions, and how they related to
mgcv's default plot functions. Here's a short list of the functions
for visualizing model terms and interactions:
pvisgamplots partial interaction surfaces; it also
allows for visualizing 3-way or higher interactions.fvisgamplots summed interaction surfaces, with the
possibility to exclude random effects.plot_smoothplots 1D model estimates, and has the
possibility to exclude random effects.plot_parametricplot group estimates.plot_diff2plots adifferencesurface
(difference between two nonlinear interaction surfaces).plot_diffplots adifferencesmooth.
Predictions
Further, there are some wrappers around the predict.gam
function to facilitate the extraction of model predictions. These can be
used for customized plots. See for an example in the vignette
"plotfunctions"
(vignette("plotfunctions", package="itsadug")).
get_predictionsfor getting the estimates for given
settings of some or all of the model predictors;get_differencefor extracting the difference between
two conditions or two smooths or two surfaces.get_modeltermfor extracting the smooth term (
partial) estimates.get_randomfor extracting random effects only.
Additional functions
There are more functions, mostly utility functions. But the ones mentioned
here may be worth to try:
- The function
start_eventcreates a column
with the start of each event, which can be used as input of the
argumentAR.startingamorbam - The function
gamtabsis a wrapper aroundprint.xtable(package xtable) for including model summaries
in aknitrfile. find_differencereturns where a smooth is
significantly different from zero.fadeRuguses transparency to overlay data
observations on a surface.gradientLegendfor adding a color legend to a plot.
The additional functions are mostly convenience functions for plotting,
such as emptyPlot, plot_error for quickly
plotting smooth terms with shaded errors, and addInterval
for drawing interval indication.