Compute risk ratio and uncertainty by fitting binomial models to counts of events relative to possible number of events. The risk ratio is the ratio of the probability of an event under the model fit to the first dataset to the probability under the model fit to the second dataset. Default standard errors are based on the usual MLE asymptotics using a delta-method-based approximation, but standard errors based on the nonparametric bootstrap and on a likelihood ratio procedure can also be computed.
calc_riskRatio_binom(
y,
n,
ciLevel = 0.9,
ciType,
bootSE,
bootControl = NULL,
lrtControl = NULL
)
The primary outputs of this function are as follows: the log of the risk ratio and standard error of that log risk ratio (logRiskRatio
and se_logRiskRatio
) as well the risk ratio itself (riskRatio
). The standard error is based on the usual MLE asymptotics using a delta-method-based approximation. If requested via ciType
, confidence intervals will be returned, as discussed in Details
.
vector of two values, the number of events in the two scenarios
vector of two values, the number of samples (possible occurrences of events) in the two scenarios
statistical confidence level for confidence intervals; in repeated experimentation, this proportion of confidence intervals should contain the true risk ratio. Note that if only one endpoint of the resulting interval is used, for example the lower bound, then the effective confidence level increases by half of one minus ciLevel
. For example, a two-sided 0.90 confidence interval corresponds to a one-sided 0.95 confidence interval.
character vector indicating which type of confidence intervals to compute. See Details
.
logical indicating whether to use the bootstrap to estimate the standard error of the risk ratio
a list of control parameters for the bootstrapping, used only when at least one bootstrap confidence interval is requested via ciType
. See Details
.
list containing a single component, bounds
, which sets the range inside which the algorithm searches for the endpoints of the likelihood ratio-based confidence interval. This avoids numerical issues with endpoints converging to zero and infinity. If an endpoint is not found within the interval, it is set to NA
. Used only when 'lrt'
is one of the ciType
values. Default is (0.01, 100).
Christopher J. Paciorek
ciType
can include one or more of the following: 'delta'
, 'koopman'
, 'lrt'
, 'boot_norm'
, 'boot_perc'
, 'boot_basic'
, 'boot_stud'
, 'boot_bca'
. 'delta'
uses the delta method to compute an asymptotic interval based on the standard error of the log risk ratio. 'koopman'
uses the method described in Koopman (1984), following the implementation discussed in Fageland et al. (2015), including the calculation of Nam (1995). 'lrt'
inverts a likelihood-ratio test. Bootstrap-based options are the normal-based interval using the bootstrap standard error ('boot_norm'
), the percentile bootstrap ('boot_perc'
), the basic bootstrap ('boot_basic'
), the bootstrap-t ('boot_stud'
), and the bootstrap BCA method ('boot_bca'
). See Paciorek et al. for more details.
See fit_pot
for information on the bootControl
argument.
Paciorek, C.J., D.A. Stone, and M.F. Wehner. 2018. Quantifying uncertainty in the attribution of human influence on severe weather. Weather and Climate Extremes 20:69-80. arXiv preprint <https://arxiv.org/abs/1706.03388>.
Koopman, P.A.R. 1984. Confidence intervals for the ratio of two binomial proportions. Biometrics 40: 513-517.
Fagerland, M.W., S. Lydersen, and P. Laake. 2015. Recommended confidence intervals for two independent binomial proportions. Statistical Methods in Medical Research 24: 224-254.
# risk ratio for 40/400 compared to 8/400 events and for
# 4/100 compared to 0/100 events
calc_riskRatio_binom(c(40, 8), c(400, 400), ciType = c('lrt', 'boot_stud', 'koopman'))
# LRT and Koopman methods can estimate lower confidence interval endpoint
# even if estimated risk ratio is infinity:
calc_riskRatio_binom(c(4,0), c(100, 100), ciType = c('lrt', 'boot_stud', 'koopman'))
Run the code above in your browser using DataLab