Description Usage Arguments Note Author(s) Examples
View source: R/paf_confidence_inverse.R
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.
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))
|
X |
Random sample ( |
thetahat |
Estimative of |
rr |
Function for Relative Risk which uses parameter
**Optional** |
thetavar |
Estimator of variance of |
weights |
Survey |
method |
Either |
nsim |
Number of simulations (default: |
confidence |
Confidence level % (default: |
deriv.method.args |
|
deriv.method |
|
force.min |
Boolean indicating whether to force the |
check_thetas |
Checks that theta parameters are correctly inputed |
Xvar |
Variance of exposure levels. |
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
Rodrigo Zepeda-Tello rzepeda17@gmail.com
Dalia Camacho-Garc<c3><ad>a-Forment<c3><ad> daliaf172@gmail.com
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.