Open Br-Hesseling opened 3 months ago
Hello,
the subset argument can't be used to select subjects according to their classification. You can only select them according to a covariate from your data. For example, if you adjust your model on a binary covariate X, you may want to show the plot for X = 0 and X = 1 separately. Then, you can use "subset = which(X == 0)".
The use different pch for each class is not possible. But you can plot only one class by specifying the color 0 for the class you don't want to show.
With a 2-class model, you plot class 1 with :
plot(m, which = "fit", var.time = "t", col = c(1, 0))
and class 2 with :
plot(m, which = "fit", var.time = "t", col = c(0, 2))
To remove the legend you can put legend = NULL.
Best,
Viviane
Hello,
I have created several hlme objects with the lcmm package and have been able to plot them using the
plot()
function. However, I would like to create separate plots for each class, to make it easier to compare the trajectories to the actual scores of participants assigned to each class. I've searched the Internet and used blackbox.ai and tried different codes:1) using
subset = 1
etc within the plot function --> this gives me an empty plot2) using
subset = model$pprob$class == 1
--> this gives the following error:3) Using
subset = model$pprob$class == 1
after creating a subset of only class 1 of the original data used for the model --> error persists, only displaying different numbers of rows.To work around this issue I thought the next best thing would be to give each class a different point symbol. Following examples from the Internet I tried:
4) adding
pch = c(1, 2, 3, 4)
withinplot()
--> all classes still have the same point symbol5) addingn
pch = c(1, 2, 3, 4)[model$pprob$class]
withinplot
--> all classes still have the same point symbolDo you have any suggestions for 1) how to plot only a single class each time, and 2) how to plot all classes in the same plot but with different point symbols?
Any help is greatly appreciated!
Sincerely, Brechtje