设置子序列的最小长度?

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

我正在使用 TraMineR 来分析 30 分钟试验中状态之间的转换。整个 108,000 帧有 10 个状态,然后是缺失值。当我获得子序列时,它甚至包括一个转换作为子序列,对于我的目的来说,这没有帮助。我知道有一种方法可以限制子序列的长度,但是还有一种方法可以限制需要将其视为子序列的转换次数吗?

如有任何帮助,我们将不胜感激!

# defines the STS object
seq.d <- seqdef(seq, informat="STS", stsep=NULL,
   alphabet=alph, states=bet, weights=NULL, 
   left=NA, right="DEL", void="%", nr="*",
   cnames=NULL, xtstep=1, tick.last=FALSE, cpal=NULL, 
   missing.color="darkgrey", labels=NULL)
# creates a seqelist object 
seq.e <- seqecreate(data=seq.d, id=NULL, timestamp=NULL,
                event=NULL, end.event=NULL, tevent="transition", use.labels = TRUE,
                weighted = NULL)
# subsequences ordered by frequency
seq.s <- seqefsub(seq.e, pmin.support = 0.10, constraint=seqeconstraint(max.gap = 30,
window.size = 300, age.min = -1, age.max = -1,age.max.end = -1, count.method = "CDIST"), max.k = 10)
r subsequence traminer
1个回答
0
投票

TraMineReextras 中的

seqentrans
函数使用子序列中的转换数量和事件数量来完成
seqefsub
返回的表。使用此信息可以轻松过滤掉不具有最小转换或事件数量的子序列。

以下示例基于

seqentrans
帮助页面中的示例。

library(TraMineRextras)
data(actcal.tse)
actcal.seqe <- seqecreate(actcal.tse[1:500,])

##Searching for frequent subsequences appearing at least 10 times
fsubseq <- seqefsub(actcal.seqe, min.support=10)
fsubseq
##                         Subsequence    Support Count
## 1                        (FullTime) 0.45592705   150
## 2                      (NoActivity) 0.34042553   112
## 3                        (PartTime) 0.22492401    74
## 4                     (LowPartTime) 0.15197568    50
## 5                           (Start) 0.10334347    34
## 6                            (Stop) 0.10334347    34
## 7              (NoActivity)-(Start) 0.07902736    26
## 8                    (Start)-(Stop) 0.04863222    16
## 9                 (FullTime)-(Stop) 0.04863222    16
## 10             (LowPartTime)-(Stop) 0.04863222    16
## 11              (Start,LowPartTime) 0.04559271    15
## 12      (NoActivity)-(Start)-(Stop) 0.03951368    13
## 13              (NoActivity)-(Stop) 0.03951368    13
## 14       (NoActivity)-(LowPartTime) 0.03951368    13
## 15                       (Increase) 0.03951368    13
## 16                       (Decrease) 0.03951368    13
## 17 (NoActivity)-(Start,LowPartTime) 0.03647416    12
## 18          (NoActivity)-(FullTime) 0.03343465    11
## 19                 (Start,FullTime) 0.03343465    11
## 20                 (PartTime,Start) 0.03039514    10
## 21    (NoActivity)-(Start,FullTime) 0.03039514    10
## 
## Computed on 329 event sequences
##    Constraint Value
##  count.method  COBJ

添加列

ntrans
nevent

fsubseq <- seqentrans(fsubseq)
## dispaying only those with at least 2 transitions
fsubseq[fsubseq$data$ntrans>1]
##                         Subsequence    Support Count ntrans nevent
## 1              (NoActivity)-(Start) 0.07902736    26      2      2
## 2                    (Start)-(Stop) 0.04863222    16      2      2
## 3                 (FullTime)-(Stop) 0.04863222    16      2      2
## 4              (LowPartTime)-(Stop) 0.04863222    16      2      2
## 5       (NoActivity)-(Start)-(Stop) 0.03951368    13      3      3
## 6               (NoActivity)-(Stop) 0.03951368    13      2      2
## 7        (NoActivity)-(LowPartTime) 0.03951368    13      2      2
## 8  (NoActivity)-(Start,LowPartTime) 0.03647416    12      2      3
## 9           (NoActivity)-(FullTime) 0.03343465    11      2      2
## 10    (NoActivity)-(Start,FullTime) 0.03039514    10      2      3

## dispaying only those with at least 3 events
fsubseq[fsubseq$data$nevent>2]
##                        Subsequence    Support Count ntrans nevent
## 1      (NoActivity)-(Start)-(Stop) 0.03951368    13      3      3
## 2 (NoActivity)-(Start,LowPartTime) 0.03647416    12      2      3
## 3    (NoActivity)-(Start,FullTime) 0.03039514    10      2      3
© www.soinside.com 2019 - 2024. All rights reserved.