swSummary: Summary of Response/Outcome for Stepped Wedge Cluster...

Description Usage Arguments Details Value Author(s) References Examples

Description

swSummary returns the mean, sum, and number of non-missing values for the response/outcome variable of interest for each cluster at each time point from a SW CRT.

Usage

1
2
swSummary(response.var, tx.var, time.var, cluster.var, data, 
type="mean", digits=16, fcn.Call=FALSE)

Arguments

response.var

numeric(vector): Response (Outcome) variable.

tx.var

numeric(vector): Treatment (Predictor of Interest) variable. Typically, 0=placebo, 1=intervention, values between 0 and 1 correspond to fractional treatment/intervention effects, and values greater than 1 correspond to other treatment options.

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 individual is from.

data

An optional data frame containing (at least) the response, treatment (tx), time, and cluster variables.

type

character (scalar): Specify which summary measure is of interest from "mean", "sum", and "n". (Note: The default returns "mean" as the summary measure of response. Note that all summary measures may not be scientifically relevant in every situation.)

digits

integer (scalar): Number of places right of the decimal. The default value is 16.

fcn.Call

logical: Only TRUE when calling swSummary from within swPlot. The default is FALSE.

Details

Returns a list containing a matrix of dimension length(unique(data$cluster)) by length( unique(data$time)) that summarizes data$response for specified type. Either the mean, sum, or the number of non-missing data$response values may be requested using type. dimnames of the matrix correspond to the unique values of cluster and time. Note that the stepping pattern in the data may be obtained by specifying the treatment variable name as the response and type = "mean".

Value

numeric (list): swSummary returns a list containing the following

type

One of user-specified options "mean", "sum", or "n".

swDsn

The SW design.

swDsn.unique.clusters

The unique clusters (i.e., rows) SW design.

n.waves

Number of waves.

clusters

Clusters per wave.

n.clusters

Total number of clusters.

time.at.each.wave

Time at each wave.

total.time

Total time points.

response.cluster

numeric (matrix): Response variable summarized according to type for all clusters, with dimension length(data$cluster) by length(unique(data$time)).

response.wave

numeric (matrix): Response variable summarized according to type, for all waves (all clusters of a particular wave are combined), with dimension length( unique(data$cluster)) by length(unique(data$time)).

Author(s)

James P Hughes and Navneet R Hakhu

References

Hussey MA, Hughes JP. Design and analysis of stepped wedge cluster randomized trials. Contemporary Clinical Trials 2007;28:182-191.

Examples

 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
38
39
library(swCRTdesign)
# Example 1 (Generating SW CRT data)
# (binary response with 1 missing value, 5 clusters, 4 time points)

n.Ex1 <- 120
p0.Ex1 <- 0.05
clusters.Ex1 <- c(2,2,1)
dsn.Ex1 <- swDsn( clusters=clusters.Ex1 )
time.Ex1 <- c(1:dsn.Ex1$total.time)*4 - 4
response.Ex1 <- rbinom(n.Ex1 * dsn.Ex1$n.clusters * dsn.Ex1$total.time, 1, p0.Ex1)
response.Ex1[1] <- NA
tx.Ex1 <- as.vector( apply( dsn.Ex1$swDsn, 1, function(z){rep(z, n.Ex1)}) )
time.Ex1 <- rep( time.Ex1, n.Ex1 * dsn.Ex1$n.clusters )
cluster.Ex1 <- rep( 1:dsn.Ex1$n.clusters, each=n.Ex1 * dsn.Ex1$total.time )
data.Ex1 <- data.frame(response.Ex1, tx.Ex1, time.Ex1, cluster.Ex1)

## Example 1 (type="mean", by cluster and by wave)
swSummary.Ex1.mean <- swSummary(response.Ex1, tx.Ex1, time.Ex1, cluster.Ex1, 
data=data.Ex1, type="mean", digits=3)

swSummary.Ex1.mean$response.cluster

swSummary.Ex1.mean$response.wave

# Example 1 (type="sum", by cluster and by wave)
swSummary.Ex1.sum <- swSummary(response.Ex1, tx.Ex1, time.Ex1, cluster.Ex1, 
data=data.Ex1, type="sum")

swSummary.Ex1.sum$response.cluster

swSummary.Ex1.sum$response.wave

## Example 1 (type="n", by cluster and by wave)
swSummary.Ex1.n <- swSummary(response.Ex1, tx.Ex1, time.Ex1, cluster.Ex1, 
data=data.Ex1, type="n")

swSummary.Ex1.n$response.cluster

swSummary.Ex1.n$response.wave

swCRTdesign documentation built on Oct. 30, 2019, 11:24 a.m.