expand.covs {mstate}R Documentation

Expand covariates in competing risks dataset in stacked format

Description

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.

Usage

## Default S3 method:
expand.covs(data, covs, append=TRUE, longnames=FALSE, event.types="failcode",...)

Arguments

data

A data frame in stacked format for competing risks analyses, such as generated by crprep.

covs

A character vector containing the names of the covariates in data to be expanded.

append

Logical value indicating whether or not the design matrix for the expanded covariates should be appended to the data (default=TRUE).

longnames

Logical value indicating whether or not the labels are to be used for the names of the categorical expanded covariates. In case of FALSE (the default) numbers from 1 up to the number of contrasts are used; if the covariate is dichotomous, the number is left out.

event.types

Character value with the name of the column that contains the event type information.

...

Further arguments to be passed to or from other methods. They are ignored in this function.

Details

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.

Value

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).

Author(s)

Ronald Geskus and Hein Putter H.Putter@lumc.nl

References

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.

See Also

expand.covs.msdata.

Examples

# 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)

[Package mstate version 0.2.11 Index]