pif.approximate: Point Estimate of the Potential Impact Fraction via the...

Description Usage Arguments Note Author(s) See Also Examples

View source: R/pif_approximate.R

Description

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.

Usage

1
2
3
pif.approximate(X, Xvar, thetahat, rr, cft = NA, deriv.method.args = list(),
  deriv.method = c("Richardson", "complex"), check_exposure = TRUE,
  check_rr = TRUE, check_integrals = TRUE, is_paf = FALSE)

Arguments

X

Mean value of exposure levels from a cross-sectional random sample. If multivariate, this should be a matrix with 1 row and as many columns as covariates

Xvar

Variance of the exposure levels.

thetahat

Estimator (vector) of theta for the Relative Risk function.

rr

function for Relative Risk which uses parameter theta. The order of the parameters shound be rr(X, theta).

**Optional**

cft

Twice differentiable function cft(X) for counterfactual. Leave empty for the Population Attributable Fraction paf where counterfactual is 0 exposure.

deriv.method.args

method.args for hessian.

deriv.method

method for hessian. Don't change this unless you know what you are doing.

check_exposure

Check that exposure X is positive and numeric.

check_rr

Check that Relative Risk function rr equals 1 when evaluated at 0.

check_integrals

Check that counterfactual and relative risk's expected values are well defined for this scenario.

is_paf

Boolean forcing evaluation of paf.

Note

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.

Author(s)

Rodrigo Zepeda-Tello rzepeda17@gmail.com

Dalia Camacho-Garc<c3><ad>a-Forment<c3><ad> daliaf172@gmail.com

See Also

pif which is a wrapper for all pif methods (pif.empirical, pif.approximate, pif.kernel).

For estimation of the Population Attributable Fraction see paf.

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

pifpaf documentation built on May 1, 2019, 9:11 p.m.