I am running the function "tsclust" on time series data and trying to access the computed distance matrix for later use in plots. An example of my code:
c <- tsclust(data, type="partitional", k=2, distance="dtw2", centroid="mean")
However, when I view c, "distmat" is NULL (c@distmat returns NULL), when I expect the distance matrix to be stored here.
Is there any way to extract the distance matrix used in the clustering after the fact? Or provide a pre-computed distance matrix to tsclust to avoid having to calculate twice? I have tried the latter option using dist() without success, but my implementation could be wrong.
The whole distance matrix is only saved if you use "pam" centroids, but you can definitely calculate it separately, check the examples in the vignette's appendices.
I am running the function "tsclust" on time series data and trying to access the computed distance matrix for later use in plots. An example of my code:
c <- tsclust(data, type="partitional", k=2, distance="dtw2", centroid="mean")
However, when I view c, "distmat" is NULL (c@distmat returns NULL), when I expect the distance matrix to be stored here.
Is there any way to extract the distance matrix used in the clustering after the fact? Or provide a pre-computed distance matrix to tsclust to avoid having to calculate twice? I have tried the latter option using dist() without success, but my implementation could be wrong.
Thanks for the excellent package!