paf.confidence.one2one: Approximate Confidence Intervals for the Population...

Description Usage Arguments Author(s) Examples

View source: R/paf_confidence_one_to_one.R

Description

Function that calculates approximate confidence intervals of the Population Attributable Fraction paf considering a one to one Relative Risk rr with unidimensional theta parameter values

Usage

1
2
3
4
5
6
paf.confidence.one2one(X, thetahat, rr, thetalow, thetaup,
  weights = rep(1/nrow(as.matrix(X)), nrow(as.matrix(X))), confidence = 95,
  confidence_theta = 99, check_thetas = TRUE, deriv.method.args = list(),
  deriv.method = c("Richardson", "complex"), method = c("empirical",
  "approximate"), Xvar = var(X), check_exposure = TRUE, check_rr = TRUE,
  check_integrals = TRUE)

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

thetalow

Lower bound of the confidence interval.

thetaup

Upper bound of the confidence interval.

weights

Survey weights for the random sample X.

confidence

Confidence level % (default: 95)

confidence_theta

Confidence level % of theta corresponding to the interval [thetalow, thetaup] (default: 99%).

check_thetas

Check that thetas are correctly specified

deriv.method.args

method.args for hessian.

deriv.method

method for hessian. Don't change this unless you know what you are doing.

method

Either "empirical" (default) or "approximate".

Xvar

Variance of exposure levels (for "approximate" method).

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

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
30
31
32
33
34
35
#Example 1: Exponential Relative Risk
#--------------------------------------------
set.seed(18427)
X <- data.frame(rnorm(1000, 3,.7))
thetahat <- 0.4
thetalow <- 0.1
thetaup  <- 0.7
paf.confidence.one2one(X, thetahat, function(X, theta){exp(theta*X)}, 
thetalow, thetaup)

#Approximate method:
Xmean <- data.frame(mean(X[,1]))
Xvar  <- var(X[,1])
paf.confidence.one2one(Xmean, thetahat, function(X, theta){exp(theta*X)}, 
thetalow, thetaup, Xvar = Xvar, method = "approximate")

#Example 2: Multivariate example
#--------------------------------------------
set.seed(18427)
X1 <- rnorm(1000,3,.7)
X2 <- rnorm(1000,3,.7)
X  <- data.frame(X1,X2)
thetahat <- c(0.12, 0.03)
thetalow <- c(0.05, 0.01)
thetaup  <- c(0.25, 0.06)
rr <- function(X, theta){exp(theta[1]*X[,1] + theta[2]*X[,2])}
paf.confidence.one2one(X, thetahat, rr, thetalow, thetaup) 

#Approximate method:
Xmean <- data.frame(t(colMeans(X)))
Xvar  <- var(X)
paf.confidence.one2one(Xmean, thetahat, 
function(X, theta){exp(theta[1]*X[,1] + theta[2]*X[,2])}, 
thetalow, thetaup, 
Xvar = Xvar, method = "approximate")

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