Learn R Programming

riskRegression (version 2020.02.05)

iidCox: Extract iid decomposition from a Cox model

Description

Compute the influence function for each observation used to estimate the model

Usage

iidCox(
  object,
  newdata,
  baseline.iid,
  tau.hazard,
  tau.max,
  store.iid,
  keep.times,
  return.object
)

# S3 method for coxph iidCox( object, newdata = NULL, baseline.iid = TRUE, tau.hazard = NULL, tau.max = NULL, store.iid = "full", keep.times = TRUE, return.object = TRUE )

# S3 method for cph iidCox( object, newdata = NULL, baseline.iid = TRUE, tau.hazard = NULL, tau.max = NULL, store.iid = "full", keep.times = TRUE, return.object = TRUE )

# S3 method for phreg iidCox( object, newdata = NULL, baseline.iid = TRUE, tau.hazard = NULL, tau.max = NULL, store.iid = "full", keep.times = TRUE, return.object = TRUE )

# S3 method for CauseSpecificCox iidCox( object, newdata = NULL, baseline.iid = TRUE, tau.hazard = NULL, tau.max = NULL, store.iid = "full", keep.times = TRUE, return.object = TRUE )

Arguments

object

object The fitted Cox regression model object either obtained with coxph (survival package) or cph (rms package).

newdata

[data.frame] Optional new data at which to do iid decomposition

baseline.iid

[logical] Should the influence function for the baseline hazard be computed.

tau.hazard

[numeric vector] the vector of times at which the i.i.d decomposition of the baseline hazard will be computed

tau.max

[numeric] latest time at which the i.i.d decomposition of the baseline hazard will be computed. Alternative to tau.hazard.

store.iid

[character] the method used to compute the influence function and the standard error. Can be "full", "approx" or "minimal". See the details section.

keep.times

[logical] If TRUE add the evaluation times to the output.

return.object

[logical] If TRUE return the object where the iid decomposition has been added. Otherwise return a list (see the return section)

Value

For Cox models, the iid slot is a list containing:

  • IFbetaInfluence function for the regression coefficient.

  • IFhazardTime differential of the influence function of the hazard.

  • IFcumhazardInfluence function of the cumulative hazard.

  • calcIFhazardElements used to compute the influence function at a given time.

  • timeTimes at which the influence function has been evaluated.

  • etime1.minTime of first event (i.e. jump) in each strata.

  • etime.maxLast observation time (i.e. jump or censoring) in each strata.

  • indexObsIndex of the observation in the original dataset.

For Cause-Specific Cox models, a list containing the iid decomposition relative to each cause is returned.

Details

This function implements the first three formula (no number,10,11) of the subsection "Empirical estimates" in (Ozenne et al., 2017).

If there is no event in a strata, the influence function for the baseline hazard is set to 0.

store.iid equal to "full" exports the influence function for the coefficients and the baseline hazard at each event time. store.iid equal to "approx" does the same except that the terms that do not contributes to the variance are not ignored (i.e. set to 0) store.iid equal to "minimal" exports the influence function for the coefficients. For the baseline hazard it only computes the quantities necessary to compute the influence function in order to save memory.

References

Brice Ozenne, Anne Lyngholm Sorensen, Thomas Scheike, Christian Torp-Pedersen and Thomas Alexander Gerds. riskRegression: Predicting the Risk of an Event using Cox Regression Models. The R Journal (2017) 9:2, pages 440-460.

Examples

Run this code
# NOT RUN {
library(survival)
library(data.table)
library(prodlim)
set.seed(10)
d <- sampleData(100, outcome = "survival")[,.(eventtime,event,X1,X6)]
setkey(d, eventtime)

m.cox <- coxph(Surv(eventtime, event) ~ X1+X6, data = d, y = TRUE, x = TRUE)
system.time(IF.cox <- iidCox(m.cox))
system.time(IF.cox_approx <- iidCox(m.cox, store.iid = "approx"))


IF.cox.all <- iidCox(m.cox, tau.hazard = sort(unique(c(7,d$eventtime))))
IF.cox.beta <- iidCox(m.cox, baseline.iid = FALSE)

# }

Run the code above in your browser using DataLab