Hierarchical generalized additive models in ecology: an introduction with mgcv

PeerJ. 2019 May 27:7:e6876. doi: 10.7717/peerj.6876. eCollection 2019.

Abstract

In this paper, we discuss an extension to two popular approaches to modeling complex structures in ecological data: the generalized additive model (GAM) and the hierarchical model (HGLM). The hierarchical GAM (HGAM), allows modeling of nonlinear functional relationships between covariates and outcomes where the shape of the function itself varies between different grouping levels. We describe the theoretical connection between HGAMs, HGLMs, and GAMs, explain how to model different assumptions about the degree of intergroup variability in functional response, and show how HGAMs can be readily fitted using existing GAM software, the mgcv package in R. We also discuss computational and statistical issues with fitting these models, and demonstrate how to fit HGAMs on example data. All code and data used to generate this paper are available at: github.com/eric-pedersen/mixed-effect-gams.

Keywords: Community ecology; Functional regression; Generalized additive models; Hierarchical models; Nonlinear estimation; Regression; Smoothing; Time series; Tutorial.

Grants and funding

This work was funded by Fisheries and Oceans Canada, Natural Science and Engineering Research Council of Canada (NSERC) Discovery Grant (RGPIN-2014-04032), by OPNAV N45 and the SURTASS LFA Settlement Agreement, managed by the U.S. Navy’s Living Marine Resources Program under Contract No. N39430-17-C-1982, and by the USAID PREDICT-2 Program. There was no additional external funding received for this study. The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.