CecileProust-Lima / lcmm

R package lcmm
https://CecileProust-Lima.github.io/lcmm/
58 stars 13 forks source link

How to plot trajectory graphs for the identified groups ? #248

Closed Jiha2717 closed 4 months ago

Jiha2717 commented 8 months ago

Dear Cecile, Thank you for providing such a powerful package! I encountered a problem while conducting the analysis,here is my model: model <- hlme(WBP ~ poly(Time, degree = 3, raw = TRUE)*CenterID, random = ~ poly(Time, degree = 3, raw = TRUE), subject = "ID", mixture = ~ poly(Time, degree = 3, raw = TRUE), ng = 4, data =train_data , B = m31) My model incorporates an interaction between time and center. The model divided the samples in the train_data into 4 groups. I'm wondering if there's a method to plot the trajectories of the WBP variable for these grouped samples in the train_data dataset. Currently, I'm manually plotting using the lowess curve in ggplot2.Alternatively, is the command "plot(model, which="fit", var.time="Time")" the result I'm looking for?The following plot is what I have drawn using ggplot2.

23394

VivianePhilipps commented 6 months ago

Hi,

we have the predictY function to get the trajectories in each latent class. Please see an example in https://cecileproust-lima.github.io/lcmm/articles/latent_class_model_with_hlme.html For the plot, either you use the associated plot function, or you do it yourself with ggplot using the $pred output of the predictY object.

Viviane