[R] Anova() in car not works after loading piecewiseSEM package

varin sacha v@r|n@@ch@ @end|ng |rom y@hoo@|r
Sun Jul 19 12:10:19 CEST 2026


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 <jszhao using yeah.net> 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.



More information about the R-help mailing list