Interpreting and plotting piecewise lme regression (sjPlot)

久未见 提交于 2020-12-15 05:34:51

问题


I am running a LME (Linear Mixed-Effects regression) in R where the knot is determined by the time of diagnosis (t=0). So the model is now:

lme(function ~ age+sex+timepre*marker+timepost*marker, random=~time|ID, data=data)

Thus: timepre is where everything from t=0 is 0 and before that is 0-time, and timepost is where everything before diagnosis is 0 and afterwards is 0+time. The time is the combination of timepre and timepost.

I now wanted to plot these effects using the sjPlot library as it nicely gives the predicted values (corrected for covariates) and having this as a plot where one could see the knot at t=0.

plot_model(model, type="int")

Instead it is plotting two different plots, one for each interaction. Is there a way to combine these plots, so that the slopes before and after come together (the intercepts are also different now)? Or how should I do this?

UPDATE:

After googling more, I found a suggestion to use splines instead of two separate time frames. So, what I tried now is:

lme(function ~ age+sex+bs(time, knots=0, degree=1)*marker, random=~time|ID, data=data)

I am able to plot this with the visreg library and I do seem to get the knot at zero:

Is this correct? Am I correct that the coefficients should be interpreted as follows:

bs(time, knots = 0, degree = 1)1:marker  12.055090  p= 0.0004
bs(time, knots = 0, degree = 1)2:marker  13.750058  p= 0.0133

the first coeff (12.055 and with p-value 0.0004) represents the change in the first slope (before the knot) as a function of the level of the marker? And the second coeff (13.75 with p-value 0.013) represents the difference between the first and second slope as a function of the marker? How then to know if change in the second slope is significant as a function of the marker?


回答1:


You don't need to use splines for your time variable, especially if you just have two time points, you can't fit any curve between these two points. Thus, your model would be:

lme(function ~ age + sex + time * marker, random=~time|ID, data=data)

You can then use plot_model(model, type = "int") to see the interaction and differences between the two time points. Or you can use the ggeffects package, which is even a bit more flexible.

If the time variable has more than two time points, it probably makes sense using poly() or splines. For ggeffects, there's a practical example including polynomial terms here (and a general introduction here).

For your above example:

library(ggeffects)
m <- lme(function ~ age+sex+bs(time, knots=0, degree=1)*marker, random=~time|ID, data=data)
pred <- ggpredict(m, c("time", "marker"))
plot(pred)


来源:https://stackoverflow.com/questions/57346055/interpreting-and-plotting-piecewise-lme-regression-sjplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!