scoreci function - RDocumentation (2024)

Description

Score-based confidence intervals for the rate (or risk) difference ("RD") orratio ("RR") for independent binomial or Poisson rates, or for odds ratio("OR", binomial only). Including options for bias correction (from Miettinen& Nurminen), skewness correction ("GNbc" method from Laud & Dane, developedfrom Gart & Nam, and generalised as "SCAS" in Laud 2017) and continuitycorrection (for strictly conservative coverage).Also includes score intervals for a single binomial proportion or Poissonrate. Based on the Wilson score interval, when corrected for skewness,coverage is almost identical to the mid-p method, or Clopper-Pearsonwhen also continuity-corrected.Hypothesis tests for superiority or non-inferiority are provided using thesame score, to ensure consistency between test and CI.This function is vectorised in x1, x2, n1, and n2. Vector inputs may also becombined into a single stratified analysis (e.g. meta-analysis), either usingfixed effects, or the more general random effects "TDAS" method, whichincorporates stratum variability using a t-distribution score (inspired byHartung-Knapp-Sidik-Jonkman).For fixed-effects analysis of stratified datasets, with weighting = "MH" forRD or RR, or weighting = "IVS" for OR, omitting the skewness correctionproduces the CMH test, together with a coherent confidence interval for therequired contrast.

Usage

scoreci( x1, n1, x2 = NULL, n2 = NULL, distrib = "bin", contrast = "RD", level = 0.95, skew = TRUE, simpleskew = FALSE, ORbias = TRUE, RRtang = NULL, bcf = TRUE, cc = FALSE, theta0 = NULL, precis = 6, plot = FALSE, plotmax = 100, hetplot = FALSE, xlim = NULL, ylim = NULL, stratified = FALSE, weighting = NULL, MNtol = 1e-08, wt = NULL, sda = NULL, fda = NULL, dropzeros = FALSE, tdas = NULL, random = FALSE, prediction = FALSE, warn = TRUE, ...)

Arguments

x1, x2

Numeric vectors of numbers of events in group 1 & group 2respectively.

n1, n2

Numeric vectors of sample sizes (for binomial rates) or exposuretimes (for Poisson rates) in each group.

distrib

Character string indicating distribution assumed for the inputdata: "bin" = binomial (default), "poi" = Poisson.

contrast

Character string indicating the contrast of interest: "RD" =rate difference (default), "RR" = rate ratio, "OR" = odds ratio.contrast="p" gives an interval for the single proportion or rate x1/n1.

level

Number specifying confidence level (between 0 and 1, default0.95).

skew

Logical (default TRUE) indicating whether to apply skewnesscorrection (for the SCAS method recommended in Laud 2017) or not (forthe 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. NOTE: this version of the score is onlysuitable for obtaining confidence limits, not p-values.

ORbias

Logical (default is TRUE for contrast="OR", otherwiseNULL) indicating whether to apply additional bias correction for OR derivedfrom Gart 1985. (Corrigendum to Laud 2017, published May 2018).Only applies if contrast is "OR".

RRtang

Logical indicating whether to use Tang's score for RR:Stheta = (p1hat - p2hat * theta) / p2d (see Tang 2020).Default TRUE for stratified = TRUE, with weighting = "IVS" or "INV".Forced to FALSE for stratified = TRUE, with fixed weighting.Experimental for distrib = "poi".

bcf

Logical (default TRUE) indicating whether to apply bias correctionin the score denominator. Applicable to distrib = "bin" only. (NB: bcf =FALSE option is really only included for legacy validation against previouspublished methods (i.e. Gart & Nam, Mee, or standard Chi-squared test).Ignored for contrast = "p".

cc

Number or logical (default FALSE) specifying (amount of) continuitycorrection. Numeric value is taken as the gamma parameter in Laud 2017,Appendix S2 (default 0.5 if cc = TRUE).IMPORTANT NOTES:1) This is a 'continuity correction' aimed at approximating strictlyconservative coverage, NOT for dealing with zero cell counts. Such'sparse data adjustments' are not needed in the score method,except to deal with double-zero cells for RD (& double-100binomial RD & RR) with IVS/INV weights.2) The continuity corrections provided here have not been fully tested forstratified methods.

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% CIexcludes theta0. If bcf = FALSE and skew = FALSE this gives aFarrington-Manning test.By default, a two-sided test against theta0 = 0 (for RD) or 1 (for RR/OR)is also output: if bcf = FALSE and skew = FALSE this is the same asPearson's Chi-squared test.

