TraMineRExtras 中的 seq 粒度

问题描述 投票:0回答:1

我正在使用

seqgranularity
中的
TraMineRExtras
命令。我在帮助文档中看到我可以指出
method = "mostfreq"
。例如,如果我从月度数据转移到年度数据,并且在 12 个月内,我有 6 个月在一个州,有 6 个月在另一个州,会发生什么情况?这两者中的哪一个将用于定义年度序列? 谢谢!

sequence traminer
1个回答
0
投票

通过在

which.max
的结果上应用
seqistatd
来识别最常见的类别,这会按字母顺序返回状态频率。
which.max
返回第一个遇到的最大值的索引。因此,使用
method="mostfreq"
seqgranularity
会分配字母表中出现频率最高的类别中第一个出现的类别。

下面的示例包含两个长度为 24 的序列,显示结果如何随字母顺序变化

library(TraMineRextras
dat <- read.table(text = "
                  a/6,b/6,c/2,d/10
                  b/6,a/6,c/10,d/2
                  ")
sdat <- seqformat(dat, from="SPS", to="STS", 
              SPS.in = list(xfix = "", sdsep = "/"), 
              stsep=",")

seq1 <- seqdef(sdat, alphabet=c("a","b","c","d")) 
## "a" precedes "b" in the alphabet
seqgranularity(seq1, method="mostfreq",tspan=12)
      
##   Sequence
## 1 a-d     
## 2 a-c 

seq2 <- seqdef(sdat, alphabet=c("d","c","b","a")) 
## Here "b" precedes "a" in the alphabet
seqgranularity(seq2, method="mostfreq",tspan=12)

##   Sequence
## 1 b-d     
## 2 b-c 
© www.soinside.com 2019 - 2024. All rights reserved.