Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gratia support for other regression packages #227

Open
seanhardison1 opened this issue Jun 8, 2023 · 4 comments
Open

gratia support for other regression packages #227

seanhardison1 opened this issue Jun 8, 2023 · 4 comments

Comments

@seanhardison1
Copy link

Hi! I love this package and I use it all the time. It's my go-to for visualizing and diagnosing GAMs on the fly.

My only critique is that I can't use it with other packages that I also use frequently like base stats or glmmTMB. I know it's a big ask, but it would be great to see gratia support for these packages in the future.

Thanks!

Sean

@gavinsimpson
Copy link
Owner

I've been a bit inconsistent with this but where appropriate I planned to support lm() and glm() from base R — appraise() works for those models for example. I hadn't considered supporting glmmTMB(); I'll be more motivated to do this if/once we have penalised splines in glmmTMB().

Are there models/functions/packages that you are especially interested in? And which functions in gratia would you like to see supported for them?

There are other more general options for a wider range of model types, like marginaleffects.

@seanhardison1
Copy link
Author

That makes sense. I was not aware that appraise works for lm and glm, but that's great to hear. The functions in gratia that I use the most are draw and appraise, so those would have to be my top choices.

Outside of mgcv, glmmTMB, and base R, the only other modeling package I use frequently is sdmTMB. sdmTMB models can include smooths fitted via mgcv, but I haven't tried them with gratia yet. It would be very cool to be able to visualize spatiotemporal predictions from sdmTMB models using draw alone, similar to how you can use draw to visualize 2D smooths etc. The predictions from sdmTMB models are already tidy too!

Tagging @seananderson in the hopes that this one day becomes reality

@authagag
Copy link

Opening this up again as glmmTMB has added spline support, see
glmmTMB/glmmTMB#928

There is some discussion of adding support in gratia. Looking through the code it seems that there would need to be a draw.glmmTMB method as well as a smooths.glmmTMB method to find all the smooth terms in the glmmTMB structure. Is there anything I am missing, pretty sure there is more

@gavinsimpson
Copy link
Owner

@authagag Oh, that saves me a job then as I had been looking at what would be required to add smooths to glmmTMB, gamm4-style.

The main thing that would be needed would be smooth_estimates() and parametric_effects() methods for class "glmmTMB". Assuming that glmmTMB does sensible things like store the actual mgcv smooth objects in model$smooths then most things should just work, and specific methods could simply just call the "gam" methods for the plotting code. Things could get more complex if the objects returned by glmmTMB() don't have many of the things that I'd find in a "gam" object as then specific methods for many internal functions could be needed.

I can take a look at glmmTMB/glmmTMB#928 and install from the repo and see what would be needed from gratia's point of view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants