Learn R Programming

itsadug (version 0.8)

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.

Arguments

Evaluation

  • The functioncompareMLcompares two GAMM models based on their selection scores and degrees of freedom.
  • The functioncheck_residallows for a quick inspection of the residuals. It shows the distribution and autocorrelation.
  • The functionsacf_resid,acf_plot, andacf_n_plotsallow for a more precise inspection of the autocorrelation in the model residuals.
  • The functionresid_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 functionstart_eventcreates a column with the start of each event, which can be used as input of the argumentAR.startingamorbam
  • The functiongamtabsis 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.