Description Usage Arguments Note Author(s) See Also Examples
View source: R/pif_empirical.R
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; θ)
| 1 2 3 | 
| X | Random sample ( | 
| thetahat | Estimator ( | 
| rr | Function for Relative Risk which uses parameter  **Optional** | 
| cft | Function  | 
| weights | Normalized survey  | 
| 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  | 
The empirical method converges for relative risk rr functions 
that are Lipschitz, convex or concave on thetahat. For stranger 
functions use pif.kernel.
Rodrigo Zepeda-Tello rzepeda17@gmail.com
Dalia Camacho-Garc<c3><ad>a-Forment<c3><ad> 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 | #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) 
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.