[R-sig-ME] [EXTERNAL] Plotting models with quadratic trends
Philippi, Tom
Tom_Ph|||pp| @end|ng |rom np@@gov
Fri Jan 19 18:58:24 CET 2024
I'll jump in because I think this is an easy question not requiring the experts.
My general approach is to create a skeleton dataset with the combination of values I want to graph the fit over (range of linear, quad, cov1, var 1), then use nlme::predict() on my lme object and that skeleton. The hard part is then what to actually graph: surfaces of predicted DV as functions of linear & var1 at average or slices of cov1, separate surfaces for different values of lvl1, or something else that shows informative aspects of the fit. [I'm assuming quad is literally linear^2, perhaps with some centering, so graphing predicted against linear would show the curve due to linear and quad in the model. For such a model you can be pretty coarse in the grid of values in skeleton, as the surface or slice lines can use smoothing to interpolate in the graphing stage.]
lme4, mgcv, and most other packages I use to fit models have predict functions for their model object types.
Tom
-----Original Message-----
From: R-sig-mixed-models <r-sig-mixed-models-bounces using r-project.org> On Behalf Of Adam Roebuck
Sent: Friday, January 19, 2024 6:36 AM
To: r-sig-mixed-models using r-project.org
Subject: [EXTERNAL] [R-sig-ME] Plotting models with quadratic trends
This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.
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
More information about the R-sig-mixed-models
mailing list