[R-sig-ME] Plotting models with quadratic trends

Guillaume Adeux gu|||@ume@|mon@@2 @end|ng |rom gm@||@com
Fri Jan 19 19:30:07 CET 2024


Hi,
An alternative could be to code your linear and quadratic effect as
poly(Var,2) (this ensures orthogonality) and use ggemmeans() or ggeffects()
(the difference between the two will depend on whether you have non focal
factors or not) . Something along these lines :
require("ggeffects")
require("emmeans")
*plot(ggemmeans(mod,terms="Var[all]"))*
If you want to look at interactions with factors, you can add :
*plot(ggemmeans(mod,terms=c("Var[all]","YourFactor")))*
You can also condition on specific values of other covariates.
This is well detailed/illustrated if you type "difference between ggpredict
and ggeffects" in your browser.
To go further, these linear and quadratic effects can be compared using
emtrends():
*emtrends(mod, ~ YourFactor | degree, "Var", max.degree = 2)*
You can wrap that in a pairs() call for pairwise comparisons.
Have a good weekend,
GA2



<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Le ven. 19 janv. 2024 à 15:36, Adam Roebuck <adam.a.roebuck using gmail.com> a
écrit :

> Hello,
>
> I apologize in advance if this is not the correct venue for this question.
> I have been searching for a way to plot models with quadratic interactions
> in R for months now. Each time I search, I typically end up falling back on
> calculating point estimates in Excel. If anyone has any suggestions, I
> would greatly appreciate it.
>
> My model specification is as follows:
>
> mod<-lme(DV~1+linear+quad+cov1+var1+(linear*var1)+(quad*var1),
>
> random=~1+lvl1|lvl2,
>
> data=dat,method="ML",
>
> control=list(opt="optim"),correlation=corAR1())
>
> Both interactions with the time variables are significant, and so I would
> like to find a way to plot them in R instead of Excel.
>
> Thanks,
> Adam
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list