我想使用 ggplot2 或 sjPlot 从 R 中的 lme4 或 nlme 绘制 10 个个体的二次增长曲线的随机子集。我知道如何为线性线做到这一点,但不是二次线。显然,下面有 105 名参与者的情节太疯狂了。
我的模型:
growthquadsl <- lmer(count~time_point+I(time_point^2) + (1+time_point|ParticipantID),
REML = TRUE,
data = longfix)
summary(growthquadsl)
Linear mixed model fit by REML ['lmerMod']
Formula: count ~ time_point + I(time_point^2) + (1 + time_point |
ParticipantID)
Data: longfix
输出:
REML criterion at convergence: 23004.3
Scaled residuals:
Min 1Q Median 3Q Max
-3.3234 -0.6165 -0.0802 0.5312 4.2995
Random effects:
Groups Name Variance Std.Dev. Corr
ParticipantID (Intercept) 28228422 5313.0
time_point 209490 457.7 -0.40
Residual 18922159 4350.0
Number of obs: 1157, groups: ParticipantID, 107
Fixed effects:
Estimate Std. Error t value
(Intercept) 14242.57 605.82 23.510
time_point 874.18 157.42 5.553
I(time_point^2) -73.47 14.75 -4.979
Correlation of Fixed Effects:
(Intr) tm_pnt
time_point -0.510
I(tm_pnt^2) 0.355 -0.923
所有曲线:
ggplot(longfix, aes(x=time_point, y=count)) +
geom_line(aes(y = predict(growthquadsl, level=1, group=ParticipantID), colour = factor(ParticipantID)), size = 1)
输出: