AFparfrailty {AF}R Documentation

Attributable fraction function based on a Weibull gamma-frailty model as a parfrailty object (commonly used for cohort sampling family designs with time-to-event outcomes).

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

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-\frac{\{1-S_0(t)\}}{\{1-S(t)\}}

where S_0(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 S_0(t) can be expressed as E_Z\{S(t\mid{X=0,Z })\}. The function uses a fitted Weibull gamma-frailty model to estimate S(t\mid{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; S_0(t).

S0.var

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

Author(s)

Elisabeth Dahlqwist, Arvid Sjölander

See Also

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

Examples

# 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))

[Package AF version 0.1.5 Index]