TSE_TO_STS 申请

TSE_TO_STS application

我有 12 个 TSE 格式的分类序列。在此函数的帮助页面中,根据使用的序列数据示例,tmax 被指定为 12。如果一个序列的最大时间长度为 292 而其他序列的最大时间长度小于 292,我将如何更改此值。假设其中一个序列在时间 25 结束。使用 tmax=292,25 之后的任何状态都将使用相同的状态,直到 292,我认为这是错误的。我想在时间 25 停止序列并用 void 填充右侧的任何其他内容。

TSE_to_STSTraMineRextras 包提供的函数。它将带有时间戳记的事件序列转换为状态序列。生成的状态序列采用 STS 形式,即以 table 组织,每个序列在不同的行中,状态在连续的列中。 tmax用来决定这个table的列数。因此,应该固定为最大状态序列长度。

例如,要在时间 25 结束序列,您需要在时间 25 插入序列结束事件。TSE_to_STS无法猜测序列何时结束。

============示例

下面我将说明如何继续使用 TraMineR 附带的 actcal.tse 数据。我考虑了 id 2 和 4 的数据,并假设 id 2 观察到第 8 个月,id 4 观察到第 10 个月。

data(actcal.tse)

## Consider the data for id 2 and 4 and  
## insert "endobs" event to indicate end of observation

subset <- rbind(actcal.tse[2:4,], data.frame(id=2,time=8,event="endobs"), 
                actcal.tse[7:9,], data.frame(id=4,time=10,event="endobs"))
subset
##    id time       event
## 2   2    0  NoActivity
## 3   2    4       Start
## 4   2    4    FullTime
## 1   2    8      endobs
## 7   4    0 LowPartTime
## 8   4    9    Increase
## 9   4    9    PartTime
## 11  4   10      endobs


## Define list of events of interest
events <- c("PartTime", "NoActivity", "FullTime", "LowPartTime", "endobs")
## Dropping all previous events
stm <- seqe2stm(events, dropList=list(PartTime=events[-1], NoActivity=events[-2], 
                FullTime=events[-3], LowPartTime=events[-4], endobs=events[-5]))
mysts <- TSE_to_STS(subset, id=1, timestamp=2, event=3,
                stm=stm, tmin=1, tmax=12, firstState="None")

## replacing "endobs" with NAs
mysts[mysts=="endobs"] <- NA
seq <- seqdef(mysts)
seqiplot(seq)

我们看到图中两个结果状态序列的长度不同。