Re: Anova() in car not works after loading piecewiseSEM package

Jeff Newmiller via R-help <[email protected]> Sat, 18 Jul 2026 19:29:44 -0700
Newsgroups gmane.comp.lang.r.general
Message-ID <[email protected]>
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 def=
ined in any installed package namespace using "::" notation... something li=
ke

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 <[email protected]> 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 =3D Orthodont, random =3D ~ 1)
> > library(car)
>Loading required package: carData
> > Anova(fm2)
>Analysis of Deviance Table (Type II tests)
>
>Response: distance
> =C2=A0 =C2=A0 =C2=A0 =C2=A0Chisq Df Pr(>Chisq)
>age 114.8383=C2=A0 1=C2=A0 < 2.2e-16 ***
>Sex=C2=A0 =C2=A09.2921=C2=A0 1=C2=A0 =C2=A00.002301 **
>---
>Signif. codes:=C2=A0 0 =E2=80=98***=E2=80=99 0.001 =E2=80=98**=E2=80=99 0.=
01 =E2=80=98*=E2=80=99 0.05 =E2=80=98.=E2=80=99 0.1 =E2=80=98 =E2=80=99 1
> > library(piecewiseSEM)
>Registered S3 method overwritten by 'lme4':
> =C2=A0 method=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from
> =C2=A0 na.action.merMod car
>
> =C2=A0 This is piecewiseSEM version 2.3.0.2.
>
>
> =C2=A0 Questions or bugs can be addressed to <[email protected]>.
> > Anova(fm2)
>Error in if (random) { : the condition has length > 1
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>[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.h=
tml
>and provide commented, minimal, self-contained, reproducible code.

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