Error: seqdata should be a state sequence object, an event sequence object, or a suffix tree. Use seqdef or seqecreate

Error: seqdata should be a state sequence object, an event sequence object, or a suffix tree. Use seqdef or seqecreate

我有一个数据序列(类似于蛋白质数据),我想使用隐马尔可夫模型 (mhmm) 的混合来对它们进行聚类。我选择了 seqHMM 包来完成它。但是当我想训练一个 mhmm 模型时,它给出了这个错误:

build_mhmm(observations = dat, n_states = c(4, 4, 6))

Error in FUN(X[[i]], ...) : seqdata should be a state sequence object, an event sequence object, or a suffix tree. Use seqdef or seqecreate.

我试图为 dat 构建结构。一个是正​​常序列,另一个是序列矩阵。 例如:

dat<-data.frame(matrix(c("e","f","j","o","d","o","p","k","k","a","d","c"),ncol = 4,nrow = 3))
#  X1 X2 X3 X4
#1  e  o  p  a
#2  f  d  k  d
#3  j  o  k  c

matrix(paste(dat$X1,dat$X2,dat$X3,dat$X4),nrow = nrow(dat))
#1 "eopa"
#2 "fdkd"
#3 "jokc"

我应该如何更改我的数据格式,以便使用 build_mhmm 使其可读?数据已经存在,我不想使用任何包重新创建它们。我想操纵它们并将它们作为适当的输入。

我找到了答案。我应该在 build_mhmm 函数

中使用 seqdef(dat) 表单包 TraMineR 而不是 dat