Hi,

Could this be a package compatibility bug?

Since Anova(fm2), car::Anova(fm2), and even car:::Anova.lme(fm2) all produce 
the same error, it doesn’t appear to be a simple namespace masking issue.

Could you post the output of:

traceback()
sessionInfo()
packageVersion("car")
packageVersion("piecewiseSEM")
packageVersion("nlme")

That should help identify the exact call that’s failing and whether the problem 
lies in car, piecewiseSEM, or an incompatibility between the two packages.



> Le 19 juil. 2026 à 04:58, Jinsong Zhao <[email protected]> a écrit :
> 
> I have tried each solution in a new R session, and neither works.
> 
> > library(piecewiseSEM)
> Registered S3 method overwritten by 'lme4':
>   method           from
>   na.action.merMod car
> 
>   This is piecewiseSEM version 2.3.0.2.
> 
> 
>   Questions or bugs can be addressed to <[email protected]>.
> > library(nlme)
> > library(car)
> Loading required package: carData
> > fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
> > Anova(fm2)
> Error in if (random) { : the condition has length > 1
> > car::Anova(fm2)
> Error in if (random) { : the condition has length > 1
> > car:::Anova.lme(fm2)
> Error in if (random) { : the condition has length > 1

______________________________________________
[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.

Reply via email to