Skip to content

Fixing the clmm environment evaluation #1191

Description

@strengejacke

I dug into this a bit deeper using options(warn = 2) to force the warning into an error, and I managed to trace the root cause.

The "terms not found" error in ggeffects:::.check_vars() is just a downstream symptom. The actual point of failure is an environment/scoping drop inside insight::model_info() when handling clmm models from within the ggeffects call stack.

When ggemmeans calls .check_bias_correction(), it triggers insight::model_info(). Inside that nested function stack, insight loses track of the clmm model's original data environment, falls back to model_info.default(), and throws the "Could not access model information" warning.

Error: (converted from warning) Could not access model information.
11. doWithOneRestart(return(expr), restart)
...
8. .signalSimpleWarning("Could not access model information.", base::quote(NULL))
7. warning(...)
...
4. model_info.default(model) 
3. insight::model_info(model) # <--- POINT OF FAILURE
2. .check_bias_correction(model, type = "fixed", ...)
1. ggemmeans(fit, terms = c("mood", "au12"), mode = "latent")

Because insight::model_info() fails here, it cascades down to .check_vars(), causing insight::find_predictors(effects = "all") to return NULL, which triggers the fatal "terms maybe misspelled?" check.

@strengejacke Since you maintain both packages, I figured it would be easiest to leave it up to you whether the safest patch is fixing the clmm environment evaluation inside insight, or adding a base R all.vars(formula(model)) fallback inside ggeffects:::.check_vars().

Originally posted by @jmgirard in #676

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions