Spaghetti plot for linear regression models
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
David Obert
el 20 de Dic. de 2023
Respondida: the cyclist
el 20 de Dic. de 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 comentarios
Respuesta aceptada
the cyclist
el 20 de Dic. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Conditional Mean Models en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!