AFcoxph: Attributable fraction function based on a Cox Proportional...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/AFcoxph.R

Description

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.

Usage

1
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.

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 - {1 - S0(t)} / {1 - S(t)}

where 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) denotes the factual survival function. If Z is sufficient for confounding control, then S0(t) can be expressed as E_z{S(t|X=0,Z)}. The function uses a fitted Cox proportional hazards regression to estimate S(t|X=0,Z), and the marginal sample distribution of Z to approximate the outer expectation (Sj<c3><b6>lander and Vansteelandt, 2014). If clusterid is supplied, then a clustered sandwich formula is used in all variance calculations.

Value

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.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.var

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

Author(s)

Elisabeth Dahlqwist, Arvid Sj<c3><b6>lander

References

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

Sj<c3><b6>lander, 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.

Examples

 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
34
35
36
37
38
39
40
41
42
# 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)

Example output

Loading required package: survival
Loading required package: drgee
Loading required package: nleqslv
Loading required package: Rcpp
Loading required package: data.table
Loading required package: stdReg
Call:  
coxph(formula = Surv(Tobs, D) ~ X + Z + X * Z, data = data, ties = "breslow")

Estimated attributable fraction (AF) and untransformed 95% Wald CI: 

 Time        AF  Std.Error  z value     Pr(>|z|) Lower limit Upper limit
  0.2 0.4409712 0.06018887 7.326458 2.363157e-13   0.3230032   0.5589393
  0.4 0.3428828 0.05302615 6.466296 1.004341e-10   0.2389535   0.4468122
  0.6 0.2618869 0.04426686 5.916093 3.296785e-09   0.1751254   0.3486483
  0.8 0.2186562 0.03899067 5.607911 2.047838e-08   0.1422359   0.2950765
  1.0 0.1783950 0.03370551 5.292755 1.204872e-07   0.1123334   0.2444566

Exposure : X 
Event    : D 

 Observations Events
          500    261

Method for confounder adjustment:  Cox Proportional Hazards model 

Formula:  Surv(Tobs, D) ~ X + Z + X * Z 
Call:  
coxph(formula = Surv(Tobs, D) ~ X + Z + X * Z, data = data, ties = "breslow")

Estimated attributable fraction (AF) and untransformed 95% Wald CI: 

 Time        AF  Robust SE   z value     Pr(>|z|) Lower limit Upper limit
  0.2 0.4409712 0.04271303 10.324045 5.486180e-25   0.3572552   0.5246872
  0.4 0.3428828 0.03776328  9.079793 1.087816e-19   0.2688681   0.4168975
  0.6 0.2618869 0.03165594  8.272914 1.307244e-16   0.1998424   0.3239314
  0.8 0.2186562 0.02767679  7.900344 2.781337e-15   0.1644107   0.2729017
  1.0 0.1783950 0.02373252  7.516903 5.608909e-14   0.1318802   0.2249099

Exposure : X 
Event    : D 

 Observations Events Clusters
         1000    522      500

Method for confounder adjustment:  Cox Proportional Hazards model 

Formula:  Surv(Tobs, D) ~ X + Z + X * Z 
Call:  
coxph(formula = Surv(Tobs, D) ~ X + Z + X * Z, data = data, ties = "breslow")

