Description Usage Arguments Details Value Author(s) See Also Examples
Produces plots similar to event charts, with the additional option to include a 'state' variable (i.e., a time-varying variable), the values of which are displayed as line segments with different colors. The plots can be used to visualize associations between states and events. Furthermore, useful strategies for the vertical alignment of subjects are included in the function.
1 2 3 4 5 6 7 8 9 10 11 12 | SEchart(data, idvar, timevar.start, timevar.stop, statevar = NULL,
eventvar = NULL, eventtime= NULL, srt1 = NULL, srt2 = NULL,
srt3 = NULL, srt4 = NULL, ord.ud = NULL, stratvar = NULL,
xlim = NULL, xlab = "Time", ylim = NULL, ylab = NULL,
grd = FALSE, grd.col = "grey", grd.lty = "dashed", idnum = 1,
idnum.col = "black", idnum.cex = 1, l.base.col = "grey",
l.base.lwd = 1, lend = 1, l.state.col = "pal.heat.rev",
l.state.lwd = 3, main = "SEchart", bg = "white", legnd = TRUE,
legnd.x = "bottomright", legnd.y = NULL, legnd.cex = 1,
legnd.txt.round = 2, legnd.bg = "white", strat.cex = 1,
strat.txt = NULL, strat.bg.col = "lightgrey", pch = NULL,
p.col = NULL, p.cex = 1, p.lwd = 1, return.output = FALSE)
|
data |
Data frame, consisting of data collected on multiple time points, in 'long' format. |
idvar |
Name of the variable in |
timevar.start |
Name of the variable in |
timevar.stop |
Name of the variable in |
statevar |
Name of the variable in |
eventvar |
Name(s) of the variable(s) in |
eventtime |
Vector of the same length as |
srt1 |
Specifies the sorting strategy used on the first level. See Details for the available options. If left unspecified, subjects are sorted only on |
srt2 |
Similar to |
srt3 |
Similar to |
srt4 |
Similar to |
ord.ud |
Vector of unique values in |
stratvar |
Name of numerical variable in |
xlim |
Limits of the X-axis of the plot. |
xlab |
The label used for the X-axis. |
ylim |
Limits of the Y-axis of the plot. |
ylab |
The label used for the Y-axis. If left unspecified, |
grd |
Logical. Should vertical grid lines be plotted? |
grd.col |
Color of the grid lines. |
grd.lty |
Line type used for the grid lines. See |
idnum |
Specifies whether and where ID numbers should be located. |
idnum.col |
Color used for the ID-numbers. |
idnum.cex |
Numerical value giving the amount by which the ID-numbers should be magnified relative to the default. |
l.base.col |
Color used for the line indicating the total time of follow-up. |
l.base.lwd |
Numerical value specifying the width of the line indicating the total time of follow-up. |
lend |
Line end style. See |
l.state.col |
Either a string specifying a color palette (see Details), or a vector of length |
l.state.lwd |
Numerical value specifying the width of the lines that are used to indicate the states. |
main |
Title of the chart. |
bg |
Background color of the chart. |
legnd |
Logical. Should a legend be included? |
legnd.x |
X coordinates of the legend. |
legnd.y |
Y coordinates of the legend. |
legnd.cex |
Numerical value giving the amount by which the text in the legend should be magnified relative to the default. |
legnd.txt.round |
Integer value specifying the number of decimals to which the values of |
legnd.bg |
Background color of the legend. |
strat.cex |
Numerical value giving the amount by which the text used to indicate the |
strat.txt |
Vector with user specified text to indicate |
strat.bg.col |
Color of the bars used to stratify the chart according to |
pch |
Vector of |
p.col |
Vector of length |
p.cex |
Numerical value giving the amount by which the points used to indicate the event(s) should be magnified relative to the default. |
p.lwd |
Numerical value specifying the line width of the points used to indicate the event(s). |
return.output |
Logical. Should the function return information on the used ordering and graphical options? |
srt1
through srt4
are used to vertically sort the subjects in the plot. Options are:
"start.time"
Sorts the subjects by their start time.
"end.time"
Sorts the subjects by their end time.
"tot.time"
Sorts the subjects by their total duration of follow-up time.
"midpoint.time"
Sorts the subjects by their midpoint follow-up time.
"min.state"
Sorts the subjects by their minimum observed level of statevar
.
"max.state"
Sorts the subjects by their maximum observed level of statevar
.
"first.state"
Sorts the subjects by the level of statevar
that was observed on first measurement.
"last.state"
Sorts the subjects by the level of statevar
that was observed on last measurement.
"average.state"
Sorts the subjects by their average observed level of statevar
per unit of time.
"sum.(eventname)"
Sorts the subjects by the sum of the number of an event. Replace (eventname) with the name of the event as specified in eventvar
(without brackets or quotation marks).
"tf.(eventname)"
Sorts the subjects by whether the subject experienced an event or not. Replace (eventname) with the name of the event as specified in eventvar
(without brackets or quotation marks).
"time.(eventname)"
Sorts the subjects by the time of the first occurence of an event. Replace (eventname) with the name of the event as specified in eventvar
(without brackets or quotation marks).
Color palette options for l.state.col
are "pal.rainbow"
, "pal.topo"
, "pal.terrain"
, "pal.heat"
, "pal.cm"
, "pal.topo"
and "pal.gray"
. Adding .rev
(e.g. "pal.heat.rev"
) reverses the colors. See rainbow
and gray.colors
.
If return.output == TRUE
, a list with objects $ord.id
, $col.statevar
, and $p.inf
.
$ord.id
A vector indicating the used ordering of the subjects.
$col.statevar
A matrix with rows specifying the colors used for every level of statevar
.
$p.inf
A matrix with rows specifying the events and the corresponding values used for pch
, p.col
, p.lwd
and p.cex
.
Rutger M. van den Bor, Willem M. van der Wal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #Example using aids dataset from package JM
library(JM)
data(aids)
#Assign class numeric to aids$patient and aids$prevOI (class factor is not allowed in function)
aids$patient <- as.numeric(aids$patient)
aids$prevOI.2 <- as.numeric(aids$prevOI)
#Categorize CD4
aids$CD4.cat <- cut(aids$CD4, breaks=10, labels=FALSE)
#For better results, use pdf()
# pdf(file = "PATH/SEchart_aids.pdf", width = 12, height = 20)
#Create SEchart for subset of aids data, with event=death and state=CD4.
#Sort subjects by (1) occurrence of event "death" and (2) their observed end
#time. The chart is stratified by "aids diagnosis at study entry" (variable
#"prevOI.2").
SEchart(data=aids[aids$patient <= 100,],
idvar="patient",
timevar.start = "start",
timevar.stop = "stop",
statevar="CD4.cat",
eventvar="event",
eventtime="end",
srt1="tf.event",
srt2="end.time",
stratvar="prevOI.2",
strat.txt=c("No aids diagnosis at study entry", "Aids diagnosis at study entry"),
l.state.col="pal.heat",
idnum.cex=0.5,
legnd = TRUE,
)
#Close the graphics device to save as pdf
# graphics.off()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.