PeteLaud / ratesci

Confidence intervals and tests for comparison of rates
1 stars 0 forks source link

ratesci

R-CMD-check License: GPL v3 CRAN_Status_Badge Total Downloads

ratesci is an R package to compute confidence intervals for rate (or risk) difference ('RD'), rate ratio ('RR', also known as relative risk), or odds ratio ('OR'). All three contrasts apply for binomial proportions, and the first two may also be used for the comparison of Poisson 'exposure-adjusted' incidence rates. The scoreci function incorporates 'skewness-corrected' asymptotic score ('SCAS') methods, which ensure equal-tailed coverage (or central location), in other words for a nominal 95% confidence interval, the one-sided non-coverage probability is (on average) close to 2.5% on each side. Stratified calculations are also catered for (e.g. meta-analysis, including random effects), as well as confidence intervals for the single binomial or Poisson rate, and for matched pairs (with the pairbinci function). Corresponding hypothesis tests against any specified null parameter value are provided in each case. Omission of the skewness correction is also allowed, resulting in the often-recommended 'Miettinen-Nurminen' asymptotic score methods, which can have inferior one-sided coverage, especially for RR. The hypothesis test for binomial RD or RR when the skewness correction is omitted corresponds to the Farrington-Manning test.

The stratified (fixed effects) version without skewness correction produces a hypothesis test which is equivalent to the Cochran-Mantel-Haenszel (CMH) test, when MH weighting is used for RD or RR, or IVS weighting for OR, and the corresponding confidence intervals are guaranteed to be coherent with the test.

For large (single-stratum) sample sizes, the 'MOVER-B' methods (moverci function) improve on traditional approximate methods with respect to one-sided and two-sided coverage, particularly in the case of RR. Being based on Bayesian methods, these also allow the option to incorporate prior beliefs about the rates in each group - by default, the 'non-informative' Jeffreys priors are used. These methods are adapted from the Newcombe 'square-and-add' method, which is also included for reference.

For those wishing to achieve strictly conservative coverage, so-called 'continuity corrections' are provided as approximations to 'exact' methods. The performance of these adjustments has not been extensively evaluated, but they appear to be more successful for SCAS than for MOVER, in terms of achieving conservative coverage.

An online calculator based on this package is available here

Installation

You can install:

Example use

library(ratesci)
scoreci(x1 = 5, n1 = 56, x2 = 0, n2 = 29)

Overview

ratesci contains the following functions:

For comparisons of rates (contrasts RD, RR and OR):

For single binomial or Poisson rates: