gavinsimpson / gratia

ggplot-based graphics and useful functions for GAMs fitted using the mgcv package
https://gavinsimpson.github.io/gratia/
Other
206 stars 28 forks source link

Add support for glmmTMB model fits #240

Open gavinsimpson opened 1 year ago

gavinsimpson commented 1 year ago

As mentioned in #227 {glmmTMB} now has basic support for penalised splines based on {mgcv}'s smooths and smooth2random().

What does {gratia} need to be able to support these models?

There are lots of utilities that will need methods for class "glmmTMB", or be modified to work with these objects or be turned into S3 methods and methods wirtten for all classes currently handled by {gratia}

Work on this in the add-glmmTMB-support branch.

gavinsimpson commented 1 year ago

The main difficulty is that models fitted with glmmTMB() do not store the smooths in object$smooth, but rather buried much more deeply in object$modelInfo$reTrms$cond$smooth_info. Much of {gratia} was written from the viewpoint of models objects that walked and quacked like a gam() model fit even if they weren't quite one. Hence lots of trivial changes will be needed to accommodate glmmTMB() models.

There are two main types of change required:

  1. Add S3 methods where existing functions are S3 generics in {gratia}, and
  2. Turn existing functions that aren't S3 generics into them, and write the appropriate methods, as well as the "glmmTMB" method

By default the methods that should be added in addition to the "glmmTMB" will be