Re: Anova() in car not works after loading piecewiseSEM package
varin sacha via R-help <[email protected]> Sun, 19 Jul 2026 12:10:19 +0200
| Newsgroups | gmane.comp.lang.r.general |
|---|---|
| Message-ID | <[email protected]> |
Ok, =
Now that the source is identified, perhaps the immediate workaround is to r=
e-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-te=
rm solution would likely be for MuMIn to make its model.frame.lme() signatu=
re compatible with the standard model.frame() interface.
Best,
> Le 19 juil. 2026 =C3=A0 10:55, Jinsong Zhao <[email protected]> a =C3=A9cri=
t :
> =
> 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 =3D FALSE, ...)
> =
> But Anova() calls it (per traceback()) with:
> =
> model.frame.lme(object, data, xlev =3D 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.