Description Usage Arguments Details Value Author(s) References See Also Examples
AF.cs
estimates the model-based adjusted attributable fraction for data from cross-sectional sampling designs.
1 |
formula |
an object of class " |
data |
an optional data frame, list or environment (or object coercible by |
exposure |
the name of the exposure variable as a string. The exposure must be binary (0/1) where unexposed is coded as 0. |
clusterid |
the name of the cluster identifier variable as a string, if data are clustered. |
Af.cs
estimates the attributable fraction for a binary outcome Y
under the hypothetical scenario where a binary exposure X
is eliminated from the population.
The estimate is adjusted for confounders Z
by logistic regression (glm
).
Let the AF be defined as
AF = 1 - Pr(Y0 = 1) / Pr(Y = 1)
where Pr(Y0 = 1) denotes the counterfactual probability of the outcome if
the exposure would have been eliminated from the population and Pr(Y = 1) denotes the factual probability of the outcome.
If Z
is sufficient for confounding control, then Pr(Y0 = 1) can be expressed as
E_z{Pr(Y = 1 |X = 0,Z)}.
The function uses logistic regression to estimate Pr(Y=1|X=0,Z), and the marginal sample distribution of Z
to approximate the outer expectation (Sj<c3><b6>lander and Vansteelandt, 2012).
If clusterid
is supplied, then a clustered sandwich formula is used in all variance calculations.
AF.est |
estimated attributable fraction. |
AF.var |
estimated variance of |
P.est |
estimated factual proportion of cases; Pr(Y=1). |
P.var |
estimated variance of |
P0.est |
estimated counterfactual proportion of cases if exposure would be eliminated; Pr(Y0=1). |
P0.var |
estimated variance of |
object |
the fitted model. Fitted using logistic regression, |
Elisabeth Dahlqwist, Arvid Sj<c3><b6>lander
Greenland, S. and Drescher, K. (1993). Maximum Likelihood Estimation of the Attributable Fraction from logistic Models. Biometrics 49, 865-872.
Sj<c3><b6>lander, A. and Vansteelandt, S. (2011). Doubly robust estimation of attributable fractions. Biostatistics 12, 112-121.
The new and more general version of the function: AFglm
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Simulate a cross-sectional sample
expit <- function(x) 1 / (1 + exp( - x))
n <- 1000
Z <- rnorm(n = n)
X <- rbinom(n = n, size = 1, prob = expit(Z))
Y <- rbinom(n = n, size = 1, prob = expit(Z + X))
# Example 1: non clustered data from a cross-sectional sampling design
data <- data.frame(Y, X, Z)
# Estimation of the attributable fraction
AF.cs_est <- AF.cs(formula = Y ~ X + Z + X * Z, data = data, exposure = "X")
summary(AF.cs_est)
# Example 2: clustered data from a cross-sectional sampling design
# Duplicate observations in order to create clustered data
id <- rep(1:n, 2)
data <- data.frame(id = id, Y = c(Y, Y), X = c(X, X), Z = c(Z, Z))
# Estimation of the attributable fraction
AF.cs_clust <- AF.cs(formula = Y ~ X + Z + X * Z, data = data,
exposure = "X", clusterid = "id")
summary(AF.cs_clust)
|
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
Warning message:
In AF.cs(formula = Y ~ X + Z + X * Z, data = data, exposure = "X") :
NOTE! Deprecated function. Use AFglm.
Call:
glm(formula = formula, family = binomial, data = data)
Estimated attributable fraction (AF) and untransformed 95% Wald CI:
AF Std.Error z value Pr(>|z|) Lower limit Upper limit
0.1561583 0.02748563 5.681453 1.335556e-08 0.1022874 0.2100291
Exposure : X
Outcome : Y
Observations Cases
1000 611
Method for confounder adjustment: Logistic regression
Formula: Y ~ X + Z + X * Z
Warning message:
In AF.cs(formula = Y ~ X + Z + X * Z, data = data, exposure = "X", :
NOTE! Deprecated function. Use AFglm.
Call:
glm(formula = formula, family = binomial, data = data)
Estimated attributable fraction (AF) and untransformed 95% Wald CI:
AF Robust SE z value Pr(>|z|) Lower limit Upper limit
0.1561583 0.02748563 5.681453 1.335556e-08 0.1022874 0.2100291
Exposure : X
Outcome : Y
Observations Cases Clusters
2000 1222 1000
Method for confounder adjustment: Logistic regression
Formula: Y ~ X + Z + X * Z
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.