intpredErrCurveCompRisks: Integrated Prediction Error For Competing Risks

View source: R/DiscSurvEvaluationCR.R

intpredErrCurveCompRisksR Documentation

Integrated Prediction Error For Competing Risks

Description

Estimates integrated prediction errors of arbitrary prediction models in the case of competing risks.

Usage

intpredErrCurveCompRisks(
  hazards,
  testDataShort,
  trainDataShort,
  timeColumn,
  timeAsFactor = FALSE,
  eventColumns,
  eventColumnsAsFactor = FALSE,
  tmax = NULL
)

Arguments

hazards

Predicted hazards on the test data with model fitted on training data. Must be a matrix, with the predictions in the rows and the number of columns equal to the number of events.

testDataShort

Test data in short format.

trainDataShort

Train data in short format.

timeColumn

Character giving the column name of the observed times.

timeAsFactor

Should the time intervals be coded as factor (class "logical")? Default is FALSE. In the default settings the column is treated as quantitative variable (class "numeric").

eventColumns

Character vector giving the column names of the event indicators (excluding censoring column).

eventColumnsAsFactor

Should the argument eventColumns be interpreted as column name of a factor variable (class "logical")? Default is FALSE.

tmax

Gives the maximum time interval for which prediction errors are calculated. It must not be higher than the maximum observed time in the training data.

Value

Integrated prediction errors for each competing event. Matrix, with the integrated predictions in the rows and the number of columns equal to the number of events.

Author(s)

Moritz Berger moritz.berger@zi-mannheim.de

References

\insertRef

heyardValCompRisksdiscSurv

See Also

predErrCurveCompRisks, predErrCurve

Examples


###########################
# Example unemployment data
library(Ecdat)
data(UnempDur)

# Select subsample
selectInd1 <- 1:200
selectInd2 <- 201:400
trainSet <- UnempDur[which(UnempDur$spell %in% (1:10))[selectInd1], ]
testSet <- UnempDur[which(UnempDur$spell %in% (1:10))[selectInd2], ]

# Convert to long format 
trainSet_long <- dataLongCompRisks(dataShort=trainSet, timeColumn="spell", 
eventColumns=c("censor1", "censor4"), timeAsFactor=TRUE)
tmax          <- max(trainSet$spell)
testSet_long <- dataLongCompRisks(dataShort=testSet, timeColumn="spell", 
eventColumns=c("censor1", "censor4"), aggTimeFormat = TRUE, lastTheoInt=tmax,
timeAsFactor=TRUE)

# Estimate continuation ratio model with logit link
vglmFit <- VGAM::vglm(formula=cbind(e0, e1, e2) ~ timeInt + age + logwage, 
data=trainSet_long, family=VGAM::multinomial(refLevel="e0"))

# Calculate predicted hazards
predHazards <- VGAM::predictvglm(vglmFit, newdata=testSet_long, type="response")

# Compute integrated prediction error 
intpredErrCurveCompRisks(hazards=predHazards[,-1], testDataShort=testSet, 
trainDataShort=trainSet, timeColumn="spell", timeAsFactor=FALSE,
eventColumns=c("censor1", "censor4"), tmax=tmax)



discSurv documentation built on April 29, 2026, 9:07 a.m.