【问题标题】:How to produce a sequence frequency plot for one single cluster within a cluster solution如何在集群解决方案中为单个集群生成序列频率图
【发布时间】:2014-07-23 18:20:58
【问题描述】:

我找不到我的问题的充分答案,也许有人可以在这里提供帮助? (我是 R 的初学者)

我做序列分析,状态空间是n = 10,时间空间是t = 168(月)。我为具有 8 个集群的集群解决方案绘制了序列频率图。然而,这个情节并没有真正开放解释,因为单个情节太固定或太小。 (见下图)

到目前为止,我执行了以下程序(非常接近 TraMineR-Help-document 中的说明):

dist.om1 <- seqdist(neu.seq, method = "OM", indel = 1, sm = submat)
clusterward1 <- agnes(dist.om1, diss = TRUE, method = "ward")
cluster8 <- cutree(clusterward1, k = 8)
cluster8 <- factor(cluster8, labels = c("Typ 1", "Typ 2", "Typ 3", "Typ 4", "Typ 5", "Typ 6", "Typ 7", "Typ 8"))
seqfplot(neu.seq, group = cluster8, pbarw = T, withlegend = T)

我尝试重新配置边距,但结果始终是相同的图(附加图是使用默认设置完成的)。所以我想,相反,也许我可以在我的 8 集群解决方案中为单个集群绘制序列频率图。 (在Stata代码中,我会为单个序列索引图sqindexplot if cluster8 == 4写一些东西) 但是,我不知道这是如何在 R 中完成的。如果有人知道如何获得更漂亮的序列频率图,我将不胜感激! 谢谢! 奥利弗

【问题讨论】:

    标签: r plot cluster-analysis traminer


    【解决方案1】:

    对于 8 个组,您可能需要使用 cex.plot 参数来减小坐标区标签的字体大小。例如:

    seqfplot(neu.seq, group = cluster8, withlegend = T, cex.plot=.5)
    

    您还可以使用 border=NA 参数获得更好看的图,该参数抑制代表每个序列模式的条形周围的黑色边框。

    或者,如果您使用pdfpngjpeg 等图形设备来创建绘图文件,请尝试使用函数的参数widthheightheight 值越大,文本看起来越小。

    要仅获取集群 4,请使用

    seqfplot(neu.seq[cluster8=="Typ 4",], withlegend = T)
    

    (另见How to identify sequences within each cluster?

    如果您想自己使用 par(mfrow=c(.,.)) 组合图例,您必须禁用自动图例,并使用 seqlegend 手动插入图例,例如

    par(mfrow=c(2,2))
    seqfplot(neu.seq[cluster8=="Typ 4",], withlegend = F)
    seqfplot(neu.seq[cluster8=="Typ 5",], withlegend = F)
    seqfplot(neu.seq[cluster8=="Typ 6",], withlegend = F)
    seqlegend(neu.seq)
    dev.off()
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-16
      • 2010-11-06
      • 2019-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多