Missing states in a set of sequences are imputed by using the probability distributions stored in a probabilistic suffix tree.
1 2 
object 
a probabilistic suffix tree, i.e., an object of class 
data 
a sequence object, i.e., an object of class 
method 
character. If 
A probabilistic suffix tree (PST) can be used to impute missing states in sequences built on the same alphabet. When a missing state occurs in a sequence the procedure searches in the PST for the context preceding the missing state and impute the state according to the conditional distribution associated with the context. The imputation can be done either randomly (method="prob") or with the state having the highest probability. However, more sophisticated modelling taking account of the non response mechanism could be required for imputing missing states. For more details, see Gabadinho 2016.
A sequence object (of class stslist
) containing original sequences in data
with missing states imputed.
Alexis Gabadinho
Gabadinho, A. & Ritschard, G. Analyzing State Sequences with Probabilistic Suffix Trees: The PST R Package. Journal of Statistical Software, 2016, 72(3), 139.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  ## Loading the SRH.seq sequence object
data(SRH)
## working with a subsample of 500 sequences
## to reduce computing time
subs < sample(nrow(SRH.seq), size=500)
SRH.sub.seq < SRH.seq[subs,]
## Learning the model (missing state is not included)
SRH.pst.L10 < pstree(SRH.sub.seq, nmin=2, ymin=0.001)
## Pruning
C99 < qchisq(0.99,51)/2
SRH.pst.L10.C99 < prune(SRH.pst.L10, gain="G2", C=C99)
## Imputing missing values in the SRH sequences
SRH.sub.iseq < impute(SRH.pst.L10, SRH.sub.seq, method="prob")
## locating sequences having missing values
## in sequence object missing states are identified by '*'
have.miss < which(rowSums(SRH.sub.seq=='*')>0)
## plotting non imputed vs imputed sequence
## (first 10 sequences in the set)
par(mfrow=c(1,2))
seqiplot(SRH.sub.seq[have.miss,], withlegend=FALSE)
seqiplot(SRH.sub.iseq[have.miss,], withlegend=FALSE)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.