基于只有 1 个状态的上下文预测条件概率

Predicting conditional probabilities based on contexts with only 1 state

似乎PST无法预测由单个状态组成的上下文之后的下一个状态的条件概率,例如EX-EX

考虑这段代码:

# Load libraries
library(RCurl)
library(TraMineR)
library(PST)

# Get data
x <- getURL("https://gist.githubusercontent.com/aronlindberg/08228977353bf6dc2edb3ec121f54a29/raw/c2539d06771317c5f4c8d3a2052a73fc485a09c6/challenge_level.csv")
data <- read.csv(text = x)

# Load and transform data
data <- read.table("thread_level.csv", sep = ",", header = F, stringsAsFactors = F)

# Create sequence object
data.seq <- seqdef(data[2:nrow(data),2:ncol(data)], missing = NA, right= NA, nr = "*")

# Make a tree
S1 <- pstree(data.seq, ymin = 0.05, L = 6, lik = TRUE, with.missing = TRUE)

# Mine the context
context <- seqdef("EX-EX")
p_context <- predict(S1.p1, context, decomp = F, output = "prob")

context <- seqdef("EX-EX") 产生:

[>] 1 distinct states appear in the data: 
     1 = EX
Error: 
 [!] alphabet contains only one state

表示predict()无法执行

如何根据只有 1 个状态且可能重复多次的上下文预测下一个状态的条件概率?

这是 seqdef 的一个问题,自版本 1.8-12 以来已得到修复。

这是我用 TraMineR 1.8-13

得到的结果
> context <- seqdef("EX-EX")
 [>] 1 distinct states appear in the data: 
     1 = EX
 [>] state coding:
       [alphabet]  [label]  [long label] 
     1  EX          EX       EX
 [>] 1 sequences in the data set
 [>] min/max sequence length: 2/2
> p_context <- predict(S1, context, decomp = F, output = "prob")
 [>] 1 sequence(s) - min/max length: 2/2
 [>] max. context length: L=6
 [>] found 2 distinct context(s)
 [>] total time: 0.019 secs
> p_context
           prob
[1] 0.000476372

请注意,我将您未定义的 S1.p1 替换为 S1