scoreci | R Documentation |
Score-based confidence intervals for the rate (or risk) difference ("RD") or ratio ("RR") for independent binomial or Poisson rates, or for odds ratio ("OR", binomial only). Including options for variance bias correction (from Miettinen & Nurminen), skewness correction ("GNbc" method from Laud & Dane, developed from Gart & Nam, and generalised as "SCAS" in Laud 2017) and continuity adjustment (for strictly conservative coverage).
Also includes score intervals for a single binomial proportion or Poisson rate ("p"). These are based on the Wilson score interval, and when corrected for skewness, coverage is almost identical to the mid-p method, or to Clopper-Pearson when also continuity-adjusted.
Hypothesis tests for association or non-inferiority are provided using the same score, to ensure consistency between test and CI. This function is vectorised in x1, x2, n1, and n2. Vector inputs may also be combined into a single stratified analysis (e.g. meta-analysis), either using fixed effects, or the more general random effects "TDAS" method, which incorporates stratum variability using a t-distribution score (inspired by Hartung-Knapp-Sidik-Jonkman). For fixed-effects analysis of stratified datasets, with weighting = "MH" for RD or RR, or weighting = "INV" for OR, omitting the skewness correction produces the CMH test, together with a coherent confidence interval for the required contrast. Alternatively, weighting = "INV" for any contrast gives intervals consistent with the efficient score test.
scoreci(
x1,
n1,
x2 = 0,
n2 = 0,
distrib = "bin",
contrast = "RD",
level = 0.95,
skew = TRUE,
simpleskew = FALSE,
or_bias = TRUE,
ORbias = NULL,
rr_tang = NULL,
RRtang = NULL,
bcf = ifelse(contrast != "p", TRUE, FALSE),
cc = FALSE,
theta0 = NULL,
precis = 6,
plot = FALSE,
plotmax = 100,
hetplot = FALSE,
xlim = NULL,
ylim = NULL,
stratified = FALSE,
weighting = NULL,
mn_tol = 1e-08,
MNtol = NULL,
wt = NULL,
sda = NULL,
fda = NULL,
dropzeros = FALSE,
random = FALSE,
prediction = FALSE,
warn = TRUE,
...
)
x1 , x2 |
Numeric vectors of numbers of events in group 1 & group 2 respectively. |
n1 , n2 |
Numeric vectors of sample sizes (for binomial rates) or exposure times (for Poisson rates) in each group. |
distrib |
Character string indicating distribution assumed for the input
data: |
contrast |
Character string indicating the contrast of interest: |
level |
Number specifying confidence level (between 0 and 1, default 0.95). |
skew |
Logical (default TRUE) indicating whether to apply skewness correction (for the SCAS or Gart-Nam method) or not (for the Miettinen-Nurminen method). |
simpleskew |
Logical (default FALSE) indicating whether to use the
"simplified" skewness correction instead of the quadratic solution.
See Laud 2021 for details. |
or_bias |
Logical (default is TRUE for |
ORbias |
(deprecated: argument renamed to or_bias.) |
rr_tang |
Logical indicating whether to use Tang's score for RR:
Stheta = (p1hat - p2hat * theta) / p2d (see Tang 2020).
Default TRUE for |
RRtang |
(deprecated: argument renamed to rr_tang.) |
bcf |
Logical (default TRUE) indicating whether to apply 'N-1' variance
correction in the score denominator. Applicable to |
cc |
Number or logical (default FALSE) specifying (amount of) continuity
adjustment. Numeric value between 0 and 0.5 is taken as the gamma parameter
in Laud 2017, Appendix S2 (
|
theta0 |
Number to be used in a one-sided significance test (e.g.
non-inferiority margin). 1-sided p-value will be <0.025 iff 2-sided 95\
excludes theta0. (If
|
precis |
Number (default 6) specifying precision (i.e. number of decimal places) to be used in optimisation subroutine for the confidence interval. |
plot |
Logical (default FALSE) indicating whether to output plot of the score function |
plotmax |
Numeric value indicating maximum value to be displayed on x-axis of plots (useful for ratio contrasts which can be infinite). |
hetplot |
Logical (default FALSE) indicating whether to output plots for evaluating heterogeneity of stratified datasets. |
xlim |
pair of values indicating range of values to be plotted. |
ylim |
pair of values indicating range of values to be plotted. |
stratified |
Logical (default FALSE) indicating whether to combine
vector inputs into a single stratified analysis. |
weighting |
String indicating which weighting method to use if
stratified = "TRUE": |
mn_tol |
Numeric value indicating convergence tolerance to be used in iteration with weighting = "MN". |
MNtol |
(deprecated: argument renamed to mn_tol) |
wt |
Numeric vector containing (optional) user-specified weights. |
sda |
Sparse data adjustment to avoid zero variance when |
fda |
Full data adjustment to avoid zero variance when x1 + x2 = n1 + n2:
Only applied when |
dropzeros |
Logical (default FALSE) indicating whether to drop
uninformative strata for RR/OR (i.e. strata with |
random |
Logical (default FALSE) indicating whether to perform random
effects meta-analysis for stratified data, using the t-distribution (TDAS)
method for stratified data (defined in Laud 2017). |
prediction |
Logical (default FALSE) indicating whether to produce a prediction interval (work in progress). |
warn |
Logical (default TRUE) giving the option to suppress warnings. |
... |
Other arguments. |
A list containing the following components:
a matrix containing estimates of the requested contrast and its confidence interval, and the estimated rates in each group: (p1hat, p2hat) are (r1, r0) from Miettinen-Nurminen, or (r1*, r0*) when stratified; (p1mle, p2mle) are (R1, R0), or (R1*, R0*) when stratified, evaluated at the MLE for the contrast parameter, incorporating any specified skewness/bias corrections.
a matrix containing details of the corresponding 2-sided significance test
against the null hypothesis that p_1 = p_2
, and one-sided significance
tests against the null hypothesis that theta >= or <= theta0.
details of the function call.
If stratified = TRUE
, the
following outputs are added:
a vector of values describing and testing heterogeneity, including a score-based version of a Q statistic and p-value, I^2 and tau^2 to quantify heterogeneity, and a test for qualitative interaction analogous to the Gail and Simon test.
a string indicating the selected weighting method.
a matrix containing stratum estimates and weights.
Pete Laud, p.j.laud@sheffield.ac.uk
Laud PJ. Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2017; 16:334-348.
Laud PJ. Corrigendum: Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2018; 17:290-293.
Laud PJ, Dane A. Confidence intervals for the difference between independent binomial proportions: comparison using a graphical approach and moving averages. Pharmaceutical Statistics 2014; 13(5):294-308.
Miettinen OS, Nurminen M. Comparative analysis of two rates. Statistics in Medicine 1985; 4:213-226.
Farrington CP, Manning G. Test statistics and sample size formulae for comparative binomial trials with null hypothesis of non-zero risk difference or non-unity relative risk. Statistics in Medicine 1990; 9(12):1447-1454.
Gart JJ. Analysis of the common odds ratio: corrections for bias and skewness. Bulletin of the International Statistical Institute 1985, 45th session, book 1, 175-176.
Gart JJ, Nam Jm. Approximate interval estimation of the ratio of binomial parameters: a review and corrections for skewness. Biometrics 1988; 44(2):323-338.
Gart JJ, Nam Jm. Approximate interval estimation of the difference in binomial parameters: correction for skewness and extension to multiple tables. Biometrics 1990; 46(3):637-643.
Tang Y. Score confidence intervals and sample sizes for stratified comparisons of binomial proportions. Statistics in Medicine 2020; 39:3427-3457.
# Binomial RD, SCAS method:
scoreci(
x1 = c(12, 19, 5), n1 = c(16, 29, 56),
x2 = c(1, 22, 0), n2 = c(16, 30, 29)
)
# Binomial RD, MN method:
scoreci(
x1 = c(12, 19, 5), n1 = c(16, 29, 56),
x2 = c(1, 22, 0), n2 = c(16, 30, 29), skew = FALSE
)
# Poisson RR, SCAS method:
scoreci(x1 = 5, n1 = 56, x2 = 0, n2 = 29, distrib = "poi", contrast = "RR")
# Poisson RR, MN method:
scoreci(
x1 = 5, n1 = 56, x2 = 0, n2 = 29, distrib = "poi",
contrast = "RR", skew = FALSE
)
# Binomial rate, SCAS method:
scoreci(x1 = c(5, 0), n1 = c(56, 29), contrast = "p")
# Binomial rate, Wilson score method:
scoreci(x1 = c(5, 0), n1 = c(56, 29), contrast = "p", skew = FALSE)
# Poisson rate, SCAS method:
scoreci(x1 = c(5, 0), n1 = c(56, 29), distrib = "poi", contrast = "p")
# Stratified example, using data from Hartung & Knapp:
scoreci(
x1 = c(15, 12, 29, 42, 14, 44, 14, 29, 10, 17, 38, 19, 21),
x2 = c(9, 1, 18, 31, 6, 17, 7, 23, 3, 6, 12, 22, 19),
n1 = c(16, 16, 34, 56, 22, 54, 17, 58, 14, 26, 44, 29, 38),
n2 = c(16, 16, 34, 56, 22, 55, 15, 58, 15, 27, 45, 30, 38),
stratified = TRUE
)
# "Random effects" TDAS example, using data from Hartung & Knapp:
scoreci(
x1 = c(15, 12, 29, 42, 14, 44, 14, 29, 10, 17, 38, 19, 21),
x2 = c(9, 1, 18, 31, 6, 17, 7, 23, 3, 6, 12, 22, 19),
n1 = c(16, 16, 34, 56, 22, 54, 17, 58, 14, 26, 44, 29, 38),
n2 = c(16, 16, 34, 56, 22, 55, 15, 58, 15, 27, 45, 30, 38),
stratified = TRUE, random = TRUE
)
# Stratified example, with extremely rare instance of non-calculable skewness
# correction seen on plot of score function:
scoreci(
x1 = c(1, 16), n1 = c(20, 40), x2 = c(0, 139), n2 = c(80, 160),
contrast = "RD", skew = TRUE, simpleskew = FALSE,
distrib = "bin", stratified = TRUE, plot = TRUE, weighting = "IVS"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.