pif.confidence.bootstrap: Pivotal Boostrap Confidence Intervals for Potential Impact...

Description Usage Arguments Value Author(s) Examples

Description

Estimates a 1 - alpha pivotal confidence interval for the potential impact fraction pif using a boostrap approximation.

Usage

1
2
3
4
5
6
7
8
pif.confidence.bootstrap(X, thetahat, thetavar, rr, cft = NA,
  weights = rep(1/nrow(as.matrix(X)), nrow(as.matrix(X))),
  method = c("empirical", "kernel"), nboost = 10000, adjust = 1,
  n = 512, confidence = 95, ktype = c("gaussian", "epanechnikov",
  "rectangular", "triangular", "biweight", "cosine", "optcosine"),
  bw = c("SJ", "nrd0", "nrd", "ucv", "bcv"), check_exposure = TRUE,
  check_rr = TRUE, check_integrals = TRUE, check_thetas = TRUE,
  is_paf = FALSE)

Arguments

X

Random sample (vector or matrix) which includes exposure and covariates.

thetahat

Maximum Likelihood estimator (vector or matrix) of theta for the Relative Risk function.

thetavar

Estimator of variance of thetahat

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.

method

Either empirical (default), or kernel

nboost

Number of samples in Bootstrap

adjust

Adjust bandwith parameter from density (for kernel method) from density.

n

Number of equally spaced points at which the density (for kernel method) is to be estimated (see density).

confidence

Concidence level (0 to 100) default = 95 %

ktype

kernel type: "gaussian", "epanechnikov", "rectangular", "triangular", "biweight", "cosine", "optcosine" (for kernel method). Additional information on kernels in density

bw

Smoothing bandwith parameter from density (for kernel method) from density. Default "SJ".

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

check_thetas

Checks that theta parameters are correctly inputed

is_paf

Boolean forcing evaluation of paf

Value

pif Estimate of Potential Impact Fraction

Author(s)

Rodrigo Zepeda-Tello rzepeda17@gmail.com

Dalia Camacho-GarcĂ­a-FormentĂ­ daliaf172@gmail.com

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
#Example 1: Exponential Relative Risk
#----------------------------------------
set.seed(18427)
X        <- rnorm(100,5,1)
thetahat <- 0.4
thetavar <- 0.1
pif.confidence.bootstrap(X, thetahat, thetavar, function(X, theta){exp(theta*X)}, 
                         nboost = 100) #nboost small only for example purposes

#This also works with kernel method
pif.confidence.bootstrap(X, thetahat, thetavar, function(X, theta){exp(theta*X)}, 
                         nboost = 100, method = "kernel") 

#Example 2: Multivariate example
#----------------------------------------
## Not run: 
set.seed(18427)
X1 <- rnorm(100, 1, 0.05)
X2 <- rnorm(100, 1, 0.05)
X  <- as.matrix(cbind(X1,X2))
thetahat <- c(2, 0.03)
thetavar <- matrix(c(0.1, 0, 0, 0.05), byrow = TRUE, nrow = 2)
rr        <- function(X, theta){
  .X <- as.matrix(X, ncol = 2)
  exp(theta[1]*.X[,1] + theta[2]*.X[,2])
}
cft <- function(X){0.5*X}#' cft <- function(X){0.95*X}
pif.confidence.bootstrap(X, thetahat, thetavar, rr, cft) 

## End(Not run)

INSP-RH/pif documentation built on May 7, 2019, 6:01 a.m.