
Last chance! 50% off unlimited learning
Sale ends in
Plots multiple ordinal sequences in a
# S3 method for default
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)
a numeric
or factor
vector for the x
axis, e.g. time.
an ordered
factor vector for the y
axis.
a factor
vector that identifies the subject,
i.e., allocates elements in x
and y
to the subject
i.e. observation unit.
a numeric vector of weights of length equal the number of subjects.
a numeric
or factor
vector of group
memberships of length equal the number of subjects. When specified,
one panel is generated for each distinct membership value.
control parameters produced by otsplot_control
,
such as line colors or the scale of translation zones.
an otsplot_filter
object which defines line
coloring options. See details.
title and axis labels for the plot.
the x limits c(x1, x2)
resp. y limits
(y1,y2)
.
additional undocumented arguments.
expansion factor for the squared symbols.
expansion factor for line widths. The expansion is relative to the size of the squared symbols.
color palette vector for line coloring.
Color for ordinal time-series filtered-out by the
filter
specification in otsplot
.
an integer specifying which seed should be set at the beginning.
line ordering. Either "background"
or
"foreground"
.
Method to connect simultaneous elements with the
preceding and following ones. Either "upwards"
(default) or
"downwards"
.
expansion factor for the translation zones.
expansion factor for the borders of translation zones.
the fill color for translation zones.
the border color for translation zones.
fontsize of titles in stripes that appear
when a groups
vector is assigned.
color of strips that appear when a groups
vector is assigned.
an integer vector c(nr, nc)
specifying the
number of rows and columns of the panel arrangement when the
groups
argument is used.
a numeric vector c(bottom, left, top, right)
specifying the space on the margins of the plot. See also
the argument mar
in par
.
logical scalar. Whether the viewport tree should be popped before return.
logical scalar. Whether grid.newpage()
should be
called previous to the plot.
maximal number of iteration for the algorithm that computes the translation arrangement.
character string. Defines the filtering
function. Available are "minfreq"
, "cumfreq"
and
"linear"
.
numeric scalar between 0 and 1. The frequency threshold
for the filtering methods "minfreq"
and "cumfreq"
.
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.
Buergin, 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.
# NOT RUN {
## ------------------------------------------------------------------- #
## 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)
# }
Run the code above in your browser using DataLab