Spaghetti plot for linear regression models
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
David Obert
am 20 Dez. 2023
Beantwortet: the cyclist
am 20 Dez. 2023
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 Kommentare
Akzeptierte Antwort
the cyclist
am 20 Dez. 2023
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Conditional Mean Models finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!