【问题标题】:Time Series Hierarchical Clustering in R column-wiseR列中的时间序列层次聚类
【发布时间】:2017-12-31 23:41:11
【问题描述】:

我正在尝试使用 tsclust 进行时间序列聚类,我的数据集如下所示:

我有超过 500 个时间序列,每个时间序列有 8 个观测值在同一时间线上。我将 tsclust 应用于它,但按时间而不是按系列获得集群(如下所示):

后来我发现 tsclust 只能按行工作。(来自 www.rdocumentation.org/packages/dtwclust/versions/3.1.1/topics/tsclust)

是否还有其他类似的函数可以用来完成聚类分析?或者我怎样才能改变我的数据格式来做到这一点?

我的原始代码如下所示:

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")

感谢任何帮助。提前谢谢你。

【问题讨论】:

  • 需要注意的是,您使用的是 dtwclust 包中的 tsclust 函数,而不是 TSclust 包。您是否尝试过转置数据?参见 R 中的 ?t。
  • @Jay 只需将 t 应用于我的系列即可。非常感谢!!!!!!

标签: r time-series cluster-analysis hierarchical-clustering tsclust


【解决方案1】:

使用t转置您的数据。

将列转换为行。

【讨论】:

    猜你喜欢
    • 2016-04-28
    • 1970-01-01
    • 2013-12-13
    • 2011-12-29
    • 2015-08-12
    • 2015-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多