precis

Number (default 6) specifying precision (i.e. number of decimalplaces) to be used in optimisation subroutine for the confidence interval.

plot

Logical (default FALSE) indicating whether to output plot of thescore function

plotmax

Numeric value indicating maximum value to be displayed onx-axis of plots (useful for ratio contrasts which can be infinite).

hetplot

Logical (default FALSE) indicating whether to output plots forevaluating 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 combinevector inputs into a single stratified analysis.IMPORTANT NOTE: The mechanism for stratified calculations is enabled forcontrast = "p", but the performance of the resulting intervals has notbeen fully evaluated.

weighting

String indicating which weighting method to use ifstratified = "TRUE":"IVS" = Inverse Variance of Score (see Laud 2017 for details),"INV" = Inverse Variance (bcf omitted, default for contrast = "OR"),"MH" = Mantel-Haenszel (default for contrast = "RD" or "RR"),"MN" = Miettinen-Nurminen iterative weights.For CI consistent with a CMH test, select skew = FALSE and useMH weighting for RD/RR and IVS for OR.

MNtol

Numeric value indicating convergence tolerance to be used initeration with weighting = "MN".

wt

Numeric vector containing (optional) user-specified weights.

sda

Sparse data adjustment to avoid zero variance when x1 + x2 = 0:Only applied when stratified = TRUE.Default 0.5 for RD with IVS/INV weights.Not required for RR/OR, default is to remove double-zero stratainstead.

fda

Full data adjustment to avoid zero variance when x1 + x2 = n1 + n2:Only applied when stratified = TRUE.Default 0.5 for RD & RR with IVS/INV weights.Not required for OR, default is to remove affected strata.

dropzeros

Logical (default FALSE) indicating whether to dropuninformative strata for RR/OR, even when the choice of weights would allowthem to be retained for a fixed effects analysis.Has no effect on estimates, just the heterogeneity test.

tdas

(deprecated: parameter renamed to random)

random

Logical (default FALSE) indicating whether to perform randomeffects meta-analysis for stratified data, using the t-distribution (TDAS)method for stratified data (defined in Laud 2017).NOTE: If random = TRUE, then skew = TRUE only affects the per-stratumestimates.

prediction

Logical (default FALSE) indicating whether to producea prediction interval (work in progress).

warn

Logical (default TRUE) giving the option to suppress warnings.

...

Other arguments.

Value

A list containing the following components:

estimates

a matrix containing estimates of the rates in each group and of the requested contrast, with its confidence interval

pval

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

call

details of the function call

If stratified = TRUE, the following outputs are added:

Qtest

a vector of values describing and testing heterogeneity

weighting

a string indicating the selected weighting method

stratdata

a matrix containing stratum estimates and weights

References

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<U+2013>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<U+2013>3457.

Examples

Run this code

# NOT RUN {# 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)# 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")# }

Run the code above in your browser using DataLab

scoreci function - RDocumentation (2024)

References

Top Articles
Latest Posts
Article information

Author: Zonia Mosciski DO

Last Updated:

Views: 6317

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Zonia Mosciski DO

Birthday: 1996-05-16

Address: Suite 228 919 Deana Ford, Lake Meridithberg, NE 60017-4257

Phone: +2613987384138

Job: Chief Retail Officer

Hobby: Tai chi, Dowsing, Poi, Letterboxing, Watching movies, Video gaming, Singing

Introduction: My name is Zonia Mosciski DO, I am a enchanting, joyous, lovely, successful, hilarious, tender, outstanding person who loves writing and wants to share my knowledge and understanding with you.