Package 'genodds'

Title: Generalised Odds Ratios
Description: Calculates Agresti's generalized odds ratios. For a randomly selected pair of observations from two groups, calculates the odds that the second group will have a higher scoring outcome than that of the first group. Package provides hypothesis testing for if this odds ratio is significantly different to 1 (equal chance).
Authors: Hannah Johns [aut, cre]
Maintainer: Hannah Johns <[email protected]>
License: GPL (>=2.0)
Version: 1.1.2
Built: 2024-11-07 04:11:53 UTC
Source: https://github.com/hannahjohns/genodds

Help Index


Effect of time to treatment on efficacy of rt-PA in treating acute stroke

Description

A dataset reconstructing reported outcomes after stroke as reported in Lees et. al. (2010) which pooled the results of several studies.

Usage

alteplase

Format

A data frame with 3669 rows and 3 variables:

time

Time interval (minutes) between stroke onset and treatment

treat

Type of treatment received

mRS

Outcome at 3 months measured using the modified Rankin Scale

References

Lees, K. R., Bluhmki, E., Von Kummer, R., Brott, T. G., Toni, D., Grotta, J. C., Albers, G. W., Kaste, M., Marler, J. R., Hamilton, S. A., Tilley, B. C., Davis, S. M., Donnan, G. A., Hacke, W. (2010). Time to treatment with intravenous alteplase and outcome in stroke: an updated pooled analysis of ECASS, ATLANTIS, NINDS, and EPITHET trials. The Lancet, 375(9727), 1695-1703.


Generalized Odds Ratios

Description

Performs Agresti's Generalized Odds Ratios (GenOR) for two-group ordinal data.

Usage

genodds(response, group, strata=NULL,
        alpha=0.05,ties="split",
        nnt=FALSE,verbose=FALSE,upper=TRUE, suppress_interpretation=FALSE,
        assume_no_effect=FALSE,
        permutation_test=FALSE, nPermutations=5000)

Arguments

response

A (non-empty) vector. Gives the outcome measure. If a factor, level order is used to determine ranking of outcomes.

group

A factor vector of equal length to response. Gives the groups for the test. Must take on exactly 2 values.

strata

An optional factor vector of equal length to response. Gives treatment blocks to separate comparisons.

alpha

The acceptable type 1 error used in the test.

ties

A string specifying how ties should be treated. Should be equal to "split" 0.5 for WMW Odds, or "drop" for Agresti's GenOR.

nnt

A boolean. If TRUE, then print number needed to treat in addition to generalised odds ratios.

verbose

A boolean. If TRUE, then print both pooled odds and relative risk ratio matrices regardless of result of statistical test.

upper

A boolean specifying if the upper triangle of relative risk ratios should be printed. If FALSE, lower triangle is used instead.

suppress_interpretation

A boolean specifying if the interpretable summary statements of results should be suppressed.

assume_no_effect

A boolean indicating if p-values and confidence intervals should be calculated using pooled_SElnnull (if TRUE) or pooled_SElnodds (if FALSE).

permutation_test

A boolean specifying if a permutation test should be performed on the data

nPermutations

The number of permutations to use in the permutation test

Details

Agresti's generalized odds ratios (GenOR) calculates the odds that, if a pair of observations are randomly selected from two groups, the outcome in one group is higher than the other. This implementation determines the direction of this comparison using factor levels. Odds are given with reference to observations corresponding to the higher group level resulting in a higher value in response. The opposite direction can be calculated by either calculating 1/genodds, or by specifying response=1-response in function input.

If nnt=TRUE, the Number Needed to Treat (NNT) is printed. NNT is a health economics measure and is related to generalised odds ratios through the formula NNT=1+2/(GenOR-1). It measures the expected number of patients required for a treatment to have impacted a patient's outcome. In this implementation, a positive NNT occurs when GenOR>1 and corresponds to the number needed to treat in the higher group level to observe a higher response value, while a negative NNT occurs when GenOR<1 and corresponds to the number needed to treat in the higher group level to observe a lower response value. If the confidence interval for GenOR straddles 1, the confidence interval for NNT is given as the union of disjoint intervals.

