0

I'm trying to doing a time series clustering using tsclust and my dataset looks like this: enter image description here

I have over 500 time series with eight observations each on the same time line. I applied tsclust to it but got clusters by time but not by series(As below): enter image description here

Later I found out tsclust can only work Row-wise.(from www.rdocumentation.org/packages/dtwclust/versions/3.1.1/topics/tsclust)

If there's any other similar functions that I can use to finish the clustering analysis? Or how I can change the format of my data to do it?

my original code looks like this:

tst<-read.csv("data.csv", stringsAsFactors = TRUE)
tst<-xts(tst[,-1], order.by = as.Date(paste0(tst[,1])))

par(mar=c(1,1,1,1))
plot.xts(tst)

series <- zscore(tst)

hc.sbd <- tsclust(series, type = "h", k = 6L,
              preproc = zscore, seed = 233,
              distance = "sbd", centroid = shape_extraction,
              control = hierarchical_control(method = "average"))
plot(hc.sbd)
plot(hc.sbd, type = "sc")

Any help is appreciated. Thank you in advance.

www
  • 38,575
  • 12
  • 48
  • 84
Kraken
  • 13
  • 3
  • 1
    Important to note that you are using the tsclust function in the dtwclust package, rather than the TSclust package. Have you tried transposing your data? See ?t in R. – Jay Jul 26 '17 at 04:37
  • @Jay It worked just by simply apply t to my series. Thank you so much!!!!! – Kraken Jul 26 '17 at 10:12

1 Answers1

3

Transpose your data using t.

That converts columns into rows.

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194