1

I have a mixed model (using nlme) with time and time quadratic (time2). How can I let sjp.int (of sjplot) ask to plot it curvilinear?

   model = lme(MR ~ Age* time + sex*time + ed* time+ time* HMD+time2*HMD, random=~1|subject, na.action="na.omit",data=mydata);summary(model)

I called sjplot as:

  sjp.int(model, type="eff", swap.pred=T, mdrt.values="quart", show.ci=T)
user6121484
  • 143
  • 2
  • 15

1 Answers1

0

Your quadratic term should have the same name, i.e. you should be using poly() or I()^2. See following example:

library(sjPlot)
library(sjmisc)
data(efc)
fit <- lm(tot_sc_e ~ c161sex * e17age + c161sex * I(e17age^2), data = efc)
sjp.int(fit)

enter image description here

Note that the order of the predictors for the interaction terms are important and should be the same in the formula (i.e. in the above case, c161sex comes first, then e17age).

Daniel
  • 7,252
  • 6
  • 26
  • 38
  • Hi Daniel, Thanks for the help, this was indeed the trick! Just an additional question, is there a way to plot three-way interactions (e.g. HMD * time * group) and then have a plot where the effect HMD*time is split across my two groups? I tried with facet.grid=TRUE, but it is giving me weird plots (I tried to convert the factor into numeric, but that didn't help) – user6121484 Sep 21 '16 at 19:52
  • 1
    Three-way-interaction is not implemented yet, see https://github.com/sjPlot/devel/issues/103. still needs some conceptional thinking – Daniel Sep 22 '16 at 06:22