ties changes how ties are treated. If "split" is provided, then ties are equally split between favouring both groups (following the approach set out by O'Brien et. al. (2006)). If "drop" is provided, then ties are ignored (following the approach set out by Agresti (1980)). By default, "split" is used.

If assume_no_effect==TRUE, use O'Brien's method for calculating standard error under null for the purposes of calculating p-values and confidence intervals. If assume_no_effect==FALSE (the default option), then p-values and confidence intervals will be calculated using standard error instead.

If strata is specified, generalized odds ratios are calculated separately for each individual strata. If in-stratum odds ratios are not significantly different from each other (with significance level alpha), these odds are pooled to obtain a global odds ratio which is adjusted for strata. If in-stratum odds ratios are significantly different, a matrix containing the relative risk ratios between stratum is printed, along with Z-scores corresponding to the significance of these differences. If verbose=TRUE is supplied, both pooled odds and relative risk ratios are printed regardless of if the between-stratum odds ratios are significantly different.

Permutation testing is performed following the approach suggested by Howard et al. (2012), where the probability of a random observation from one group achieving a higher score than a patient in another group is calculated (given there is a difference between the scores), and then the group labels are randomly shuffled to guarantee the null hypothesis of no difference between groups is true. The permutation test p-value is the proportion of such permutations which result in a test statistic more extreme than what was observed on the original data, forming a two-tail test. This procedure is equivalent to that provided by Agresti's generalised odds ratio, and is implemented here for both methods of handling ties.

By default, print.genodds() will report an interpretable summary of the test statistic following a loosely modified form of the statements suggested by Howard et al. (2012). This may be suppressed by specifying suppress_interpretation=TRUE.

Options verbose, nnt, upper, and suppress_interpretation may be re-specified when using print method.

Value

A list with class "Genodds" containing the following:

pooled_lnodds

The pooled log(odds).

pooled_lnconf.int

(1-alpha)% Confidence intervals for pooled log(odds).

pooled_SElnodds

Standard error of pooled log(odds).

pooled_SElnnull

Standard error of pooled log(odds) under the null hypothesis.

pooled_p

The p-value of the test of pooled log(odds) = 1.

pooled_rel_statistic

Statistic of test that strata odds are equal.

pooled_rel_p

p-value for test that strata odds are equal.

relative_lnodds

A matrix giving the log of the ratio of odds between strata (generalised relative risk ratio).

relative_selnodds

A matrix containing the standard error of the log(relative risk ratio).

results

A list containing a summary of each strata measure.

param.record

A list containing parameters used in the test.

References

Agresti, A. (1980). Generalized odds ratios for ordinal data. Biometrics, 59-67.

O'Brien, R. G., & Castelloe, J. (2006, March). Exploiting the link between the Wilcoxon-Mann-Whitney test and a simple odds statistic. In Thirty-first Annual SAS Users Group International Conference.

Churilov, L., Arnup, S., Johns, H., Leung, T., Roberts, S., Campbell, B. C., Davis, S. M. & Donnan, G. A. (2014). An improved method for simple, assumption-free ordinal analysis of the modified Rankin Scale using generalized odds ratios. International Journal of Stroke, 9(8), 999-1005.

Howard, G., Waller, J. L., Voeks, J. H., Howard, V. J., Jauch, E. C., Lees, K. R., ... & Hess, D. C. (2012). A simple, assumption-free, and clinically interpretable approach for analysis of modified Rankin outcomes. Stroke, 43(3), 664-669.

Examples

# Use the alteplase dataset provided by package and calculate genodds
df <- alteplase
x <- genodds(df$mRS,df$treat,df$time)
x
print(x,nnt=TRUE)

Power Calculations for Generalized Odds Ratios

Description

Provides power analysis for Agresti's Generalized Odds Ratios.

Usage

genodds.power(
  p0,
  p1,
  N = NULL,
  power = NULL,
  alpha = 0.05,
  ties = "split",
  w = c(0.5, 0.5),
  direction = "two.sided"
)

Arguments

p0

A numeric vector contianing the probabilities in control group.

p1

A numeric vector contianing the probabilities in treatment group.

N

A numeirc vector containing total sample sizes.

power

A numeric vector containing required total sample size.

alpha

Type 1 error.

ties

A string specifying how ties should be treated. Should be equal to "split" 0.5 for WMW Odds, or "drop" for Agresti's GenOR.

w

A numeric vector of length 2 specifying the relative weighting of sample size between treatment groups.

direction

Direction for hypothesis test. Must be one of "two.sided","upper.tail" or "lower.tail".

Details

See genodds for explanation of generalized odds ratios.

N provides the total sample size. Sample size per group can be calculated by N*w/sum(w).

When power is supplied, if no sufficient sample size is found then this function will return Inf.

Value

If power is supplied

A numeric vector containing required sample sizes to achieve specified powers.

If N is supplied

A numeric vector containing power at specified sample sizes.

References

O'Brien, R. G., & Castelloe, J. (2006, March). Exploiting the link between the Wilcoxon-Mann-Whitney test and a simple odds statistic. In Thirty-first Annual SAS Users Group International Conference.

Examples

# Provide theoretical distributions of outcomes for each group
# Distributions taken from Lees et. al. (2010). See ?alteplase for a citation.
p0 <- c(0.224,0.191,0.082,0.133,0.136,0.043,0.191)
p1 <- c(0.109,0.199,0.109,0.120,0.194,0.070,0.200)

# Calculate sample size required to achieve 80% and 90%
# power for these distributions
genodds.power(p0,p1,power=c(0.8,0.9))

# genodds.power suggests a total sample size of 619 for 80% power.
# Round up to 620 for even sample size per group

# Confirm these sample sizes lead to 80% and 90% power
genodds.power(p0,p1,N=c(620,830))