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

Description Usage Arguments Note Author(s) See Also Examples

View source: R/pif_empirical.R

Description

Function that calculates the potential impact fraction pif via the empirical method. That is: for a random sample X, a relative risk function rr(X, thetahat) with parameters thetahat the empirical estimator is given by:

PIF = 1 - ∑ rr(cft(X_i); θ)/∑ rr(X_i; θ)

Usage

1
2
3
pif.empirical(X, thetahat, rr, cft = NA, weights = rep(1/nrow(as.matrix(X)),
  nrow(as.matrix(X))), check_exposure = TRUE, check_rr = TRUE,
  check_integrals = TRUE, is_paf = FALSE)

Arguments

X

Random sample (data.frame) which includes exposure and covariates. or sample mean if approximate method is selected.

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

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

weights

Normalized survey weights for the sample X.

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

The empirical method converges for relative risk rr functions that are Lipschitz, convex or concave on thetahat. For stranger functions use pif.kernel.

Author(s)

Rodrigo Zepeda-Tello [email protected]

Dalia Camacho-Garc<c3><ad>a-Forment<c3><ad> [email protected]

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
#Example 1: Relative risk given by exponential
#--------------------------------------------
set.seed(18427)
X        <- data.frame(rnorm(100,3,.5))
thetahat <- 0.12
rr       <- function(X, theta){exp(theta*X)}
pif.empirical(X, thetahat, rr, cft = function(X){ 0.5*X })

#Without counterfactual estimates PAF
pif.empirical(X, thetahat, rr) 
 
#Example 2: Linear relative risk
#--------------------------------------------
pif.empirical(X, thetahat, rr = function(X, theta){theta*X + 1}, 
               cft = function(X){ 0.5*X })

#Example 3: Multivariate relative risk
#--------------------------------------------
set.seed(18427)
X1       <- rnorm(100,4,1)
X2       <- rnorm(100,2,0.4)
X        <- data.frame(cbind(X1,X2))
thetahat <- c(0.12, 0.03)
rr       <- function(X, theta){exp(theta[1]*X[,1] + theta[2]*X[,2])}

#Creating a counterfactual. As rr requires a bivariate input, cft should 
#return a two-column matrix
cft  <- function(X){
   cbind(X[,1]/2, 1.1*X[,2])
}
pif.empirical(X, thetahat, rr, cft) 

pifpaf documentation built on Sept. 29, 2017, 1:03 a.m.