Skip to content

Patients assigned to multiple clusters #139

Answered by niekdt
rvdmvm asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

The trajectoryAssignments function returns a vector with a single cluster assignment per patient. Subjects are not modeled to change cluster over time.

You cannot assign this vector to your data data frame directly because the data contains repeated measurements per subject. To confirm this, you'll see that length(cluster_new) is way smaller than nrow(data). Unfortunately R does not warn about this mismatching assignment, and happily repeats the vector to match the number of rows, hence the different values over time.

The correct way is to first construct a data frame of the subject cluster assignments, and then to merge that with your original dataset. This ensures the assignments ar…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rvdmvm
Comment options

@niekdt
Comment options

Answer selected by niekdt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants