seqsplot | R Documentation |
High level plot function for state sequence objects that produces survival curves of states in sequences. Usage is similar to the generic seqplot
function of TraMineR, with a special handling of the group
argument when per.state=TRUE
is included in the ...
list.
seqsplot(seqdata, group = NULL, main = "auto",
cpal = NULL, missing.color = NULL,
ylab = NULL, yaxis = "all",
xaxis = "all", xtlab = NULL,
cex.axis = 1, with.legend = "auto", ltext = NULL, cex.legend = 1,
use.layout = (!is.null(group) | with.legend != FALSE), legend.prop = NA,
rows = NA, cols = NA, which.states = NULL,
title, cex.plot, withlegend, axes, ...)
seqdata |
State sequence object created with the |
group |
Grouping variable of length equal to the number of sequences. When |
main |
Character string. Title for the graphic. Default is |
cpal |
Vector. Color palette used for the states or the groups when |
missing.color |
Color for representing missing values inside the sequences. By default, this color is taken from the |
ylab |
Character string or vector of strings. Optional label of the y-axis. If a vector, y-axis label of each group (or state) level. If set as |
yaxis |
Logical or one of |
xaxis |
Logical or one of |
xtlab |
Vector of length equal to the number of columns of |
cex.axis |
Real. Axis annotation magnification. See |
with.legend |
Character string or logical. Defines if and where the legend of the state colors is plotted. The default value |
ltext |
Vector of character strings of length and order corresponding to |
cex.legend |
Real. Legend magnification. See |
use.layout |
Logical. Should |
legend.prop |
Real in range [0,1]. Proportion of the graphic area devoted to the legend plot when |
rows , cols |
Integers. Number of rows and columns of the plot panel when |
which.states |
Vector of short state names. List of the states for which survival curves should be plotted. |
title |
Deprecated. Use |
cex.plot |
Deprecated. Use |
withlegend |
Deprecated. Use |
axes |
Deprecated. Use |
... |
arguments to be passed to the function called to produce the appropriate statistics and the associated plot method (see details), or other graphical parameters. For example |
This is a specific version of seqplot
for type="s". It implements a dedicated handling of the group variable passed as group
argument when per.sate=TRUE
is included in the ...
list.
Invalid or non observed states are removed the list given as which.states
argument. When which.states = NULL
, which.states
will be defined as the list of states present in the data.
When per.sate=TRUE
, a distinct plot is generated for each state in the which.states
list and, when a grouping variable is provided, the survival curves of all groups are plotted in each plot.
When per.state=FALSE
, a distinct plot is generated for each group and the survival curves of all states listed as which.states
are plotted in each plot.
Gilbert Ritschard (based on TraMineR seqplot function)
Gabadinho, A., G. Ritschard, N. S. Müller and M. Studer (2011). Analyzing and Visualizing State Sequences in R with TraMineR. Journal of Statistical Software 40(4), 1-37.
plot.stslist.surv
, seqsurv
, seqplot
,
## ======================================================
## Creating state sequence objects from example data sets
## ======================================================
data(biofam)
biofam.lab <- c("Parent", "Left", "Married", "Left+Marr",
"Child", "Left+Child", "Left+Marr+Child", "Divorced")
biofam.short <- c("P","L","M","LM","C","LC","LMC","D")
sple <- 1:200 ## only the first 200 sequences
seqstatl(biofam[sple,10:25]) ## state 4 not present
biofam <- biofam[sple,]
biofam.seq <- seqdef(biofam[,10:25], alphabet=0:7, states=biofam.short, labels=biofam.lab)
## defining two birth cohorts
biofam$wwii <- factor(biofam$birthyr > 1945,
labels=c("Born Before End of Word War II","Born After Word War II"))
## ==============================
## Plots of state survival curves
## ==============================
seqsplot(biofam.seq) ## all states, no group
seqsplot(biofam.seq, group=biofam$wwii, lwd=2) ## all states for each group
seqsplot(biofam.seq, group=biofam$wwii, per.state=TRUE, lwd=2) ## groups for each state
## For a selection of states only
seqsplot(biofam.seq, group=biofam$wwii, which.states= c('LM'), lwd=2)
## changing default color
seqsplot(biofam.seq, group=biofam$wwii, which.states= c('LM'),
cpal="orange", lwd=2)
seqsplot(biofam.seq, group=biofam$wwii, which.states= c('LM','LMC'),
cpal=c("orange","brown"), lwd=2)
seqsplot(biofam.seq, group=biofam$wwii, which.states= c('LM','LMC'), per.state=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.