Skip to content

Combine latrend() with SillyPutty #143

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

You must be logged in to vote

Hi @hichew22, thanks for the detailed post.

The cluster assignment for the trajectories can be converted to integer by using as.integer(cluster), where 1=first cluster, 2=second cluster, etc.

KmL is not a hierarchical cluster algorithm so it does not compute/consider the pairwise distances between trajectories. That said, since $k$-means uses the Euclidean distance, we can compute a distance matrix ourselves.

First, the data needs to be structured with one trajectory per row, and each column representing a different time point. You can use latrend's tsmatrix function for that. Then we can compute the Euclidean distance matrix using R's dist function.

tsdata = tsmatrix(df, response='value')
d

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by niekdt
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #141 on November 16, 2023 16:15.