seqedplot: Graphical representation of a set of events sequences.

View source: R/seqedplot.R

seqedplotR Documentation

Graphical representation of a set of events sequences.

Description

This function provides two ways to represent a set of events. The first one (type="survival") plots the survival curves of the first occurrence of each event. The second one (type="hazard") plots the mean counts of each event in the successive periods.

Usage

seqedplot(seqe,
    group=NULL, breaks=20, ages=NULL,
    main="auto", type="survival", ignore=NULL,
	with.legend="auto",cex.legend=1,
    use.layout=(!is.null(group) | with.legend!=FALSE), legend.prop=NA,
    rows=NA, cols=NA,
    xaxis="all", xlab="time",
    yaxis="all",
    ylab=ifelse(type=="survival", "survival probability", "mean number of events"),
    cpal=NULL,
    title, withlegend, axes, ...)

Arguments

seqe

an event sequence object as defined by the seqecreate function.

group

Plots one plot for each level of the factor given as argument.

breaks

Number of breaks defining a period.

ages

Two numeric values representing minimum and maximum ages to be represented.

main

String. Title of the graphic. Default is "auto", i.e., group levels. Set as NULL to suppress titles.

type

String. Type of One of "survival" or "hazard". If type="survival", survival curves of the first occurrence of each event are plotted. If type="hazard", mean numbers of each event in the successive periods are plotted.

ignore

Character vector. An optional list of events that should not be plotted.

with.legend

Logical or string. Defines if and where the legend of the state colors is plotted. The default value "auto" sets the position of the legend automatically. Other possible values are "right" or FALSE. Obsolete value TRUE is equivalent to "auto".

cex.legend

expansion factor for setting the size of the font for the labels in the legend. The default value is 1. Values lesser than 1 will reduce the size of the font, values greater than 1 will increase the size.

use.layout

if TRUE, layout is used to arrange plots when using the group option or plotting a legend. When layout is activated, the standard par(mfrow=....) for arranging plots does not work. With with.legend=FALSE and group=NULL, layout is automatically deactivated and par(mfrow=....) can be used.

legend.prop

proportion of the graphic area used for plotting the legend when use.layout=TRUE and with.legend=TRUE. Default value is set according to the place (bottom or right of the graphic area) where the legend is plotted. Values from 0 to 1.

rows

optional arguments to arrange plots when use.layout=TRUE.

cols

optional arguments to arrange plots when use.layout=TRUE.

xaxis

Logical or one of "all" and "bottom". If set as TRUE or "all" (default value) x-axes are drawn on each plot in the graphic. If set as "bottom" and group is used, x-axes are drawn under the plots of the bottom panel only. If FALSE, no x-axis is drawn.

yaxis

Logical or one of "all" or "left". If set as TRUE or "all" (default value) y-axes are drawn on each plot in the graphic. If "left" and group is used, the y-axis is displayed on plots of the left panel only. If FALSE no y-axis is drawn.

xlab

an optional label for the x-axis. If set to NA, no label is drawn.

ylab

an optional label for the y-axis. If set to NA, no label is drawn. Can be a vector of labels by group level.

cpal

Color palette used for the events. If NULL, a new color palette is generated.

title

Deprecated. Use main instead.

withlegend

Deprecated. Use with.legend instead.

axes

Deprecated. Use xaxis instead.

...

Additional arguments passed to plot.survfit, lines.survfit, and/or legend.

Author(s)

Matthias Studer

References

Studer, M., Müller, N.S., Ritschard, G. & Gabadinho, A. (2010), "Classer, discriminer et visualiser des séquences d'événements", In Extraction et gestion des connaissances (EGC 2010), Revue des nouvelles technologies de l'information RNTI. Vol. E-19, pp. 37-48.

Examples

data(actcal.tse)
actcal.tse <- actcal.tse[1:200,]
iseq <- unique(actcal.tse$id)
nseq <- length(iseq)
data(actcal)
actcal <- actcal[rownames(actcal) %in% iseq,]
actcal.seqe <- seqecreate(actcal.tse)
seqelength(actcal.seqe) <- rep(12, nseq)
seqedplot(actcal.seqe, type="hazard", breaks=6, group=actcal$sex, lwd=3)
seqedplot(actcal.seqe, type="survival", group=actcal$sex, lwd=3)

TraMineRextras documentation built on Sept. 11, 2024, 6:52 p.m.