swPlot {swCRTdesign} | R Documentation |
Plot of Mean Response/Outcome for Stepped Wedge Cluster Randomized Trial (SW CRT)
Description
swPlot
returns plot of the mean response versus time based on waves and/or clusters from a SW CRT.
Usage
swPlot(response.var, tx.var, time.var, cluster.var, data, choose.mfrow=NULL,
by.wave=TRUE, combined.plot=TRUE, choose.xlab="Time", choose.main=NULL,
choose.pch=NULL, choose.cex=1, choose.tx.col=NULL, choose.tx.lty = c(2,1),
choose.ncol=2, xlim=NULL, ylim=NULL, choose.tx.pos="topright", choose.legend.pos="right")
Arguments
response.var |
numeric(vector): Response (Outcome) variable. |
tx.var |
numeric(vector): Treatment (Predictor of Interest) variable. Typically, 0=control, 1=intervention, and values greater than 1 correspond to other treatment levels. |
time.var |
integer(vector): Time (points) variable, corresponding to the time points when data were collected during the SW CRT. |
cluster.var |
integer(vector): Cluster (identification) variable, corresponding to the cluster where an observation is from. |
data |
An optional data frame containing (at least) the response, treatment (tx), time, and cluster variables. |
choose.mfrow |
numeric (vector): Choose |
by.wave |
logical: If |
combined.plot |
logical: If |
choose.xlab |
Choose |
choose.main |
Choose |
choose.pch |
Choose |
choose.cex |
Choose |
choose.tx.col |
Choose colors for different treatment options. Vector of two colors, corresponding to control and treatment groups, respectively. If |
choose.tx.lty |
Choose line types for different treatment options. Vector of two numbers for |
choose.ncol |
Choose number of columns for non-treatment legend. Standard |
xlim , ylim |
Vectors of length 2 giving x and y axis limits on plot. If NULL, minimum and maximum of summary time and response variables are used, respectively. |
choose.tx.pos |
Choose where to place treatment colors "legend". Standard |
choose.legend.pos |
Choose where to place the non-treatment legend. Standard |
Details
Returns a plot of the mean response versus time with a combination of by wave (TRUE
/ FALSE
) and combined plot (TRUE
/ FALSE
) from a SW CRT. See discussion of number of waves in help file for swSummary.
Author(s)
James P Hughes, Navneet R Hakhu, and Emily C Voldal
References
Hussey MA, Hughes JP. Design and analysis of stepped wedge cluster randomized trials. Contemporary Clinical Trials 2007;28:182-191.
Examples
library(swCRTdesign)
# Example 1
# Generate binary response with 5 clusters, 4 time points
data.Ex1 <- swSim(swDsn(c(2,2,1)),family=binomial(link="identity"), n=120,
mu0=0.25, mu1=0.30,time.effect=0, tau=0.05, gamma=.01)
# Example 1 (Mean Response vs Time, by.wave=TRUE, combined.plot=TRUE)
swPlot(response.var, tx.var, time.var, cluster.var, data.Ex1, by.wave=TRUE,
combined.plot=TRUE, choose.tx.pos="bottomright", choose.legend.pos="bottom")
# Example 2 (Mean Response vs Time, by.wave=TRUE, combined.plot=FALSE)
swPlot(response.var, tx.var, time.var, cluster.var, data.Ex1, by.wave=TRUE,
combined.plot=FALSE, choose.tx.pos="bottomright", choose.legend.pos="bottom")
# Example 3 (Mean Response vs Time, by.wave=FALSE, combined.plot=TRUE)
swPlot(response.var, tx.var, time.var, cluster.var, data.Ex1, by.wave=FALSE,
combined.plot=TRUE, ylim=c(0,0.6), choose.tx.pos="bottomright", choose.legend.pos="topleft")
# Example 4 (Mean Response vs Time, by.wave=FALSE, combined.plot=FALSE)
swPlot(response.var, tx.var, time.var, cluster.var, data.Ex1, by.wave=FALSE,
combined.plot=FALSE, choose.tx.pos="bottomright", choose.legend.pos="bottom")