prec_riskdiff | R Documentation |
prec_riskdiff
returns the risk difference and the sample size or the
precision for the provided proportions.
prec_riskdiff( p1, p2, n1 = NULL, conf.width = NULL, r = 1, conf.level = 0.95, method = c("newcombe", "mn", "ac", "wald"), ... )
p1 |
risk among exposed. |
p2 |
risk among unexposed. |
n1 |
number of patients in exposed group. |
conf.width |
precision (the full width of the confidence interval). |
r |
allocation ratio (relative size of exposed and unexposed cohort
( |
conf.level |
confidence level. |
method |
Exactly one of |
... |
other options to uniroot (e.g. |
Exactly one of the parameters n1
or conf.width
must be passed as NULL,
and that parameter is determined from the other.
Newcombe (newcombe
) proposed a confidence interval based on the wilson
score method for the single proportion (see prec_prop). The confidence
interval without continuity correction is implemented from equation 10 in
Newcombe (1998).
Miettinen-Nurminen (mn
) provide a closed from equation for the
restricted maximum likelihood estimate . The implementation is based on
code provided by Yongyi Min on
https://users.stat.ufl.edu/~aa/cda/R/two-sample/R2/index.html.
Agresti-Caffo (ac
) confidence interval is based on the Wald confidence
interval, adding 1 success to each cell of the 2 x 2 table (see Agresti and
Caffo 2000).
uniroot
is used to solve n for the newcombe, ac, and mn
method.
Agresti A (2003) Categorical Data Analysis, Second Edition, Wiley Series in Probability and Statistics, doi: 10.1002/0471249688.
Agresti A and Caffo B (2000) Simple and Effective Confidence Intervals for Proportions and Differences of Proportions Result from Adding Two Successes and Two Failures, The American Statistician, 54(4):280-288.
Miettinen O and Nurminen M (1985) Comparative analysis of two rates, Statistics in Medicine, 4:213-226.
Newcombe RG (1998) Interval estimation for the difference between independent proportions: comparison of eleven methods, Statistics in Medicine, 17:873-890.
Fagerland MW, Lydersen S, and Laake P (2015). Recommended confidence intervals for two independent binomial proportions, Statistical methods in medical research 24(2):224-254.
# proportions of 40 and 30\%, 50 participants, how wide is the CI? prec_riskdiff(p1 = .4, p2 = .3, n1 = 50) # proportions of 40 and 30\%, 50 participants, how many participants for a CI 0.2 wide? prec_riskdiff(p1 = .4, p2 = .3, conf.width = .2) # Validate Newcombe (1998) prec_riskdiff(p1 = 56/70, p2 = 48/80, n1 = 70, r = 70/80, met = "newcombe") # Table IIa prec_riskdiff(p1 = 10/10, p2 = 0/10, n1 = 10, met = "newcombe") # Table IIh # multiple scenarios prec_riskdiff(p1 = c(56/70, 9/10, 6/7, 5/56), p2 = c(48/80, 3/10, 2/7, 0/29), n1 = c(70, 10, 7, 56), r = c(70/80, 1, 1, 56/29), method = "wald")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.