AFcoxph function

Attributable fraction function based on a Cox Proportional Hazard regression model as a coxph object (commonly used for cohort sampling designs with time-to-event outcomes).

Attributable fraction function based on a Cox Proportional Hazard regression model as a coxph object (commonly used for cohort sampling designs with time-to-event outcomes).

AFcoxph estimates the model-based adjusted attributable fraction function from a Cox Proportional Hazard regression model in form of a coxph object. This model is commonly used for data from cohort sampling designs with time-to-event outcomes.

AFcoxph(object, data, exposure, times, clusterid)

Arguments

  • object: a fitted Cox Proportional Hazard regression model object of class "coxph". Method for handling ties must be breslow since this is assumed in the calculation of the standard errors. No special terms such as cluster, strata and tt is allowed in the formula for the fitted object.
  • data: an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment (formula), typically the environment from which the function is called.
  • exposure: the name of the exposure variable as a string. The exposure must be binary (0/1) where unexposed is coded as 0.
  • times: a scalar or vector of time points specified by the user for which the attributable fraction function is estimated. If not specified the observed event times will be used.
  • clusterid: the name of the cluster identifier variable as a string, if data are clustered. Cluster robust standard errors will be calculated.

Returns

  • AF.est: estimated attributable fraction function for every time point specified by times.

  • AF.var: estimated variance of AF.est. The variance is obtained by combining the delta methods with the sandwich formula.

  • S.est: estimated factual survival function; S(t)S(t).

  • S.var: estimated variance of S.est. The variance is obtained by the sandwich formula.

  • S0.est: estimated counterfactual survival function if exposure would be eliminated; S0(t)S0(t).

  • S0.var: estimated variance of S0.est. The variance is obtained by the sandwich formula.

Details

AFcoxph estimates the attributable fraction for a time-to-event outcome under the hypothetical scenario where a binary exposure X is eliminated from the population. The estimate is adjusted for confounders Z

by the Cox proportional hazards model (coxph). Let the AF function be defined as

AF=1{1S0(t)}{1S(t)}AF=11S0(t)/1S(t) AF=1-\frac{\{1-S_0(t)\}}{\{1-S(t)\}}AF = 1 - {1 - S0(t)} / {1 - S(t)}

where S0(t)S0(t) denotes the counterfactual survival function for the event if the exposure would have been eliminated from the population at baseline and S(t)S(t) denotes the factual survival function. If Z is sufficient for confounding control, then S0(t)S0(t) can be expressed as EzS(tX=0,Z)E_z{S(t|X=0,Z)}. The function uses a fitted Cox proportional hazards regression to estimate S(tX=0,Z)S(t|X=0,Z), and the marginal sample distribution of Z

to approximate the outer expectation ( and Vansteelandt, 2014). If clusterid is supplied, then a clustered sandwich formula is used in all variance calculations.

Examples

# Simulate a sample from a cohort sampling design with time-to-event outcome expit <- function(x) 1 / (1 + exp( - x)) n <- 500 time <- c(seq(from = 0.2, to = 1, by = 0.2)) Z <- rnorm(n = n) X <- rbinom(n = n, size = 1, prob = expit(Z)) Tim <- rexp(n = n, rate = exp(X + Z)) C <- rexp(n = n, rate = exp(X + Z)) Tobs <- pmin(Tim, C) D <- as.numeric(Tobs < C) #Ties created by rounding Tobs <- round(Tobs, digits = 2) # Example 1: non clustered data from a cohort sampling design with time-to-event outcomes data <- data.frame(Tobs, D, X, Z) # Fit a Cox PH regression model fit <- coxph(formula = Surv(Tobs, D) ~ X + Z + X * Z, data = data, ties="breslow") # Estimate the attributable fraction from the fitted Cox PH regression model AFcoxph_est <- AFcoxph(fit, data=data, exposure ="X", times = time) summary(AFcoxph_est) # Example 2: clustered data from a cohort sampling design with time-to-event outcomes # Duplicate observations in order to create clustered data id <- rep(1:n, 2) data <- data.frame(Tobs = c(Tobs, Tobs), D = c(D, D), X = c(X, X), Z = c(Z, Z), id = id) # Fit a Cox PH regression model fit <- coxph(formula = Surv(Tobs, D) ~ X + Z + X * Z, data = data, ties="breslow") # Estimate the attributable fraction from the fitted Cox PH regression model AFcoxph_clust <- AFcoxph(object = fit, data = data, exposure = "X", times = time, clusterid = "id") summary(AFcoxph_clust) plot(AFcoxph_clust, CI = TRUE) # Estimate the attributable fraction from the fitted Cox PH regression model, time unspecified AFcoxph_clust_no_time <- AFcoxph(object = fit, data = data, exposure = "X", clusterid = "id") summary(AFcoxph_clust_no_time) plot(AFcoxph_clust, CI = TRUE)

References

Chen, L., Lin, D. Y., and Zeng, D. (2010). Attributable fraction functions for censored event times. Biometrika 97 , 713-726.

, A. and Vansteelandt, S. (2014). Doubly robust estimation of attributable fractions in survival analysis. Statistical Methods in Medical Research. doi: 10.1177/0962280214564003.

See Also

coxph and Surv used for fitting the Cox proportional hazards model.

Author(s)

Elisabeth Dahlqwist, Arvid

  • Maintainer: Elisabeth Dahlqwist
  • License: GPL-2 | GPL-3
  • Last published: 2019-05-20

Useful links