| Title: | Confidence Intervals and Tests for Comparisons of Binomial Proportions or Poisson Rates |
|---|---|
| Description: | Computes confidence intervals for binomial or Poisson rates and their differences or ratios. Including the rate (or risk) difference ('RD') or rate ratio (or relative risk, 'RR') for binomial proportions or Poisson rates, and odds ratio ('OR', binomial only). Also confidence intervals for RD, RR or OR for paired binomial data, and estimation of a proportion from clustered binomial data. Includes skewness-corrected asymptotic score ('SCAS') methods, which have been developed in Laud (2017) <doi:10.1002/pst.1813> from Miettinen and Nurminen (1985) <doi:10.1002/sim.4780040211> and Gart and Nam (1988) <doi:10.2307/2531848>, and in Laud (2025, under review) for paired proportions. The same score produces hypothesis tests that are improved versions of the non-inferiority test for binomial RD and RR by Farrington and Manning (1990) <doi:10.1002/sim.4780091208>, or a generalisation of the McNemar test for paired data. The package also includes MOVER methods (Method Of Variance Estimates Recovery) for all contrasts, derived from the Newcombe method but with options to use equal-tailed intervals in place of the Wilson score method, and generalised for Bayesian applications incorporating prior information. So-called 'exact' methods for strictly conservative coverage are approximated using continuity adjustments, and the amount of adjustment can be selected to avoid over-conservative coverage. Also includes methods for stratified calculations (e.g. meta-analysis), either with fixed effect assumption (matching the CMH test) or incorporating stratum heterogeneity. |
| Authors: | Pete Laud [aut, cre] (ORCID: <https://orcid.org/0000-0002-3766-7090>) |
| Maintainer: | Pete Laud <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.0.9000 |
| Built: | 2026-05-22 08:34:32 UTC |
| Source: | https://github.com/petelaud/ratesci |
Data from systematic review of the effect of cisapride for treatment of non-ulcer dyspepsia (Hartung & Knapp 2001)
cisapridecisapride
A data frame with five variables:
Study author
Number of events (successes) in cisapride-treated group
Number of patients in cisapride-treated group
Number of events (successes) in placebo group
Number of patients in placebo group
Asymptotic Score confidence intervals for a proportion estimated from a clustered sample, as decribed by Saha et al. 2016. With optional skewness correction to improve interval location (to be evaluated).
clusterpci(x, n, level = 0.95, skew = TRUE, cc = FALSE, theta0 = 0.5)clusterpci(x, n, level = 0.95, skew = TRUE, cc = FALSE, theta0 = 0.5)
x |
Numeric vector of number of events per cluster. |
n |
Numeric vector of sample sizes per cluster. |
level |
Number specifying confidence level (between 0 and 1, default 0.95). |
skew |
Logical (default TRUE) indicating whether to apply skewness correction or not. (To be evaluated) |
cc |
Number or logical (default FALSE) specifying (amount of) continuity
adjustment. Numeric value is taken as the gamma parameter in Laud 2017,
Appendix S2 (default 0.5 for 'conventional' adjustment if |
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. |
A list containing the following components:
the estimate and confidence interval for p and the specified confidence level, along with estimates of the ICC and the variance inflation factor, xihat.
one-sided significance tests against the null hypothesis that theta >= or <= theta0 as specified.
details of the function call.
Pete Laud, [email protected]
Saha K, Miller D and Wang S. A comparison of some approximate confidence intervals for a single proportion for clustered binary outcome data. Int J Biostat 2016; 12:1–18
Short MI et al. A novel confidence interval for a single proportion in the presence of clustered binary outcome data. Stat Meth Med Res 2020; 29(1):111–121
# Data example from Liang 1992, used in Saha 2016 and Short 2020: # Note Saha states the ICC estimate is 0.1871 and Short makes it 0.1855. # I agree with Short - CI limits differ from Saha to the 4th dp. x <- c(rep(c(0, 1), c(36, 12)), rep(c(0, 1, 2), c(15, 7, 1)), rep(c(0, 1, 2, 3), c(5, 7, 3, 2)), rep(c(0, 1, 2), c(3, 3, 1)), c(0, 2, 3, 4, 6)) n <- c(rep(1, 48), rep(2, 23), rep(3, 17), rep(4, 7), rep(6, 5)) # Wilson-based interval clusterpci(x, n, skew = FALSE) # Skewness-corrected version clusterpci(x, n, skew = TRUE) # With continuity adjustment clusterpci(x, n, skew = FALSE, cc = TRUE)# Data example from Liang 1992, used in Saha 2016 and Short 2020: # Note Saha states the ICC estimate is 0.1871 and Short makes it 0.1855. # I agree with Short - CI limits differ from Saha to the 4th dp. x <- c(rep(c(0, 1), c(36, 12)), rep(c(0, 1, 2), c(15, 7, 1)), rep(c(0, 1, 2, 3), c(5, 7, 3, 2)), rep(c(0, 1, 2), c(3, 3, 1)), c(0, 2, 3, 4, 6)) n <- c(rep(1, 48), rep(2, 23), rep(3, 17), rep(4, 7), rep(6, 5)) # Wilson-based interval clusterpci(x, n, skew = FALSE) # Skewness-corrected version clusterpci(x, n, skew = TRUE) # With continuity adjustment clusterpci(x, n, skew = FALSE, cc = TRUE)
Data from systematic review of the effect of graduated compression stockings for prevention of DVT (Roderick et al. 2005)
compresscompress
A data frame with five variables:
Study author
Number of events (DVTs) in GCS-treated group
Number of patients in GCS-treated group
Number of events (DVTs) in control group
Number of patients in control group
Data from systematic review of the effect on mortality of corticosteroids in traumatic brain injury (reported with MRC CRASH trial results, Roberts et al. 2001)
crashcrash
A data frame with five variables:
Study author and year
Number of deaths in steroid-treated group
Number of patients in steroid-treated group
Number of deaths in control group
Number of patients in control group
https://pubmed.ncbi.nlm.nih.gov/15474134
Generalised approximate Bayesian confidence intervals based on a Beta (for binomial rates) or Gamma (for Poisson rates) conjugate priors. Encompassing the Jeffreys method (with Beta(0.5, 0.5) or Gamma(0.5) respectively), as well as any user-specified prior distribution. Clopper-Pearson method (as quantiles of a Beta distribution as described in Brown et al. 2001) also included by way of a "continuity adjustment" parameter.
jeffreysci( x, n, ai = 0.5, bi = 0.5, cc = 0, level = 0.95, distrib = "bin", adj = TRUE, ... )jeffreysci( x, n, ai = 0.5, bi = 0.5, cc = 0, level = 0.95, distrib = "bin", adj = TRUE, ... )
x |
Numeric vector of number of events. |
n |
Numeric vector of sample sizes (for binomial rates) or exposure times (for Poisson rates). |
ai, bi
|
Numbers defining the Beta prior distribution (default 'ai = bi = 0.5“ for Jeffreys interval). Gamma prior for Poisson rates requires only ai. |
cc |
Number or logical specifying (amount of) "continuity adjustment".
cc = 0 (default) gives Jeffreys interval, |
level |
Number specifying confidence level (between 0 and 1, default 0.95). |
distrib |
Character string indicating distribution assumed for the input
data: |
adj |
Logical (default TRUE) indicating whether to apply the boundary adjustment recommended on p108 of Brown et al. (set to FALSE if informative priors are used). |
... |
Other arguments. |
A list containing the following components:
a matrix containing estimated rate(s), and corresponding approximate Bayesian confidence interval, and the input values x and n.
details of the function call.
Pete Laud, [email protected]
Laud PJ. Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2017; 16:334-348.
Brown LD, Cai TT, DasGupta A. Interval estimation for a binomial proportion. Statistical Science 2001; 16(2):101-133
# Jeffreys method: jeffreysci(x = 5, n = 56)# Jeffreys method: jeffreysci(x = 5, n = 56)
Wrapper function for the MOVER-B methods. Approximate Bayesian 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). (developed from Newcombe, Donner & Zou, Li et al, and Fagerland & Newcombe, and generalised as "MOVER-B" in Laud 2017) including special case "MOVER-J" using non-informative priors with optional continuity adjustment. This function is vectorised in x1, x2, n1, and n2.
moverbci( x1, n1, x2, n2, a1 = 0.5, b1 = 0.5, a2 = 0.5, b2 = 0.5, distrib = "bin", contrast = "RD", level = 0.95, cc = 0, ... )moverbci( x1, n1, x2, n2, a1 = 0.5, b1 = 0.5, a2 = 0.5, b2 = 0.5, distrib = "bin", contrast = "RD", level = 0.95, cc = 0, ... )
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. |
a1, b1, a2, b2
|
Numbers defining the Beta(ai,bi) prior distributions for each group (default ai = bi = 0.5 for Jeffreys uninformative priors). Gamma priors for Poisson rates require only a1, a2. |
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). |
cc |
Number or logical specifying (amount of) continuity adjustment
(default FALSE). Numeric value is taken as the gamma parameter in Laud
2017, Appendix S2 (default 0.5 if |
... |
Additional arguments. |
A list containing the following components:
a matrix containing estimates of the rates in each group and of the requested contrast, with its confidence interval
details of the function call
Pete Laud, [email protected]
Confidence intervals applying the MOVER method ("Method of Variance Estimates Recovery", developed from the Newcombe method for binomial RD) across different contrasts (RD, RR, OR) and distributions (binomial, Poisson) using equal-tailed Jeffreys intervals instead of the Wilson score method for the event rates. Also allows more general Beta and Gamma priors for an approximate Bayesian confidence interval incorporating prior beliefs about the group event rates. This function is vectorised in x1, x2, n1, and n2.
moverci( x1, n1, x2 = NULL, n2 = NULL, distrib = "bin", contrast = "RD", level = 0.95, a1 = 0.5, b1 = 0.5, a2 = 0.5, b2 = 0.5, type = "jeff", adj = FALSE, cc = FALSE, ... )moverci( x1, n1, x2 = NULL, n2 = NULL, distrib = "bin", contrast = "RD", level = 0.95, a1 = 0.5, b1 = 0.5, a2 = 0.5, b2 = 0.5, type = "jeff", adj = FALSE, cc = FALSE, ... )
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). |
a1, b1, a2, b2
|
Numbers defining the Beta(ai,bi) prior distributions for each group (default ai = bi = 0.5 for Jeffreys method). Gamma priors for Poisson rates require only a1, a2. |
type |
Character string indicating the method used for the intervals for
the individual group rates. |
adj |
Logical (default FALSE) indicating whether to apply the boundary
adjustment for Jeffreys intervals recommended on p108 of Brown et al.
( |
cc |
Number or logical specifying (amount of) continuity adjustment
(default FALSE). Numeric value is taken as the gamma parameter in Laud
2017, Appendix S2 (default 0.5 if |
... |
Additional arguments. |
A list containing the following components:
a matrix containing estimates of the rates in each group and of the requested contrast, with its confidence interval.
details of the function call.
Pete Laud, [email protected]
Laud PJ. Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2017; 16:334-348.
Newcombe RG. Interval estimation for the difference between independent proportions: comparison of eleven methods. Statistics in Medicine 1998; 17(8):873-890.
Donner A, Zou G. Closed-form confidence intervals for functions of the normal mean and standard deviation. Statistical Methods in Medical Research 2012; 21(4):347-359.
Fagerland MW, Newcombe RG. Confidence intervals for odds ratio and relative risk based on the inverse hyperbolic sine transformation. Statistics in Medicine 2013; 32(16):2823-2836.
Li HQ, Tang ML, Wong WK. Confidence intervals for ratio of two Poisson rates using the method of variance estimates recovery. Computational Statistics 2014; 29(3-4):869-889.
# Binomial RD, MOVER-J method: moverci(x1 = 5, n1 = 56, x2 = 0, n2 = 29) # Binomial RD, Newcombe method: moverci(x1 = 5, n1 = 56, x2 = 0, n2 = 29, type = "wilson")# Binomial RD, MOVER-J method: moverci(x1 = 5, n1 = 56, x2 = 0, n2 = 29) # Binomial RD, Newcombe method: moverci(x1 = 5, n1 = 56, x2 = 0, n2 = 29, type = "wilson")
Confidence intervals for comparisons of two binomial rates. This convenience wrapper function produces a selection of the methods below as appropriate for the odds ratio contrast (OR), with or without continuity adjustment.
SCAS (skewness-corrected asymptotic score)
Miettinen-Nurminen, Gart and unadjusted Asymptotic Score methods
MOVER-R Wilson
MOVER-R Jeffreys
Approximate normal (Woolf/Gart) methods (strongly advise this is not used for any purpose but included for reference)
orci(x1, n1, x2, n2, level = 0.95, std_est = TRUE, cc = FALSE, precis = 8)orci(x1, n1, x2, n2, level = 0.95, std_est = TRUE, cc = FALSE, precis = 8)
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. |
level |
Number specifying confidence level (between 0 and 1, default 0.95). |
std_est |
logical, specifying if the crude point estimate for the contrast value should be returned (TRUE, default) or the method-specific alternative point estimate consistent with a 0% confidence interval (FALSE). |
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 ( |
precis |
Number (default 8) specifying precision (i.e. number of decimal places) to be used in root-finding subroutine for the score confidence intervals. (Note other methods use closed-form calculations so are not affected.) |
Pete Laud, [email protected]
Laud PJ. Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2017; 16:334-348. (Appendix A.4)
Confidence intervals for the rate (or risk) difference ("RD"), rate ratio
("RR") or conditional odds ratio ("OR"), for paired binomial data. (For
paired Poisson rates, suggest use the tdasci function with distrib = "poi",
and weighting = "MH", with pairs as strata.)
This function applies the score-based Tango and Tang methods for RD and
RR respectively, with iterative and closed-form versions, and an added
skewness correction for improved one-sided coverage.
Also includes MOVER options using the Method of Variance Estimates Recovery
for paired RD and RR, incorporating Newcombe's correlation correction, and
some simpler methods by Bonett & Price for RD and RR.
For OR, intervals are produced based on transforming various intervals for
the single proportion, including SCASp, mid-p and Jeffreys.
All methods have options for continuity adjustment, and the magnitude of
adjustment can be customised.
pairbinci( x, level = 0.95, contrast = "RD", method = ifelse(contrast == "OR", "SCASp", "Score"), moverbase = ifelse(method %in% c("MOVER", "MOVER_newc", "BP"), "jeff", NULL), bcf = TRUE, skew = TRUE, cc = FALSE, theta0 = NULL, precis = 6, warn = TRUE, method_RD = NULL, method_RR = NULL, method_OR = NULL, cctype = NULL, ... )pairbinci( x, level = 0.95, contrast = "RD", method = ifelse(contrast == "OR", "SCASp", "Score"), moverbase = ifelse(method %in% c("MOVER", "MOVER_newc", "BP"), "jeff", NULL), bcf = TRUE, skew = TRUE, cc = FALSE, theta0 = NULL, precis = 6, warn = TRUE, method_RD = NULL, method_RR = NULL, method_OR = NULL, cctype = NULL, ... )
x |
A numeric vector object specified as c(a, b, c, d)
where: |
level |
Number specifying confidence level (between 0 and 1, default 0.95). |
contrast |
Character string indicating the contrast of interest: |
method |
Character string indicating the confidence interval method
to be used. The following are available for |
moverbase |
Character string indicating the base method used as input for the MOVER methods for RD or RR (when method = "MOVER" or "MOVER_newc"), and for the Hybrid BP method for RR: "jeff" = Jeffreys equal-tailed interval (default), "SCASp" = skewness-corrected score, "midp" = mid-p, "wilson" = Wilson score (not recommended, known to be skewed). |
bcf |
Logical (default FALSE) indicating whether to apply variance bias correction in the score denominator. (Under evaluation, manuscript under review.) |
skew |
Logical (default TRUE) indicating whether to apply skewness correction or not. (Under evaluation, manuscript under review.)
|
cc |
Number or logical (default FALSE) specifying (amount of) continuity adjustment. When a score-based method is used, cc = 0.5 corresponds to the continuity-corrected McNemar test. |
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. NB: can also be used for a superiority test by setting theta0 = 0. |
precis |
Number (default 6) specifying precision (i.e. number of decimal places) to be used in optimisation subroutine for the confidence interval. |
warn |
Logical (default TRUE) giving the option to suppress warnings. |
method_RD |
(deprecated: parameter renamed to method) |
method_RR |
(deprecated: parameter renamed to method) |
method_OR |
(deprecated: parameter renamed to method) |
cctype |
(deprecated: new equivariant cc method implemented instead.) |
... |
Other arguments. |
A list containing the following components:
the input data in 2x2 matrix form.
the requested contrast, with its confidence interval and the specified confidence level, along with estimates of the marginal probabilities and the correlation coefficient (uncorrected and corrected).
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 as specified.
details of the function call.
Pete Laud, [email protected]
Tango T. Equivalence test and confidence interval for the difference in proportions for the paired-sample design. Statistics in Medicine 1998; 17:891-908
Newcombe RG. Improved confidence intervals for the difference between binomial proportions based on paired data. Statistics in Medicine 1998; 17:2635-2650
Tango T. Improved confidence intervals for the difference between binomial proportions based on paired data by Robert G. Newcombe, Statistics in Medicine, 17, 2635-2650 (1998). Statistics in Medicine 1999; 18(24):3511-3513
Nam J-M, Blackwelder WC. Analysis of the ratio of marginal probabilities in a matched-pair setting. Stat Med 2002; 21(5):689–699
Tang N-S, Tang M-L, Chan ISF. On tests of equivalence via non-unity relative risk for matched-pair design. Statistics in Medicine 2003; 22:1217-1233
Agresti A, Min Y. Simple improved confidence intervals for comparing matched proportions. Statistics in Medicine 2005; 24:729-740
Bonett DG, Price RM. Confidence intervals for a ratio of binomial proportions based on paired data. Statistics in Medicine 2006; 25:3039-3047
Tang M-L, Li H-Q, Tang N-S. Confidence interval construction for proportion ratio in paired studies based on hybrid method. Statistical Methods in Medical Research 2010; 21(4):361-378
Tang N-S et al. Asymptotic confidence interval construction for proportion difference in medical studies with bilateral data. Statistical Methods in Medical Research. 2011; 20(3):233-259
Yang Z, Sun X and Hardin JW. A non-iterative implementation of Tango's score confidence interval for a paired difference of proportions. Statistics in Medicine 2013; 32:1336-1342
Fagerland MW, Lydersen S, Laake P. Recommended tests and confidence intervals for paired binomial proportions. Statistics in Medicine 2014; 33(16):2850-2875
Laud PJ. Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2017; 16:334-348.
DelRocco N et al. New Confidence Intervals for Relative Risk of Two Correlated Proportions. Statistics in Biosciences 2023; 15:1–30
Chang P et al. Continuity corrected score confidence interval for the difference in proportions in paired data. Journal of Applied Statistics 2024; 51-1:139-152
Laud PJ. Comments on "New Confidence Intervals for Relative Risk of Two Correlated Proportions" (2023). Statistics in Biosciences 2025; https://doi.org/10.1007/s12561-025-09479-4
Laud PJ. Improved confidence intervals and tests for paired binomial proportions. (2025, Under review)
# Example from Fagerland et al 2014 # SCAS method for RD pairbinci(x = c(1, 1, 7, 12), contrast = "RD", method = "Score") # Tango method pairbinci(x = c(1, 1, 7, 12), contrast = "RD", method = "Score", skew = FALSE, bcf = FALSE) # MOVER-NJ method pairbinci(x = c(1, 1, 7, 12), contrast = "RD", method = "MOVER_newc", moverbase = "jeff") # SCAS for RR pairbinci(x = c(1, 1, 7, 12), contrast = "RR", method = "Score") # Tang method pairbinci(x = c(1, 1, 7, 12), contrast = "RR", method = "Score", skew = FALSE, bcf = FALSE) # MOVER-NJ pairbinci(x = c(1, 1, 7, 12), contrast = "RR", method = "MOVER_newc", moverbase = "jeff") # Transformed SCASp method for OR pairbinci(x = c(1, 1, 7, 12), contrast = "OR", method = "SCASp") # Transformed Wilson method pairbinci(x = c(1, 1, 7, 12), contrast = "OR", method = "wilson")# Example from Fagerland et al 2014 # SCAS method for RD pairbinci(x = c(1, 1, 7, 12), contrast = "RD", method = "Score") # Tango method pairbinci(x = c(1, 1, 7, 12), contrast = "RD", method = "Score", skew = FALSE, bcf = FALSE) # MOVER-NJ method pairbinci(x = c(1, 1, 7, 12), contrast = "RD", method = "MOVER_newc", moverbase = "jeff") # SCAS for RR pairbinci(x = c(1, 1, 7, 12), contrast = "RR", method = "Score") # Tang method pairbinci(x = c(1, 1, 7, 12), contrast = "RR", method = "Score", skew = FALSE, bcf = FALSE) # MOVER-NJ pairbinci(x = c(1, 1, 7, 12), contrast = "RR", method = "MOVER_newc", moverbase = "jeff") # Transformed SCASp method for OR pairbinci(x = c(1, 1, 7, 12), contrast = "OR", method = "SCASp") # Transformed Wilson method pairbinci(x = c(1, 1, 7, 12), contrast = "OR", method = "wilson")
Confidence intervals for the single binomial or Poisson rate. This convenience wrapper function produces a selection of alternative methods. The first three are recommended for achieving 1-sided and 2-sided coverage probability close to the nominal levels (see Laud 2017 and Laud 2018):
SCAS (skewness-corrected asymptotic score)
Jeffreys
mid-p (two versions, using exact calculation or approximation via Beta/Gamma distribution, see p.115 of Brown et al.)) The following more approximate methods are included for users wishing to use a more established or commonly used method:
Wilson score
Agresti-Coull
Wald (strongly advise this is not used for any purpose but included for reference)
All methods can be made more conservative with a 'continuity adjustment',
which may either be specified as TRUE, or an intermediate 'compromise'
value between 0 and 0.5 may be selected. When cc is TRUE or 0.5, the
mid-p method becomes the 'exact' Clopper-Pearson interval (or Garwood for Poisson
rates), and the output also includes the slightly less conservative Blaker
interval.
Hence the full list of conservative methods produced (when cc is TRUE) is:
SCAS_cc
Jeffreys_cc
Clopper-Pearson 'exact' (two identical versions, using exact calculation or approximation via Beta/Gamma distribution))
Wilson_cc
Wald_cc (strongly advise this is not used for any purpose but included for reference)
Blaker 'exact'
Note that Brown et al's Beta formulation perfectly matches the exact interval
when cc is TRUE (i.e. for Clopper-Pearson) but not when cc is FALSE
(for mid-p)
All methods except Agresti-Coull have equivalent formulae for the Poisson
distribution: Garwood for Clopper-Pearson, Rao score for Wilson score.
Jeffreys has a Poisson equivalent using the Gamma distribution. e.g. See Brown
et al. 2003, Swift 2009 and Laud 2017. The formulation for the approximate
mid-p interval using Gamma distribution for a Poisson rate has been deduced
by the package author from the corresponding formulae from Brown et al., and
has not (to the best of my knowledge) been published.
This function is vectorised in x, n.
rateci( x, n, distrib = "bin", level = 0.95, std_est = TRUE, cc = FALSE, precis = 8 )rateci( x, n, distrib = "bin", level = 0.95, std_est = TRUE, cc = FALSE, precis = 8 )
x |
Numeric vector of number of events. |
n |
Numeric vector of sample size (for binomial rate) or exposure times (for Poisson rate). |
distrib |
Character string indicating distribution assumed for the input data: "bin" = binomial (default), "poi" = Poisson. |
level |
Number specifying confidence level (between 0 and 1, default 0.95). |
std_est |
logical, specifying if the crude point estimate for the proportion value x/n should be returned (TRUE, default) or the method-specific alternative point estimate consistent with a 0% confidence interval (FALSE). |
cc |
Number or logical (default FALSE) specifying continuity adjustment. |
precis |
Number (default 8) specifying precision (i.e. number of decimal places) to be used in root-finding subroutine for the exact confidence interval. (Note all other methods use closed-form calculations so are not affected.) |
A list containing, for each method, a matrix containing lower and upper confidence limits and point estimate of p for each value of x and n. Methods shown depend on the cc parameter, which specifies whether the continuity adjustment is applied to the SCAS and Jeffreys methods. The corresponding 'exact' method is Clopper-Pearson/Garwood if cc = TRUE and mid-p if cc = FALSE. An additional output object 'estimates' is provided for a side-by-side comparison of all methods. These are grouped depending on the cc argument (if cc = TRUE then the continuity-adjusted and exact strictly conservative methods are included) The last list item contains details of the function call.
Pete Laud, [email protected]
Laud PJ. Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2017; 16:334-348. (Appendix A.4)
Brown LD, Cai TT and DasGupta A. Interval estimation for a binomial proportion. Statistical Science 2001; 16(2):101-133.
Garwood F. Fiducial limits for the Poisson distribution. Biometrika 1936; 28(3-4):437, doi:10.1093/biomet/28.3-4.437.
Confidence intervals for comparisons of two binomial or Poisson rates. This convenience wrapper function produces a selection of the methods below as appropriate for the selected distribution (binomial or Poisson) for the rate difference (RD) contrast, with or without continuity adjustment.
SCAS (skewness-corrected asymptotic score)
Miettinen-Nurminen, Mee, Koopman, Gart-Nam Asymptotic Score methods
MOVER Wilson (aka Newcombe Hybrid Score for binomial RD)
MOVER Jeffreys
Agresti-Caffo (binomial RD only)
Approximate normal (Wald) methods (strongly advise this is not used for any purpose but included for reference)
rdci( x1, n1, x2, n2, distrib = "bin", level = 0.95, std_est = TRUE, cc = FALSE, precis = 8 )rdci( x1, n1, x2, n2, distrib = "bin", level = 0.95, std_est = TRUE, cc = FALSE, precis = 8 )
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: |
level |
Number specifying confidence level (between 0 and 1, default 0.95). |
std_est |
logical, specifying if the crude point estimate for the contrast value should be returned (TRUE, default) or the method-specific alternative point estimate consistent with a 0% confidence interval (FALSE). |
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 ( |
precis |
Number (default 8) specifying precision (i.e. number of decimal places) to be used in root-finding subroutine for the score confidence intervals. (Note other methods use closed-form calculations so are not affected.) |
Pete Laud, [email protected]
Laud PJ. Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2017; 16:334-348. (Appendix A.4)
Confidence intervals for comparisons of two binomial or Poisson rates. This convenience wrapper function produces a selection of the methods below as appropriate for the selected distribution (binomial or Poisson) for the rate ratio (/relative risk) contrast (RR), with or without continuity adjustment.
SCAS (skewness-corrected asymptotic score)
Miettinen-Nurminen,Koopman, Gart-Nam Asymptotic Score methods
MOVER-R Wilson
MOVER-R Jeffreys
Approximate normal (Katz log) methods (strongly advise this is not used for any purpose but included for reference)
rrci( x1, n1, x2, n2, distrib = "bin", level = 0.95, std_est = TRUE, cc = FALSE, precis = 8 )rrci( x1, n1, x2, n2, distrib = "bin", level = 0.95, std_est = TRUE, cc = FALSE, precis = 8 )
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: |
level |
Number specifying confidence level (between 0 and 1, default 0.95). |
std_est |
logical, specifying if the crude point estimate for the contrast value should be returned (TRUE, default) or the method-specific alternative point estimate consistent with a 0% confidence interval (FALSE). |
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 ( |
precis |
Number (default 8) specifying precision (i.e. number of decimal places) to be used in root-finding subroutine for the score confidence intervals. (Note other methods use closed-form calculations so are not affected.) |
Pete Laud, [email protected]
Laud PJ. Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2017; 16:334-348. (Appendix A.4)
Wrapper function for the SCAS method. 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), or the single rate ("p"). (This is the "GNbc" method from Laud & Dane, developed from Gart & Nam, and generalised as "SCAS" in Laud 2017) including optional continuity adjustment. 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). This method assumes the contrast is constant across strata (fixed effects). For a 'random-effects' method use tdasci (or scoreci with random = TRUE).
scasci( x1, n1, x2 = NULL, n2 = NULL, distrib = "bin", contrast = "RD", level = 0.95, cc = FALSE, theta0 = NULL, precis = 6, plot = FALSE, hetplot = FALSE, xlim = NULL, ylim = NULL, plotmax = 100, stratified = FALSE, weighting = NULL, mn_tol = 1e-08, MNtol = NULL, wt = NULL, warn = TRUE, ... )scasci( x1, n1, x2 = NULL, n2 = NULL, distrib = "bin", contrast = "RD", level = 0.95, cc = FALSE, theta0 = NULL, precis = 6, plot = FALSE, hetplot = FALSE, xlim = NULL, ylim = NULL, plotmax = 100, stratified = FALSE, weighting = NULL, mn_tol = 1e-08, MNtol = NULL, wt = NULL, 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). |
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. By default, a two-sided test against theta0 = 0 (for RD) or 1 (for RR/OR) is also output. |
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 |
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. |
plotmax |
Numeric value indicating maximum value to be displayed on x-axis of plots (useful for ratio contrasts which can be infinite). |
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. |
warn |
Logical (default TRUE) giving the option to suppress warnings. |
... |
Other arguments. |
A list containing the following components:
a matrix containing estimates of the rates in each group and of the requested contrast, with its confidence interval
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
a string indicating the selected weighting method
a matrix containing stratum estimates and weights
Pete Laud, [email protected]
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.
Closed-form function for computing confidence intervals for a single rate.
Note: For associated hypothesis tests, use scoreci() with contrast = "p".
This function is vectorised in x, n.
scaspci( x, n, distrib = "bin", level = 0.95, bcf = FALSE, bign = n, xihat = 1, cc = FALSE, ... )scaspci( x, n, distrib = "bin", level = 0.95, bcf = FALSE, bign = n, xihat = 1, cc = FALSE, ... )
x |
Numeric vector of number of events. |
n |
Numeric vector of sample sizes (for binomial rates) or exposure times (for Poisson rates). |
distrib |
Character string indicating distribution assumed for the input
data: |
level |
Number specifying confidence level (between 0 and 1, default 0.95). |
bcf |
Logical (default TRUE) indicating whether to apply bias correction
in the score denominator. Applicable to |
bign |
Sample size N to be used in the calculation of bcf, if different
from n. (Used by transformed SCASp method for paired conditional OR in
|
xihat |
Number specifying estimated variance inflation factor for a
skewness corrected version of the Saha Wilson Score interval for clustered
binomial proportions. Need to calculate using BMS and WMS as per Saha 2016.
Used by |
cc |
Number or logical (default FALSE) specifying (amount of) continuity adjustment. Numeric value is taken as the gamma parameter in Laud 2017, Appendix S2 (default 0.5 for 'conventional' adjustment if cc = TRUE). |
... |
Other arguments. |
A list containing the following components:
a matrix containing estimated rate(s), the SCAS confidence interval, and the input values x and n.
details of the function call.
Pete Laud, [email protected]
Laud PJ. Equal-tailed confidence intervals for comparison of rates. Pharmaceutical Statistics 2017; 16:334-348. (Appendix A.4)
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, ... )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, [email protected]
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" )# 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" )
Wrapper function for the TDAS method. Score-based stratified 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), or for prevalence or incidence rate ("p"). This function combines vector inputs into a single stratified random effects analysis (e.g. meta-analysis), incorporating any stratum variability into the confidence interval.
Applies recommended default options, including bias correction for OR from Laud 2018. Should a user wish to compute TDAS intervals without bias correction to match results from Laud 2017, use scoreci() with or_bias = FALSE.
tdasci( x1, n1, x2 = NULL, n2 = NULL, distrib = "bin", contrast = "RD", level = 0.95, cc = FALSE, theta0 = NULL, precis = 6, plot = FALSE, hetplot = FALSE, plotmax = 100, xlim = NULL, ylim = NULL, weighting = NULL, mn_tol = 1e-08, MNtol = NULL, wt = NULL, skew = TRUE, prediction = FALSE, warn = TRUE, ... )tdasci( x1, n1, x2 = NULL, n2 = NULL, distrib = "bin", contrast = "RD", level = 0.95, cc = FALSE, theta0 = NULL, precis = 6, plot = FALSE, hetplot = FALSE, plotmax = 100, xlim = NULL, ylim = NULL, weighting = NULL, mn_tol = 1e-08, MNtol = NULL, wt = NULL, skew = TRUE, 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). |
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. By default, a two-sided test against theta0 = 0 (for RD) or 1 (for RR/OR) is also output. |
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 |
hetplot |
Logical (default FALSE) indicating whether to output plots for evaluating heterogeneity of stratified datasets. |
plotmax |
Numeric value indicating maximum value to be displayed on x-axis of plots (useful for ratio contrasts which can be infinite). |
xlim |
pair of values indicating range of values to be plotted. |
ylim |
pair of values indicating range of values to be plotted. |
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. |
skew |
Logical (default TRUE) indicating whether to apply skewness correction (for the SCAS method recommended in Laud 2017) or not (for the Miettinen-Nurminen method) to the per-stratum estimates provided in the output. Has no effect on the TDAS interval itself. |
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 rates in each group and of the requested contrast, with its confidence interval
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
a vector of values describing and testing heterogeneity
a string indicating the selected weighting method
a matrix containing stratum estimates and weights
details of the function call
Pete Laud, [email protected]
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.