Estimated attributable fraction (AF) and untransformed 95% Wald CI: 

  Time          AF   Robust SE    z value     Pr(>|z|)  Lower limit Upper limit
  0.00 0.652157206 0.045285561 14.4009966 5.100275e-47  0.563399138 0.740915275
  0.01 0.635259108 0.045825983 13.8624218 1.070023e-43  0.545441831 0.725076385
  0.02 0.620947406 0.045925377 13.5207907 1.179017e-41  0.530935322 0.710959491
  0.03 0.605498347 0.046074404 13.1417509 1.897838e-39  0.515194174 0.695802520
  0.04 0.585710990 0.046272719 12.6578036 1.012939e-36  0.495018127 0.676403854
  0.05 0.577288946 0.046230359 12.4872261 8.765686e-36  0.486679107 0.667898785
  0.06 0.564027623 0.046020234 12.2560791 1.558607e-34  0.473829623 0.654225623
  0.07 0.553050343 0.045801086 12.0750486 1.430797e-33  0.463281864 0.642818823
  0.08 0.548134789 0.046067491 11.8985162 1.204701e-32  0.457844166 0.638425413
  0.09 0.534463787 0.045698885 11.6953354 1.346542e-31  0.444895618 0.624031956
  0.10 0.518838493 0.045116246 11.5000370 1.318590e-30  0.430412277 0.607264710
  0.11 0.504070894 0.044448717 11.3405049 8.266613e-30  0.416953010 0.591188779
  0.12 0.494633659 0.044275783 11.1716523 5.612694e-29  0.407854718 0.581412600
  0.13 0.488862531 0.044338956 11.0255760 2.876709e-28  0.401959774 0.575765288
  0.14 0.479065674 0.043830071 10.9300685 8.278594e-28  0.393160314 0.564971034
  0.15 0.474810291 0.043723698 10.8593352 1.800552e-27  0.389113418 0.560507165
  0.16 0.464042565 0.043353848 10.7036074 9.789142e-27  0.379070585 0.549014546
  0.17 0.461763537 0.043243801 10.6781440 1.288214e-26  0.377007244 0.546519830
  0.18 0.454879204 0.043124537 10.5480369 5.186948e-26  0.370356666 0.539401743
  0.19 0.452547249 0.043041772 10.5141407 7.435555e-26  0.368186925 0.536907572
  0.20 0.440971233 0.042713027 10.3240454 5.486180e-25  0.357255237 0.524687228
  0.21 0.438590412 0.042679063 10.2764771 8.995574e-25  0.354940986 0.522239838
  0.22 0.431305533 0.042505224 10.1471182 3.412926e-24  0.347996825 0.514614241
  0.24 0.428721841 0.042414415 10.1079277 5.095055e-24  0.345591115 0.511852567
  0.25 0.423458506 0.042187915 10.0374361 1.043511e-23  0.340771712 0.506145301
  0.26 0.420735974 0.042088632  9.9964280 1.579935e-23  0.338243772 0.503228176
  0.27 0.412351957 0.041697088  9.8892267 4.635949e-23  0.330627166 0.494076747
  0.28 0.409479876 0.041558065  9.8531987 6.639655e-23  0.328027565 0.490932188
  0.29 0.395403905 0.040807471  9.6894980 3.341671e-22  0.315422732 0.475385078
  0.30 0.389715017 0.040550513  9.6106063 7.212302e-22  0.310237472 0.469192562
  0.31 0.386751516 0.040451726  9.5608162 1.168317e-21  0.307467590 0.466035443
  0.32 0.377830309 0.039943915  9.4590205 3.108414e-21  0.299541674 0.456118943
  0.33 0.374804906 0.039809213  9.4150293 4.729506e-21  0.296780282 0.452829530
  0.36 0.368707944 0.039670927  9.2941600 1.483731e-20  0.290954355 0.446461532
  0.37 0.365539854 0.039427655  9.2711538 1.841430e-20  0.288263070 0.442816638
  0.38 0.356246290 0.038870234  9.1650154 4.953992e-20  0.280062032 0.432430548
  0.39 0.352886018 0.038630342  9.1349442 6.544050e-20  0.277171939 0.428600097
  0.40 0.342882808 0.037763285  9.0797930 1.087816e-19  0.268868130 0.416897486
  0.41 0.339410307 0.037512185  9.0480015 1.456088e-19  0.265887775 0.412932840
  0.42 0.335877066 0.037251343  9.0165090 1.941785e-19  0.262865776 0.408888357
  0.43 0.328871779 0.036539915  9.0003433 2.250130e-19  0.257254861 0.400488696
  0.45 0.321460506 0.036217336  8.8758738 6.938650e-19  0.250475831 0.392445181
  0.47 0.317714081 0.035965657  8.8338183 1.011620e-18  0.247222688 0.388205474
  0.48 0.313986746 0.035719659  8.7903064 1.491526e-18  0.243977501 0.383995990
  0.50 0.306360155 0.035154961  8.7145639 2.918800e-18  0.237457697 0.375262612
  0.51 0.302543918 0.034937873  8.6594831 4.739084e-18  0.234066946 0.371020890
  0.52 0.298689864 0.034602055  8.6321423 6.021342e-18  0.230871082 0.366508647
  0.55 0.294616523 0.034279432  8.5945568 8.358676e-18  0.227430071 0.361802974
  0.56 0.286434348 0.033871534  8.4564917 2.755418e-17  0.220047361 0.352821335
  0.57 0.278090010 0.033145154  8.3900654 4.858717e-17  0.213126702 0.343053317
  0.59 0.273951157 0.032823900  8.3460881 7.056120e-17  0.209617496 0.338284819
  0.60 0.261886858 0.031655940  8.2729136 1.307244e-16  0.199842355 0.323931360
  0.63 0.257921731 0.031451572  8.2005990 2.391921e-16  0.196277783 0.319565679
  0.67 0.249941942 0.030721311  8.1357838 4.092818e-16  0.189729279 0.310154605
  0.68 0.245978585 0.030397520  8.0920610 5.866353e-16  0.186400541 0.305556629
  0.69 0.241959775 0.030051591  8.0514797 8.179897e-16  0.183059739 0.300859811
  0.70 0.237985910 0.029721573  8.0071774 1.173711e-15  0.179732697 0.296239123
  0.71 0.234063537 0.029311707  7.9853262 1.401512e-15  0.176613648 0.291513426
  0.74 0.230203573 0.028905433  7.9640243 1.665326e-15  0.173549965 0.286857181
  0.75 0.226402604 0.028488726  7.9470948 1.909362e-15  0.170565728 0.282239480
  0.77 0.222591137 0.028120378  7.9156523 2.459601e-15  0.167476208 0.277706065
  0.79 0.218656212 0.027676795  7.9003445 2.781337e-15  0.164410691 0.272901732
  0.81 0.210897995 0.027171804  7.7616486 8.383244e-15  0.157642237 0.264153752
  0.87 0.206827251 0.026708935  7.7437476 9.652857e-15  0.154478700 0.259175802
  0.92 0.202786029 0.026249048  7.7254622 1.114482e-14  0.151338840 0.254233218
  0.95 0.194595702 0.025239404  7.7099960 1.258217e-14  0.145127379 0.244064024
  0.98 0.186406156 0.024237947  7.6906744 1.463614e-14  0.138900654 0.233911659
  0.99 0.178395035 0.023732519  7.5169028 5.608909e-14  0.131880154 0.224909917
  1.03 0.173809423 0.023200554  7.4916065 6.803566e-14  0.128337172 0.219281674
  1.10 0.168974262 0.022683515  7.4492098 9.390092e-14  0.124515390 0.213433134
  1.12 0.164086861 0.022144873  7.4096996 1.265858e-13  0.120683706 0.207490015
  1.17 0.159204782 0.021599211  7.3708610 1.695295e-13  0.116871106 0.201538457
  1.20 0.154259432 0.020942202  7.3659605 1.758759e-13  0.113213470 0.195305393
  1.23 0.149271422 0.020338447  7.3393717 2.145988e-13  0.109408799 0.189134046
  1.40 0.143849743 0.019923888  7.2199634 5.200156e-13  0.104799640 0.182899847
  1.41 0.138468760 0.019306198  7.1722440 7.377828e-13  0.100629308 0.176308212
  1.43 0.128222559 0.018238808  7.0302051 2.062302e-12  0.092475153 0.163969966
  1.49 0.123068051 0.017479470  7.0407199 1.912491e-12  0.088808920 0.157327182
  1.54 0.117867918 0.016913146  6.9690123 3.191739e-12  0.084718762 0.151017074
  1.60 0.112884850 0.016374208  6.8940646 5.422038e-12  0.080791992 0.144977709
  1.65 0.108070951 0.015763083  6.8559526 7.083886e-12  0.077175876 0.138966026
  1.68 0.103320698 0.015136551  6.8259075 8.737120e-12  0.073653603 0.132987792
  1.71 0.098573858 0.015000839  6.5712228 4.990373e-11  0.069172753 0.127974963
  1.76 0.093329705 0.014355403  6.5013643 7.959480e-11  0.065193632 0.121465778
  1.88 0.088016625 0.013769561  6.3921154 1.636063e-10  0.061028781 0.115004469
  1.95 0.082938491 0.013290468  6.2404490 4.363165e-10  0.056889651 0.108987330
  2.01 0.078062003 0.012606159  6.1923701 5.926619e-10  0.053354385 0.102769620
  2.08 0.073215417 0.011975720  6.1136546 9.737494e-10  0.049743437 0.096687398
  2.24 0.068653174 0.011304416  6.0731289 1.254417e-09  0.046496926 0.090809422
  2.31 0.064148808 0.010896701  5.8869936 3.932840e-09  0.042791667 0.085505949
  2.40 0.059117915 0.010323564  5.7265023 1.025224e-08  0.038884101 0.079351730
  3.14 0.052905279 0.009833530  5.3800905 7.444842e-08  0.033631915 0.072178642
  3.36 0.046004683 0.009360985  4.9145129 8.900348e-07  0.027657489 0.064351877
  3.51 0.039719299 0.008604858  4.6159156 3.913660e-06  0.022854087 0.056584511
  3.60 0.032511181 0.008149272  3.9894586 6.622428e-05  0.016538903 0.048483460
  3.67 0.026091696 0.007443104  3.5054858 4.557747e-04  0.011503480 0.040679912
  4.09 0.018158064 0.006533484  2.7792313 5.448772e-03  0.005352670 0.030963458
  9.64 0.006417307 0.004784925  1.3411510 1.798714e-01 -0.002960974 0.015795588
 12.31 0.001278750 0.001436247  0.8903407 3.732830e-01 -0.001536244 0.004093743

Exposure : X 
Event    : D 

 Observations Events Clusters
         1000    522      500

Method for confounder adjustment:  Cox Proportional Hazards model 

Formula:  Surv(Tobs, D) ~ X + Z + X * Z 

AF documentation built on May 21, 2019, 1:01 a.m.

Related to AFcoxph in AF...