otsplot {vcrpart} | R Documentation |
Time-series plot for longitudinal ordinal data
Description
Plots multiple ordinal sequences in a x
(usually
time) versus y
(response variable) scatterplot. The sequences
are displayed by jittered frequency-weighted parallel lines.
Usage
## Default S3 method:
otsplot(x, y, subject, weights, groups,
control = otsplot_control(), filter = NULL,
main, xlab, ylab, xlim, ylim, ...)
otsplot_control(cex = 1, lwd = 1/4, col = NULL,
hide.col = grey(0.8), seed = NULL,
lorder = c("background", "foreground") ,
lcourse = c("upwards", "downwards"),
grid.scale = 1/5, grid.lwd = 1/2,
grid.fill = grey(0.95), grid.col = grey(0.6),
layout = NULL, margins = c(5.1, 4.1, 4.1, 3.1),
strip.fontsize = 12, strip.fill = grey(0.9),
pop = TRUE, newpage = TRUE, maxit = 500L)
otsplot_filter(method = c("minfreq", "cumfreq", "linear"), level = NULL)
Arguments
x |
a |
y |
an |
subject |
a |
weights |
a numeric vector of weights of length equal the number of subjects. |
groups |
a |
control |
control parameters produced by |
filter |
an |
main , xlab , ylab |
title and axis labels for the plot. |
xlim , ylim |
the x limits |
... |
additional undocumented arguments. |
cex |
expansion factor for the squared symbols. |
lwd |
expansion factor for line widths. The expansion is relative to the size of the squared symbols. |
col |
color palette vector for line coloring. |
hide.col |
Color for ordinal time-series filtered-out by the
|
seed |
an integer specifying which seed should be set at the beginning. |
lorder |
line ordering. Either |
lcourse |
Method to connect simultaneous elements with the
preceding and following ones. Either |
grid.scale |
expansion factor for the translation zones. |
grid.lwd |
expansion factor for the borders of translation zones. |
grid.fill |
the fill color for translation zones. |
grid.col |
the border color for translation zones. |
strip.fontsize |
fontsize of titles in stripes that appear
when a |
strip.fill |
color of strips that appear when a |
layout |
an integer vector |
margins |
a numeric vector |
pop |
logical scalar. Whether the viewport tree should be popped before return. |
newpage |
logical scalar. Whether |
maxit |
maximal number of iteration for the algorithm that computes the translation arrangement. |
method |
character string. Defines the filtering
function. Available are |
level |
numeric scalar between 0 and 1. The frequency threshold
for the filtering methods |
Details
The function is a scaled down version of the seqpcplot
function of the TraMineR package, implemented in the grid
graphics environment.
The filter
argument serves to specify filters to fade out less
interesting patterns. The filtered-out patterns are displayed in the
hide.col
color. The filter
argument expects an object
produced by otsplot_filter
.
otsplot_filter("minfreq", level = 0.05)
colors patterns with a
support of at least 5% (within a
group). otsplot_filter("cumfreq", level = 0.75)
highlight the 75% most frequent patterns (within
group). otsplot_filter("linear")
linearly greys out patterns with low support.
The implementation adopts a color palette which was originally generated by the colorspace package (Ihaka et al., 2013). The authors are grateful for these codes.
Value
otsplot
returns an object of class
otsplot
.
otsplot_control
returns an object of class
otsplot_control
and otsplot_filter
an object
of class otsplot_filter
. Both these object types are
specifically designed as input arguments of otsplot
.
Author(s)
Reto Burgin and Gilbert Ritschard
References
Burgin, R. and G. Ritschard (2014). A Decorated Parallel Coordinate Plot for Categorical Longitudinal Data, The American Statistician 68(2), 98–103.
Ihaka, R., P. Murrell, K. Hornik, J. C. Fisher and A. Zeileis (2013). colorspace: Color Space Manipulation. R package version 1.2-4. URL https://CRAN.R-project.org/package=colorspace.
Examples
## ------------------------------------------------------------------- #
## Dummy example:
##
## Plotting artificially generated ordinal longitudinal data
## ------------------------------------------------------------------- #
## load the data
data(vcrpart_1)
vcrpart_1 <- vcrpart_1[1:40,]
## plot the data
otsplot(x = vcrpart_1$wave, y = vcrpart_1$y, subject = vcrpart_1$id)
## using 'groups'
groups <- rep(c("A", "B"), each = nrow(vcrpart_1) / 2L)
otsplot(x = vcrpart_1$wave, y = vcrpart_1$y, subject = vcrpart_1$id,
groups = groups)
## color series with supports over 30%
otsplot(x = vcrpart_1$wave, y = vcrpart_1$y, subject = vcrpart_1$id,
filter = otsplot_filter("minfreq", level = 0.3))
## highlight the 50% most frequent series
otsplot(x = vcrpart_1$wave, y = vcrpart_1$y, subject = vcrpart_1$id,
filter = otsplot_filter("cumfreq", level = 0.5))
## linearly grey out series with low support
otsplot(x = vcrpart_1$wave, y = vcrpart_1$y, subject = vcrpart_1$id,
filter = otsplot_filter("linear"))
## subject-wise plot
otsplot(x = vcrpart_1$wave, y = vcrpart_1$y,
subject = vcrpart_1$id, groups = vcrpart_1$id)