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.
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
character vector indicating which type of confidence intervals to compute. See
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
list containing a single component,
ciType can include one or more of the following:
'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.
fit_pot for information on the
The primary outputs of this function are as follows: the log of the risk ratio and standard error of that log risk ratio (
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
Christopher J. Paciorek
Paciorek, C.J., D.A. Stone, and M.F. Wehner. Quantifying uncertainty in the attribution of human influence on severe weather. 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.
1 2 3 4 5 6
# 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'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.