Plot the predicted probability of each state in a sequence
# S4 method for PSTf,stslist
pqplot(object, data, cdata, L, stcol, plotseq=FALSE,
ptype="b", cex.plot=1, space=0,
measure="prob", pqmax, seqscale, ...)
a probabilistic suffix tree, i.e., an object of class "PSTf"
as returned by the pstree
, prune
or tune
function.
a sequence object, i.e., an object of class 'stslist'
as created by TraMineR seqdef
function, either subsetted with the index of the sequence to predict or containing one sequence.
Not implemented yet.
integer. Maximal context length for sequence prediction. This is the same as pruning the PST by removing all nodes of depth<L before prediction.
character. Color to use to plot the prediction qualities.
logical. If TRUE, the sequence is displayed separately, and the prediction plot is plotted above.
character. Type of plot, either 'b'
for barplot or 'l'
for line.
numeric. Expansion factor for setting the size of the font for the axis labels and names. The default value is 1. Values lesser than 1 will reduce the size of the font, values greater than 1 will increase the size.
numeric. Space separating each state in the plot.
character. Measure used for prediction quality. Either 'prob'
or 'logloss'
.$
numeric. Maximum coordinate for the prediction quality plot, i.e. the max of the y axis.
numeric. If plotseq=TRUE
, width of the bar representing the sequence as a proportion of the y axis range.
optional graphical parameters to be passed to the plot function.
Alexis Gabadinho
The pqplot()
function displays either the predicted probabilities or the log-loss for each position of a single sequence as a series of barplots. For more details, see Gabadinho 2016.
Gabadinho, A. & Ritschard, G. (2016) Analyzing State Sequences with Probabilistic Suffix Trees: The PST R Package. Journal of Statistical Software, 72(3), 1-39.
data(s1)
s1 <- seqdef(s1)
S1 <- pstree(s1, L=3)
z <- seqdef("a-b-a-a-b")
pqplot(S1, z)
pqplot(S1, z, measure="logloss", plotseq=TRUE)
Run the code above in your browser using DataLab