Description Usage Arguments Examples
Transform data.frame in to package:etm etm
(long) format.
1 |
survData |
|
type |
Model type. |
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 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (survData, type)
{
tvdata <- tvCox(survData, type = type)
tvdata <- tvdata[order(tvdata$originf, decreasing = TRUE),
]
numCases.inf <- sum(tvdata$originf == 1)
numCases.mix <- sum(tvdata$originf == 0)
id <- tvdata$id
entry <- tvdata$tstart
exit <- tvdata$tstop
from <- c(rep(0:1, length.out = numCases.inf), rep(0, numCases.mix))
to <- c(rep(1:2, length.out = numCases.inf), rep(2, numCases.mix))
to2 <- tvdata$disch + to
rinf <- 1:numCases.inf
rmix <- (max(rinf) + 1):nrow(tvdata)
rcens.inf <- tvdata$inf[rinf] == 1 & (tvdata$disch[rinf] +
tvdata$death[rinf]) == 0
rcens.mix <- (tvdata$disch[rmix] + tvdata$death[rmix]) ==
0
rcens <- c(rcens.inf, rcens.mix)
to[rcens] <- to2[rcens] <- "cens"
age <- tvdata$age
agegr <- tvdata$agegr
sex <- tvdata$sex
msm.data <- data.frame(id, from, to, entry, exit)
msm.data <- msm.data[!is.na(msm.data$exit), ]
msm.data
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.