Description Usage Arguments Note Author(s) References See Also Examples
View source: R/risk_ratio_approximate_confidence.R
Function that approximates the confidence interval for the integral
\int RR(x;θ)f(x)dx
where f(x) is the density function of the exposure X, RR(x;θ) the relative risk of the exposure with associated parameter θ. In particular this is an approximation when only mean and variance of exposure known
1 2 3 4 | risk.ratio.approximate.confidence(X, Xvar, thetahat, rr, thetavar,
nsim = 1000, confidence = 95, deriv.method.args = list(),
deriv.method = c("Richardson", "complex"), check_thetas = TRUE,
force.min = FALSE)
|
X |
Mean value of exposure levels from a cross-sectional random sample. |
Xvar |
Variance of exposure levels. |
thetahat |
Estimator (vector or matrix) of |
rr |
Function for Relative Risk which uses parameter |
thetavar |
Estimator of variance of **Optional** |
nsim |
Number of simulations |
confidence |
Confidence level % (default: |
deriv.method.args |
|
deriv.method |
|
check_thetas |
Checks that |
force.min |
Boolean indicating whether to force the |
When a sample of the exposure X
is available the method
risk.ratio.confidence should be prefered.
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
Sherif, Y. .s. (1989). The lower confidence limit for the mean of positive random variables. Microelectronics Reliability, 29(2), 151-152.
risk.ratio.confidence for a method when there is a sample of the exposure.
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 | ## Not run:
#' #Example 1: Exponential Relative Risk
#--------------------------------------------
set.seed(18427)
X <- data.frame(rnorm(100))
thetahat <- 0.1
thetavar <- 0.2
Xmean <- data.frame(mean(X[,1]))
Xvar <- var(X[,1])
rr <- function(X,theta){exp(X*theta)}
risk.ratio.approximate.confidence(Xmean, Xvar, thetahat, rr, thetavar)
#We can force RR'.s CI to be >= 1.
#This should be done with extra methodological (philosophical) care as
#RR>= 1 should only be assumed with absolute mathematical certainty
risk.ratio.approximate.confidence(Xmean, Xvar, thetahat, rr, thetavar, force.min = TRUE)
#Example 2: Multivariate Relative Risk
#--------------------------------------------
set.seed(18427)
X1 <- rnorm(1000)
X2 <- runif(1000)
X <- data.frame(t(colMeans(cbind(X1,X2))))
Xvar <- cov(cbind(X1,X2))
thetahat <- c(0.02, 0.01)
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])}
risk.ratio.approximate.confidence(X, Xvar, thetahat, rr, thetavar)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.