Spaghetti plot for linear regression models
14 次查看(过去 30 天)
显示 更早的评论
I have 6 subjects which got tested 10 times (repeated measure). So in total I have 60 values. I used the fitlme function to fit a quadratic model with random intercept and random slope (Formula: Y ~ 1+ TestNumber + TestNumber^2+ (1 + TestNumber|SubjectID)). Now I want to create a spaghetti plot with all values, the predicted model for each subject und the final model with the 95% CI. I already managed to plot the values and the final model with the 95% CI, but how do I calculate the individual models? Do I have to consider random and fixed effects?
0 个评论
采纳的回答
the cyclist
2023-12-20
In the model you describe, you are not interested in this specific subjects, but consider them to be a random draw from a representative population. I would not say that there is a "predicted model for each subject" -- there is one model that has been fit using data from those subjects.
That being said, the model does capture each subject's random deviation from the mean intercept and mean slope. You can get these as follows:
[B,Bnames] = randomEffects(mdl); % where "mdl" is whatever you called your model object
If you wanted to plot the modeled trajectory for these subjects, then you'd add each subject's random effect (different for each subject) to the overall fixed effect (the same for all subjects). Then, using those coefficients, you can plot over the whole range of TestNumber (your independent variable).
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Conditional Mean Models 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!