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

Moved glmmTMB require statement in plot_type_ranef to come after the model class check #858

Merged

Conversation

jvparidon
Copy link
Contributor

Calling plot_model() with type = "re" (and by extension plot_type_ranef()) on an lme4 model object currently throws an error if glmmTMB is not installed: Package 'glmmTMB' required for this function to work, please install it.

However, looking at the plot_type_ranef() code it doesn't seem like glmmTMB is actually necessary to plot lme4 ranefs. There is a require call for glmmTMB at the top of plot_type_ranef(), before the control flow actually checks whether the model is an lme4 or glmmTMB model.

I've moved the glmmTMB require statement so that the model class is checked first. If glmmTMB is not actually necessary, not having it installed won't throw an error.

I considered moving the lme4 require statement as well, but sjstats (and by extension sjPlot) has it as a hard dependency anyway, so it should always be installed if plot_type_ranef() is called.

@jvparidon jvparidon changed the title Moved glmmTMB require statement in plot_type_ranef to after the model class check Moved glmmTMB require statement in plot_type_ranef to come after the model class check Oct 28, 2022
@jvparidon
Copy link
Contributor Author

Love using sjPlot, by the way!

@strengejacke
Copy link
Owner

LGTM! Thanks!

@strengejacke strengejacke merged commit 9e8b4de into strengejacke:master Oct 25, 2023
@jvparidon jvparidon deleted the jvp/refactor_glmmTMB_dependency branch October 26, 2023 14:37
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

Successfully merging this pull request may close these issues.

None yet

2 participants