Does the PST
package always display contexts from right to left?
In the query()
function we use a string to represent a context. If I'm assuming that the context is specified from right to left (as it seems to be in the print()
and cmine()
functions), and I'm interested in the sequence A->B->C
, then should I query for:
query(S1.p1, "C-B-A")
?
Further, in the predict()
function, we use seqdef()
to define sequences to predict for. Does that mean I should specify them from left to right, as TraMineR usually does?
x <- seqdef("A-B-C)
predict(S1.p1, x)
?
In a probabilistic suffix tree (PST), a branch defines a suffix from right to left when we start reading it from the root. At the first level you have the last element of the suffix, at level 2 you have the element preceding the last element, etc. The printed tree is displayed with the root on the left side and is expanded from left to right. Nevertheless, the suffixes displayed in a node of the print outcome should be read naturally from left to right. E.g, a node a-b-c
means a suffix with c
at the end. Such a node is obtained from the node b-c
by adding a
on the left.
The same holds for the outcome of cmine
. For each found context, e.g. a-b-c
, cmine
gives the probability to get each of the possible state immediately after the context, i.e., after c
in the example.
In summary, sequences and contexts are always displayed from left to right, even though contexts are built from right to left.
So, if you want query for the sequence A->B->C
, just use query(S1.p1, "A-B-C")
. Likewise, to predict a specific sequence with predict
, define the sequence naturally from left to right.