Description Usage Arguments Note Author(s) See Also Examples
Function for estimating the Potential Impact Fraction
pif
from a cross-sectional sample of the exposure X
with a known Relative Risk function rr
with parameters theta
when only mean(X)
and var(X)
are known.
1 2 3 |
X |
Mean value of exposure levels from a cross-sectional random
sample. If multivariate, this should be a |
Xvar |
Variance of the exposure levels. |
thetahat |
Estimator ( |
rr |
**Optional** |
cft |
Twice differentiable function |
deriv.method.args |
|
deriv.method |
|
check_exposure |
Check that exposure |
check_rr |
Check that Relative Risk function |
check_integrals |
Check that counterfactual and relative risk's expected values are well defined for this scenario. |
is_paf |
Boolean forcing evaluation of |
pif.approximate
method should be the last choice for the case
when no information on the exposure X
(except for mean and standard
deviation) are given. In practice pif.empirical
should be
prefered.
Rodrigo Zepeda-Tello rzepeda17@gmail.com
Dalia Camacho-GarcĂa-FormentĂ daliaf172@gmail.com
pif
which is a wrapper for all pif methods
(pif.empirical
, pif.approximate
,
pif.kernel
).
For estimation of the Population Attributable Fraction see
paf
.
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 | #Example 1
#--------------------------------------------
X <- data.frame(2)
thetahat <- 0.12
Xvar <- 0.2
rr <- function(X,theta){exp(X*theta)}
cft <- function(X){0.5*X}
pif.approximate(X, Xvar, thetahat, rr, cft)
#Change the derivative arguments
pif.approximate(X, Xvar, thetahat, rr, cft,
deriv.method = "Richardson",
deriv.method.args = list(eps=1e-8, d=0.000001))
#When no counterfactual is specified paf is calculated
pif.approximate(X, Xvar, thetahat, rr)
#Example 2: Multivariate
#--------------------------------------------
X1 <- 2
X2 <- 1.1
X <- data.frame(X1,X2)
Xvar <- matrix(c(1,.4,.4,1),ncol = 2, byrow = TRUE)
cft <- function(X){.25*X}
thetahat <- c(0.12, 0.03)
rr <- function(X, theta){exp(theta[1]*X[,1] + theta[2]*X[,2])}
pif.approximate(X, Xvar, thetahat, rr, cft)
#Example 3: More multivariate
#--------------------------------------------
X1 <- rnorm(1000,3,.5)
X2 <- rnorm(1000,4,1)
X <- cbind(X1,X2)
Xmean <- data.frame(t(colMeans(X)))
Xvar <- var(X)
thetahat <- c(0.12, 0.17)
thetavar <- matrix(c(0.001, 0.00001, 0.00001, 0.004), byrow = TRUE, nrow = 2)
rr <- function(X, theta){exp(theta[1]*X[,1] + theta[2]*X[,2])}
cft <- function(X){cbind(sqrt(X[,1] + 0.2*X[,2]), X[,1])}
pif.approximate(Xmean, Xvar, thetahat, rr, cft)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.