Ok,
Now that the source is identified, perhaps the immediate workaround is to
re-register the original nlme S3 method:
registerS3method("model.frame", "lme", nlme:::model.frame.lme)
This should restore the expected dispatch for car::Anova.lme(). The long-term
solution would likely be for MuMIn to make its model.frame.lme() signature
compatible with the standard model.frame() interface.
Best,
> Le 19 juil. 2026 à 10:55, Jinsong Zhao <[email protected]> a écrit :
>
> I think I've found the root cause.
>
> piecewiseSEM imports MuMIn, where model.frame.lme is registered as an S3
> method:
>
> S3method(model.frame, lme)
>
> Its definition is:
>
> model.frame.lme <- function(formula, random = FALSE, ...)
>
> But Anova() calls it (per traceback()) with:
>
> model.frame.lme(object, data, xlev = xlev)
>
> This passes data to the random argument, causing a type mismatch and the
> error:
>
> Error in if (random) { : the condition has length > 1
>
> I've diagnosed the issue, but I don't yet know how to fix it.
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.