paf.confidence.inverse: Confidence intervals for the Population Attributable...

Description Usage Arguments Note Author(s) Examples

View source: R/paf_confidence_inverse.R

Description

Confidence intervals for the Population Attributable Fraction for relative risk inyective functions, the PAF is inyective, and intervals can be calculated for the relative risk, and then transformed to PAF CI.

Usage

1
2
3
4
5
paf.confidence.inverse(X, thetahat, rr, thetavar,
  weights = rep(1/nrow(as.matrix(X)), nrow(as.matrix(X))),
  method = c("empirical", "approximate"), nsim = 1000, confidence = 95,
  deriv.method.args = list(), deriv.method = c("Richardson", "complex"),
  force.min = FALSE, check_thetas = TRUE, Xvar = var(X))

Arguments

X

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

thetahat

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

thetavar

Estimator of variance of thetahat.

weights

Survey weights for the random sample X.

method

Either empirical (default) or approximate.

nsim

Number of simulations (default: 1000)

confidence

Confidence level % (default: 95)

deriv.method.args

method.args for hessian. Only if "approximate" method is chosen.

deriv.method

method for hessian. Don't change this unless you know what you are doing. Only if "approximate" method is chosen.

force.min

Boolean indicating whether to force the rr to have a minimum value of 1 instead of 0 (not recommended).

check_thetas

Checks that theta parameters are correctly inputed

Xvar

Variance of exposure levels.

Note

The force.min option forces the relative risk rr to have a minimum of 1 and thus an rr < 1 is NOT possible. This is only for when absolute certainty is had that rr > 1 and should be used under careful consideration. The confidence interval to acheive such an rr is based on the paper by Do Le Minh and Y. .s. Sherif

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
28
29
30
31
32
33
34
35
36
37
38
 ## Not run: 
#Example 1: Exponential Relative Risk
#--------------------------------------------
set.seed(18427)
X <- as.data.frame(rnorm(100,0.3,.05))
thetahat <- 0.4
thetavar <- 0.1
paf.confidence.inverse(X, thetahat, function(X, theta){exp(theta*X)}, thetavar)


#With approximate method
Xmean <- as.data.frame(mean(X[,1]))
Xvar  <- var(X)
paf.confidence.inverse(Xmean, thetahat, 
function(X, theta){exp(theta*X)}, thetavar, Xvar = Xvar, method = "approximate")

#We can force PAF's CI to be >= 0 (only if it is certain)
paf.confidence.inverse(X, thetahat, 
function(X, theta){exp(theta*X)}, thetavar, force.min = TRUE)

#Example 2: Multivariate Relative Risk
#--------------------------------------------
set.seed(18427)
X1 <- rnorm(1000,0.3,.05)
X2 <- rnorm(1000,0.3,.05)
X  <- as.data.frame(as.matrix(cbind(X1,X2)))
thetahat <- c(0.12, 0.03)
thetavar <- matrix(c(0.1, 0, 0, 0.4), byrow = TRUE, nrow = 2)
rr <- function(X, theta){exp(theta[1]*X[,1] + theta[2]*X[,2])}
paf.confidence.inverse(X, thetahat, rr, thetavar) 

#Same example with approximate method
Xmean    <- as.data.frame(matrix(colMeans(X), ncol = 2))
Xvar     <- cov(X)
paf.confidence.inverse(Xmean, thetahat, rr=rr, thetavar = thetavar, 
method = "approximate", Xvar = Xvar)

## End(Not run)

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