expand.covs | R Documentation |
Given a competing risks dataset in stacked format, and one or more covariates, this function adds type-specific covariates to the dataset. The original dataset with the type-specific covariates appended is returned.
expand.covs(data, ...)
data |
An object of class |
... |
Further arguments to be passed to or from other methods. They are ignored in this function. |
Type-specific covariates can be used to analyse separate effects on all
event types in a single analysis based on a stacked data set (Putter, Fiocco
& Geskus (2007) and Geskus (2016)). It is only unambiguously defined for
numeric covariates or for explicit codings. Rows that contain the data for
that specific event type have the value copied from the original covariate
in case it is numeric. In all other rows it has the value zero. If the
covariate is a factor, it will be expanded on the design matrix given by
model.matrix
. For standard "treatment
contrasts" this means that dummy variables are created. If the covariate is
a factor, the column name combines the name of the covariate with the
specific event type. If longnames
=TRUE
, both parts are
intersected by the specific labels in the coding. Missing values in the
basic covariates are allowed and result in missing values in the expanded
covariates.
An data frame object of the same class as the data argument,
containing the design matrix for the type-specific covariates, either on its
own (append
=FALSE
) or appended to the data
(append
=TRUE
).
Ronald Geskus and Hein Putter H.Putter@lumc.nl
Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics: Competing risks and multi-state models. Statistics in Medicine 26, 2389–2430.
Geskus, Ronald B. (2016). Data Analysis with Competing Risks and Intermediate States. CRC Press, Boca Raton.
expand.covs.msdata
.
# small data set in stacked format
tg <- data.frame(time=c(5,5,1,1,9,9),status=c(1,0,2,2,0,1),failcode=rep(c("I","II"),3),
x1=c(1,1,2,2,2,2),x2=c(3,3,2,2,1,1))
tg$x1 <- factor(tg$x1,labels=c("male","female"))
# expanded covariates
expand.covs(tg,covs=c("x1","x2"))
expand.covs(tg,covs=c("x1","x2"),longnames=TRUE)
expand.covs(tg,covs=c("x1","x2"),append=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.