2017-01-27 5 views
2

은 단일 상태로 구성된 문맥 다음 상태의 다음 조건의 조건부 확률을 예측할 수없는 것으로 보인다.오직 하나의 상태를 갖는 문맥에 기초하여 조건부 확률을 예측 함

# 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() 실행될 수 없다는 것을 의미

EX-EX이 코드를 고려한다.

여러 상태로 반복 될 수있는 상태가 하나 뿐인 컨텍스트를 기반으로 다음 상태의 조건부 확률을 예측하려면 어떻게해야합니까?

답변

2

이것은 012-의 문제로 버전 1.8-12에서 수정되었습니다. 여기

내가 S1로 정의되지 않은 S1.p1를 대체 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 

참고로 얻을 것입니다.

+0

동일한 마커를 반복하는 컨텍스트에서 사용할 수 있습니다 (예 : 'EX-EX'. 그러나 마커 길이가 1 인 컨텍스트는 'EX'는 여전히 계산되지 않지만 여기서 문제는'seqdef()'가 아닌'predict()'에있는 것처럼 보입니다. – histelheim

+1

실제로는 시퀀스가 ​​아닌'EX'의 경우, 그 확률은 단순히 발생 확률입니다. 자료. 예를 들어'seqstatf (data.seq) [ "EX", 2]/100'과 같이 얻을 수 있습니다. – Gilbert

관련 문제