Debian Codegraph @

man/expand.covs.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/expand.covs.R
3 \name{expand.covs}
4 \alias{expand.covs}
5 \alias{expand.covs.default}
6 \title{Expand covariates in competing risks dataset in stacked format}
7 \usage{
8 expand.covs(data, ...)
9 }
10 \arguments{
11 \item{data}{An object of class \code{"msdata"}, such as output by
12 \code{\link{msprep}}}
13
14 \item{...}{Further arguments to be passed to or from other methods. They
15 are ignored in this function.}
16 }
17 \value{
18 An data frame object of the same class as the data argument,
19 containing the design matrix for the type-specific covariates, either on its
20 own (\code{append}=\code{FALSE}) or appended to the data
21 (\code{append}=\code{TRUE}).
22 }
23 \description{
24 Given a competing risks dataset in stacked format, and one or more
25 covariates, this function adds type-specific covariates to the dataset. The
26 original dataset with the type-specific covariates appended is returned.
27 }
28 \details{
29 Type-specific covariates can be used to analyse separate effects on all
30 event types in a single analysis based on a stacked data set (Putter, Fiocco
31 & Geskus (2007) and Geskus (2016)). It is only unambiguously defined for
32 numeric covariates or for explicit codings. Rows that contain the data for
33 that specific event type have the value copied from the original covariate
34 in case it is numeric. In all other rows it has the value zero. If the
35 covariate is a factor, it will be expanded on the design matrix given by
36 \code{\link[stats:model.matrix]{model.matrix}}. For standard "treatment
37 contrasts" this means that dummy variables are created. If the covariate is
38 a factor, the column name combines the name of the covariate with the
39 specific event type. If \code{longnames}=\code{TRUE}, both parts are
40 intersected by the specific labels in the coding. Missing values in the
41 basic covariates are allowed and result in missing values in the expanded
42 covariates.
43 }
44 \examples{
45
46 # small data set in stacked format
47 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),
48 x1=c(1,1,2,2,2,2),x2=c(3,3,2,2,1,1))
49 tg$x1 <- factor(tg$x1,labels=c("male","female"))
50 # expanded covariates
51 expand.covs(tg,covs=c("x1","x2"))
52 expand.covs(tg,covs=c("x1","x2"),longnames=TRUE)
53 expand.covs(tg,covs=c("x1","x2"),append=FALSE)
54
55 }
56 \references{
57 Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics:
58 Competing risks and multi-state models. \emph{Statistics in Medicine}
59 \bold{26}, 2389--2430.
60
61 Geskus, Ronald B. (2016). \emph{Data Analysis with Competing Risks and
62 Intermediate States.} CRC Press, Boca Raton.
63 }
64 \seealso{
65 \code{\link{expand.covs.msdata}}.
66 }
67 \author{
68 Ronald Geskus and Hein Putter \email{[email protected]}
69 }
70 \keyword{datagen}