[R-sig-ME] [EXT] Re: Plotting models with quadratic trends

d@iuedecke m@iii@g oii uke@de d@iuedecke m@iii@g oii uke@de
Mon Jan 22 20:22:40 CET 2024


Hi Adam,
just a short follow-up, meanwhile you can also calculate contrasts and pairwise comparisons using ggeffects. See following examples / vignettes, starting with this one (the other two vignettes belonging to this series are references/linked in the document).

https://strengejacke.github.io/ggeffects/articles/introduction_comparisons_1.html

Best
Daniel

-----Ursprüngliche Nachricht-----
Von: R-sig-mixed-models <r-sig-mixed-models-bounces using r-project.org> Im Auftrag von Adam Roebuck
Gesendet: Montag, 22. Januar 2024 18:10
An: Guillaume Adeux <guillaumesimon.a2 using gmail.com>
Cc: r-sig-mixed-models using r-project.org
Betreff: [EXT] Re: [R-sig-ME] Plotting models with quadratic trends

Just want to send along a quick thank you to Guillaume Adeux and Tom Philippi. Both of your recommendations worked beautifully.

Have a great week,
Adam

On Fri, Jan 19, 2024 at 1:30 PM Guillaume Adeux <guillaumesimon.a2 using gmail.com>
wrote:

> 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 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]]

_______________________________________________
R-sig-mixed-models using r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

--

_____________________________________________________________________

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Christian Gerloff (Vorsitzender), Joachim Prölß, Prof. Dr. Blanche Schwappach-Pignataro, Matthias Waldmann (komm.)
_____________________________________________________________________

SAVE PAPER - THINK BEFORE PRINTING


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