r - 如何为集群解决方案中的单个集群生成序列频率图

标签 r plot cluster-analysis traminer

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

我做序列分析,状态空间是n = 10,时间空间是t = 168(月)。我绘制了具有 8 个簇的簇解的序列频率图。然而,该情节并不真正可供解释,因为单个情节太固定或太小。 (见下图) enter image description here

到目前为止,我执行了以下过程(非常接近 TraMineR 帮助文档中的说明):

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 中完成的。如果有人知道如何获得更漂亮的序列频率图,我将非常感激! 谢谢你! 奥利弗

最佳答案

对于 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()

希望这有帮助。

关于r - 如何为集群解决方案中的单个集群生成序列频率图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24014755/

相关文章:

r - 列表的逻辑比较

r - R中的模式和类有什么区别?

r - R 中的新列,用于累积计数(相加)唯一日期

在 ggplot2 0.9.0 中使用 axis.line 仅删除 y 轴

python - 如何在多线程任务/时间图中可视化线程?

python - Matplotlib 图例 : how to assign multiple scatterpoints values

python - 如何解释 k Medoids 输出

cluster-analysis - 如何将相似度矩阵转化为相异度矩阵?

r - 在 R 中绘制半圆

algorithm - 生成像城市一样分布的随机点?