pif.confidence.linear: Confidence Intervals for the Potential Impact Fraction using...

Description Usage Arguments Author(s) Examples

View source: R/pif_confidence_linear.R

Description

Function that calculates approximate confidence intervals to the potential impact fraction.

Usage

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

Arguments

X

Random sample (data.frame) which includes exposure and covariates.

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

thetavar

Estimator of variance of thetahat

**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

confidence

Confidence level % (default 95)

nsim

Number of simulations for estimation of variance

check_thetas

Check that theta parameters are correctly inputed

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.

Author(s)

Rodrigo Zepeda-Tello [email protected]

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

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
## Not run: 
#Example with risk given by HR (PAF)
set.seed(18427)
X <- as.data.frame(rnorm(100,3,.5))
thetahat <- 0.12
thetavar <- 0.1
pif.confidence.linear(X, thetahat, function(X, theta){exp(theta*X)}, 
                      thetavar, nsim = 100)

#Example with linear counterfactual
cft      <- function(X){0.3*X}
pif.confidence.linear(X, thetahat, function(X, theta){exp(theta*X)}, 
                     thetavar, cft, nsim = 100)

#Example with theta and X multivariate
set.seed(18427)
X1 <- rnorm(100, 3,.5)
X2 <- rnorm(100,3,.5)
X  <- as.data.frame(as.matrix(cbind(X1,X2)))
thetahat <- c(0.1, 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}
pif.confidence.linear(X, thetahat, rr, thetavar, cft) 

## End(Not run)

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