AFparfrailty: Attributable fraction function based on a Weibull...

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

View source: R/AFparfrailty.R

Description

AFparfrailty estimates the model-based adjusted attributable fraction function from a shared Weibull gamma-frailty model in form of a parfrailty object. This model is commonly used for data from cohort sampling familty designs with time-to-event outcomes.

Usage

1
AFparfrailty(object, data, exposure, times, clusterid)

Arguments

object

a fitted Weibull gamma-parfrailty object of class "parfrailty".

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 death times will be used.

clusterid

the name of the cluster identifier variable as a string, if data are clustered.

Details

AFparfrailty 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 shared frailty model (parfrailty). The baseline hazard is assumed to follow a Weibull distribution and the unobserved shared frailty effects U are assumed to be gamma distributed. 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 and U are sufficient for confounding control, then S0(t) can be expressed as E_z{S(t|X=0,Z)}. The function uses a fitted Weibull gamma-frailty model to estimate S(t|X=0,Z), and the marginal sample distribution of Z to approximate the outer expectation. 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

See Also

parfrailty used for fitting the Weibull gamma-frailty and stdParfrailty used for standardization of a parfrailty object.

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
# Example 1: clustered data with frailty U
expit <- function(x) 1 / (1 + exp( - x))
n <- 100
m <- 2
alpha <- 1.5
eta <- 1
phi <- 0.5
beta <- 1
id <- rep(1:n,each=m)
U <- rep(rgamma(n, shape = 1 / phi, scale = phi), each = m)
Z <- rnorm(n * m)
X <- rbinom(n * m, size = 1, prob = expit(Z))
# Reparametrize scale as in rweibull function
weibull.scale <- alpha / (U * exp(beta * X)) ^ (1 / eta)
t <- rweibull(n * m, shape = eta, scale = weibull.scale)

# Right censoring
c <- runif(n * m, 0, 10)
delta <- as.numeric(t < c)
t <- pmin(t, c)

data <- data.frame(t, delta, X, Z, id)

# Fit a parfrailty object
library(stdReg)
fit <- parfrailty(formula = Surv(t, delta) ~ X + Z + X * Z, data = data, clusterid = "id")
summary(fit)

# Estimate the attributable fraction from the fitted frailty model

time <- c(seq(from = 0.2, to = 1, by = 0.2))

AFparfrailty_est <- AFparfrailty(object = fit, data = data, exposure = "X",
                                  times = time, clusterid = "id")
summary(AFparfrailty_est)
plot(AFparfrailty_est, CI = TRUE, ylim=c(0.1,0.7))

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

Related to AFparfrailty in AF...