pif.confidence.loglinear: Confidence intervals for the Potencial Impact Fraction, using...

Description Usage Arguments Author(s) Examples

View source: R/pif_confidence_loglinear.R

Description

Confidence intervals for the Potencial Impact Fraction for relative risk inyective functions, the pif is inyective, and intervals can be calculated for log(pif), and then transformed to pif CI.

Usage

1
2
3
4
pif.confidence.loglinear(X, thetahat, thetavar, rr, cft = NA,
  weights = rep(1/nrow(as.matrix(X)), nrow(as.matrix(X))), nsim = 100,
  confidence = 95, check_thetas = TRUE, check_exposure = TRUE,
  check_cft = TRUE, is_paf = FALSE)

Arguments

X

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

thetahat

Estimative 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

Survey weights for the random sample X.

nsim

Number of simulations for estimation of variance.

confidence

Confidence level % (default 95)

check_thetas

Check that theta parameters are correctly inputed

check_exposure

Check that exposure X is positive and numeric

check_cft

Check if counterfactual function cft reduces exposure.

is_paf

Force evaluation of paf

Author(s)

Rodrigo Zepeda-Tello rzepeda17@gmail.com

Dalia Camacho-Garc<c3><ad>a-Forment<c3><ad> 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
#Example 1: Exponential Relative risk
#--------------------------------------------
set.seed(18427)
X        <- as.data.frame(rnorm(100,5,1))
thetahat <- 0.4
thetavar <- 0.1
cft      <- function(X){sqrt(X)}
pif.confidence.loglinear(X, thetahat, thetavar, rr = function(X, theta){exp(theta*X)}, cft)

#Same example with linear counterfactual
a    <- 0.5
cft  <- function(X){a*X}
pif.confidence.loglinear(X, thetahat, thetavar, function(X, theta){exp(theta*X)})

#' #Example 2: Multivariate Relative Risk
#--------------------------------------------
set.seed(18427)
X1        <- rnorm(100, 4,0.01)
X2        <- runif(100,0.4,2)
X         <- as.data.frame(cbind(X1,X2))
thetahat  <- c(0.12, 0.03)
thetavar  <- matrix(c(0.01, 0, 0, 0.04), byrow = TRUE, nrow = 2)
rr        <- function(X, theta){
           .X <- as.matrix(X, ncol = 2)
           exp(theta[1]*.X[,1] + theta[2]*.X[,2])
           }
pif.confidence.loglinear(X, thetahat, thetavar, rr) 

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