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

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sun Jul 19 04:29:44 CEST 2026


Since these packages don't seem to play well with each other, even if they are conflicting from within the global namespace you can access symbols defined in any installed package namespace using "::" notation... something like

piecewiseSEM::na.action.merMod

or the package maintainers of those packages might make changes to improve compatibility.


On July 18, 2026 6:06:21 PM PDT, Jinsong Zhao <jszhao using yeah.net> wrote:
>Hi there,
>
>In the code below, you may notice that the Anova() function from the 
>*car*package does not behave as expected after loading the 
>piecewiseSEMpackage. I haven't been able to identify the cause of this 
>issue or find a working solution. Any suggestions or insights would be 
>greatly appreciated.
>
>Best,
>
>Jinsong
>
> > library(nlme)
> > fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
> > library(car)
>Loading required package: carData
> > Anova(fm2)
>Analysis of Deviance Table (Type II tests)
>
>Response: distance
>        Chisq Df Pr(>Chisq)
>age 114.8383  1  < 2.2e-16 ***
>Sex   9.2921  1   0.002301 **
>---
>Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> > 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 <jslefche using gmail.com>.
> > Anova(fm2)
>Error in if (random) { : the condition has length > 1
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org 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.

--
Sent from my phone. Please excuse my brevity.
	[[alternative HTML version deleted]]



More information about the R-help mailing list