View source: R/DiscSurvEstimationCR.R
| estCumInc | R Documentation |
Estimates the cumulative incidence function of a discrete time competing risks model given covariates P(T <= t, event = k | x).
estCumInc(hazards, eventFocus = 1, obj = NULL)
## S3 method for class 'discSurvEstCumInc'
plot(x, ...)
hazards |
Estimated discrete hazard rates of all events (class "matrix"). Each column represents one event. The first column is assumed to contain the censoring case and the discrete hazards should only vary over time in each row. |
eventFocus |
Column that represent the discrete hazards of the primary event (class "integer"). |
obj |
Integer identification number of each individual. Usually this information is computed during data augmentation (class "numeric"). |
x |
estimated cumulative incidence function P(T <= t, event=k | x) based on estimated hazards of a discrete competing risks model or a discrete subdistribution hazard model (class "discSurvEstCumInc"). |
... |
Further arguments passed to |
The covariates set is required to be constant across rows. If argument obj is given, then for each unique individual with specific covariates a cumulative incidence function is computed.
Returns cumulative incidence function of the primary event. If argument obj is not empty a list of vectors is returned.
Thomas Welchowski t.welchowski@psychologie.uzh.ch
minjungDiscCompdiscSurv
estCompRisksGEE, dataLongCompRisks,
dataLongCompRisksTimeDep, geeglm
estSurv, estCumInc, estCompRisksGEE
# Example with unemployment data
library(Ecdat)
data(UnempDur)
# Select subsample
SubUnempDur <- UnempDur [1:100, ]
# Estimate GEE models for all events
estGEE <- estCompRisksGEE(dataShort = SubUnempDur, dataTransform = "dataLongCompRisks",
corstr = "independence", formulaVariable =~ timeInt + age + ui + logwage * ui,
eventColumns = c("censor1", "censor2", "censor3", "censor4"), timeColumn = "spell")
# Estimate hazards of all events given the covariates of third person
SubUnempDurLong <- dataLongCompRisks(dataShort = SubUnempDur,
eventColumns = c("censor1", "censor2", "censor3", "censor4"), timeColumn = "spell")
preds <- predict(estGEE, subset(SubUnempDurLong, obj == 3))
# Estimate cumulative incidence function
cumIncGEE <- estCumInc(preds, eventFocus = 2)
plot(cumIncGEE)
# Example with unemployment data
library(Ecdat)
data(UnempDur)
# Select subsample
SubUnempDur <- UnempDur [1:100, ]
################################
# Competing risks model
# Estimate GEE models for all events
estGEE <- estCompRisksGEE(dataShort = SubUnempDur, dataTransform = "dataLongCompRisks",
corstr = "independence", formulaVariable =~ timeInt + age + ui + logwage * ui,
eventColumns = c("censor1", "censor2", "censor3", "censor4"), timeColumn = "spell")
# Estimate hazards of all events given the covariates of third person
SubUnempDurLong <- dataLongCompRisks(dataShort = SubUnempDur,
eventColumns = c("censor1", "censor2", "censor3", "censor4"), timeColumn = "spell")
preds <- predict(estGEE, subset(SubUnempDurLong, obj == 3))
estCumInc1 <- estCumInc(preds, eventFocus = 3)
plot(estCumInc1)
###############################
# Subdistribution hazards model
# Convert to long format
SubUnempDurLong <- dataLongSubDist(dataShort = SubUnempDur, timeColumn = "spell",
eventColumns = c("censor1", "censor2", "censor3", "censor4"), eventFocus = "censor1")
# Estimate continuation ratio model with logit link
glmFit <- glm(formula = y ~ timeInt + age + ui + logwage * ui, data = SubUnempDurLong,
family = binomial(), weights = SubUnempDurLong$subDistWeights)
# Estimated subdistribution hazard given the covariates of the third person
preds <- predict(glmFit, type = "response", newdata = subset(SubUnempDurLong, obj == 3))
cumInc1 <- estCumInc(preds)
plot(cumInc1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.