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>
<#m_-6732050243265228395_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Le ven. 19 janv. 2024 ? 15:36, Adam Roebuck <adam.a.roebuck at 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]]