Package 'hce'

Title: Design and Analysis of Hierarchical Composite Endpoints
Description: Simulate and analyze hierarchical composite endpoints. Win odds is the main analysis method, but other win statistics (win ratio, net benefit) are also implemented, provided there is no censoring. See Gasparyan SB et al (2023) "Hierarchical Composite Endpoints in COVID-19: The DARE-19 Trial." Case Studies in Innovative Clinical Trials, 95-148. Chapman; Hall/CRC. <doi:10.1201/9781003288640-7>.
Authors: Samvel B. Gasparyan [aut, cre]
Maintainer: Samvel B. Gasparyan <[email protected]>
License: MIT + file LICENSE
Version: 0.6.5
Built: 2024-12-16 06:32:22 UTC
Source: CRAN

Help Index


Event-Time dataset for kidney outcomes.

Description

A dataset with multiple kidney outcomes over time scale outcomes of 1500 patients in the ADSL dataset.

Usage

ADET

Format

a data frame with 604 rows (events) and 6 variables:

ID

patient identifiers, numeric

AVAL

occurence time of the event, numeric

PARAM

name of the event, character

PARAMCD

coded name of the event, character

PARAMN

type of the event, outcomes 1-7, where a higher value means a better outcome, numeric

TRTPN

treatment values, 1 Active or 2 Placebo, numeric

Source

Heerspink HL et al "Development and validation of a new hierarchical composite endpoint for clinical trials of kidney disease progression." Journal of the American Society of Nephrology (2023): doi:10.1681/ASN.0000000000000243.

Examples

head(ADET)
# Number of unique patients
length(unique(ADET$ID)) 
# Number of events per event type
barplot(table(ADET$PARAM))

Laboratory dataset for Glomerular Filtration Rate (GFR) measurements.

Description

A dataset of laboratory measurements of kidney function over time for the 1500 patients in the ADSL dataset.

Usage

ADLB

Format

a data frame with 13980 rows and 8 variables:

ID

patient identifiers, numeric

TRTPN

treatment values, 1 Active or 2 Placebo, numeric

AVAL

measurement value, numeric

ADAY

measurement day in the study, numeric

AVISITN

hospital visit number, numeric

PARAM

name of the event, GFR measurments, character

PARAMCD

coded name of the event, GFR, character

PARAMN

type of the event is set to 7 for all measurements, numeric

Source

Heerspink HL et al "Development and validation of a new hierarchical composite endpoint for clinical trials of kidney disease progression." Journal of the American Society of Nephrology (2023): doi:10.1681/ASN.0000000000000243.

Examples

head(ADLB)

Baseline characteristics dataset of patients with kidney function assessments.

Description

A data frame with baseline characteristics for 1500 patients used to derive KHCE dataset.

Usage

ADSL

Format

a data frame with 1500 rows and 4 variables:

ID

patient identifiers, numeric

TRTPN

treatment values, 1 Active or 2 Placebo, numeric

EGFRBL

Baseline GFR values of patients, numeric

STRATAN

strata 1-4, higher value means a higher risk for kidney disease progression, numeric

Source

Heerspink HL et al "Development and validation of a new hierarchical composite endpoint for clinical trials of kidney disease progression." Journal of the American Society of Nephrology (2023): doi:10.1681/ASN.0000000000000243.

Examples

head(ADSL)

A generic function for coercing data structures to hce objects

Description

A generic function for coercing data structures to hce objects

Usage

as_hce(x, ...)

Arguments

x

an object used to select a method.

...

additional parameters.

Value

an hce object.

See Also

as_hce.data.frame().

Examples

### data frames 
data(HCE1)
HCE <- as_hce(HCE1)
calcWINS(HCE)

Coerce a data frame to an hce object

Description

Coerce a data frame to an hce object

Usage

## S3 method for class 'data.frame'
as_hce(x, ...)

Arguments

x

a data frame.

...

additional parameters.

Value

an hce object.

Examples

KHCE <- as_hce(KHCE)
calcWO(KHCE)

A generic function for calculating win statistics

Description

A generic function for calculating win statistics

Usage

calcWINS(x, ...)

Arguments

x

an object used to select a method.

...

further arguments passed to or from other methods.

Value

a data frame containing calculated values.

See Also

calcWINS.hce(), calcWINS.formula(), calcWINS.data.frame() methods.


Win statistics calculation using a data frame

Description

Win statistics calculation using a data frame

Usage

## S3 method for class 'data.frame'
calcWINS(x, AVAL, TRTP, ref, alpha = 0.05, WOnull = 1, ...)

Arguments

x

a data frame containing subject-level data.

AVAL

variable in the data with ordinal analysis values.

TRTP

the treatment variable in the data.

ref

the reference treatment group.

alpha

2-sided significance level. The default is 0.05.

WOnull

the null hypothesis. The default is 1.

...

additional parameters.

Value

a list containing win statistics and their confidence intervals. It contains the following named data frames:

  • summary a data frame containing number of wins, losses, and ties of the active treatment group and the overall number of comparisons.

  • WP a data frame containing the win probability and its confidence interval.

  • NetBenefit a data frame containing the net benefit and its confidence interval. This is just a ⁠2x-1⁠ transformation of WP and its CI.

  • WO a data frame containing the win odds and its confidence interval.

  • WR1 a data frame containing the win ratio and its confidence interval, using the transformed standard error of the gamma statistic.

  • WR2 a data frame containing the win ratio and its confidence interval, using the standard error calculated using Pties.

  • gamma a data frame containing Goodman Kruskal's gamma and its confidence interval.

  • SE a data frame containing standard errors used to calculated the Confidence intervals for win statistics.

References

The theory of win statistics is covered in the following papers.

  • For the win proportion CI calculation see

    Gasparyan SB et al. (2021) "Adjusted win ratio with stratification: calculation methods and interpretation." Statistical Methods in Medical Research 30.2: 580-611. doi:10.1177/0962280220942558.

  • The win odds CI is calculated using the formula in

    Gasparyan SB et al. (2021) "Power and sample size calculation for the win odds test: application to an ordinal endpoint in COVID-19 trials." Journal of Biopharmaceutical Statistics 31.6: 765-787. doi:10.1080/10543406.2021.1968893.

  • The win ratio the first CI uses the standard error derived from the standard error of the gamma statistic presented in

    Gasparyan SB, Kowalewski EK, Buenconsejo J, Koch GG. (2023) “Hierarchical Composite Endpoints in COVID-19: The DARE-19 Trial.” In Case Studies in Innovative Clinical Trials, Chapter 7, 95–148. Chapman; Hall/CRC. doi:10.1201/9781003288640-7.

  • The win ratio the second CI uses the standard error presented in

    Yu RX, Ganju J. (2022) "Sample size formula for a win ratio endpoint." Statistics in Medicine 41.6: 950-63. doi:10.1002/sim.9297.

  • The Goodman Kruskal's gamma and its CI match those in DescTools::GoodmanKruskalGamma() and are based on

    Agresti A. (2002) Categorical Data Analysis. John Wiley & Sons, pp. 57-59. doi:10.1002/0471249688.

    Brown MB, Benedetti JK. (1977) "Sampling Behavior of Tests for Correlation in Two-Way Contingency Tables." Journal of the American Statistical Association 72, 309-315. doi:10.1080/01621459.1977.10480995.

    Goodman LA, Kruskal WH. (1954) "Measures of association for cross classifications." Journal of the American Statistical Association 49, 732-764. doi:10.1080/01621459.1954.10501231.

    Goodman LA, Kruskal WH. (1963) "Measures of association for cross classifications III: Approximate sampling theory." Journal of the American Statistical Association 58, 310-364. doi:10.1080/01621459.1963.10500850.

See Also

calcWINS(), calcWINS.hce(), calcWINS.formula().

Examples

calcWINS(x = COVID19b, AVAL = "GROUP", TRTP = "TRTP", ref = "Placebo")

Win statistics calculation using formula syntax

Description

Win statistics calculation using formula syntax

Usage

## S3 method for class 'formula'
calcWINS(x, data, ...)

Arguments

x

an object of class formula.

data

a data frame.

...

additional parameters.

Value

a list containing win statistics and their confidence intervals. It contains the following named data frames:

  • summary a data frame containing number of wins, losses, and ties of the active treatment group and the overall number of comparisons.

  • WP a data frame containing the win probability and its confidence interval.

  • NetBenefit a data frame containing the net benefit and its confidence interval. This is just a ⁠2x-1⁠ transformation of WP and its CI.

  • WO a data frame containing the win odds and its confidence interval.

  • WR1 a data frame containing the win ratio and its confidence interval, using the transformed standard error of the gamma statistic.

  • WR2 a data frame containing the win ratio and its confidence interval, using the standard error calculated using Pties.

  • gamma a data frame containing Goodman Kruskal's gamma and its confidence interval.

  • SE a data frame containing standard errors used to calculated the Confidence intervals for win statistics.

References

The theory of win statistics is covered in the following papers.

  • For the win proportion CI calculation see

    Gasparyan SB et al. (2021) "Adjusted win ratio with stratification: calculation methods and interpretation." Statistical Methods in Medical Research 30.2: 580-611. doi:10.1177/0962280220942558.

  • The win odds CI is calculated using the formula in

    Gasparyan SB et al. (2021) "Power and sample size calculation for the win odds test: application to an ordinal endpoint in COVID-19 trials." Journal of Biopharmaceutical Statistics 31.6: 765-787. doi:10.1080/10543406.2021.1968893.

  • The win ratio the first CI uses the standard error derived from the standard error of the gamma statistic presented in

    Gasparyan SB, Kowalewski EK, Buenconsejo J, Koch GG. (2023) “Hierarchical Composite Endpoints in COVID-19: The DARE-19 Trial.” In Case Studies in Innovative Clinical Trials, Chapter 7, 95–148. Chapman; Hall/CRC. doi:10.1201/9781003288640-7.

  • The win ratio the second CI uses the standard error presented in

    Yu RX, Ganju J. (2022) "Sample size formula for a win ratio endpoint." Statistics in Medicine 41.6: 950-63. doi:10.1002/sim.9297.

  • The Goodman Kruskal's gamma and its CI match those in DescTools::GoodmanKruskalGamma() and are based on

    Agresti A. (2002) Categorical Data Analysis. John Wiley & Sons, pp. 57-59. doi:10.1002/0471249688.

    Brown MB, Benedetti JK. (1977) "Sampling Behavior of Tests for Correlation in Two-Way Contingency Tables." Journal of the American Statistical Association 72, 309-315. doi:10.1080/01621459.1977.10480995.

    Goodman LA, Kruskal WH. (1954) "Measures of association for cross classifications." Journal of the American Statistical Association 49, 732-764. doi:10.1080/01621459.1954.10501231.

    Goodman LA, Kruskal WH. (1963) "Measures of association for cross classifications III: Approximate sampling theory." Journal of the American Statistical Association 58, 310-364. doi:10.1080/01621459.1963.10500850.

See Also

calcWINS(), calcWINS.hce(), calcWINS.data.frame().

Examples

# Example 1
calcWINS(x = GROUP ~ TRTP, data = COVID19b)
# Example 2
calcWINS(x = GROUP ~ TRTP, data = COVID19, ref = "Placebo", alpha = 0.01, WOnull = 1.2)

Win statistics calculation for hce objects

Description

Win statistics calculation for hce objects

Usage

## S3 method for class 'hce'
calcWINS(x, ...)

Arguments

x

an hce object.

...

additional parameters.

Value

a list containing win statistics and their confidence intervals. It contains the following named data frames:

  • summary a data frame containing number of wins, losses, and ties of the active treatment group and the overall number of comparisons.

  • WP a data frame containing the win probability and its confidence interval.

  • NetBenefit a data frame containing the net benefit and its confidence interval. This is just a ⁠2x-1⁠ transformation of WP and its CI.

  • WO a data frame containing the win odds and its confidence interval.

  • WR1 a data frame containing the win ratio and its confidence interval, using the transformed standard error of the gamma statistic.

  • WR2 a data frame containing the win ratio and its confidence interval, using the standard error calculated using Pties.

  • gamma a data frame containing Goodman Kruskal's gamma and its confidence interval.

  • SE a data frame containing standard errors used to calculated the Confidence intervals for win statistics.

References

The theory of win statistics is covered in the following papers.

  • For the win proportion CI calculation see

    Gasparyan SB et al. (2021) "Adjusted win ratio with stratification: calculation methods and interpretation." Statistical Methods in Medical Research 30.2: 580-611. doi:10.1177/0962280220942558.

  • The win odds CI is calculated using the formula in

    Gasparyan SB et al. (2021) "Power and sample size calculation for the win odds test: application to an ordinal endpoint in COVID-19 trials." Journal of Biopharmaceutical Statistics 31.6: 765-787. doi:10.1080/10543406.2021.1968893.

  • The win ratio the first CI uses the standard error derived from the standard error of the gamma statistic presented in

    Gasparyan SB, Kowalewski EK, Buenconsejo J, Koch GG. (2023) “Hierarchical Composite Endpoints in COVID-19: The DARE-19 Trial.” In Case Studies in Innovative Clinical Trials, Chapter 7, 95–148. Chapman; Hall/CRC. doi:10.1201/9781003288640-7.

  • The win ratio the second CI uses the standard error presented in

    Yu RX, Ganju J. (2022) "Sample size formula for a win ratio endpoint." Statistics in Medicine 41.6: 950-63. doi:10.1002/sim.9297.

  • The Goodman Kruskal's gamma and its CI match those in DescTools::GoodmanKruskalGamma() and are based on

    Agresti A. (2002) Categorical Data Analysis. John Wiley & Sons, pp. 57-59. doi:10.1002/0471249688.

    Brown MB, Benedetti JK. (1977) "Sampling Behavior of Tests for Correlation in Two-Way Contingency Tables." Journal of the American Statistical Association 72, 309-315. doi:10.1080/01621459.1977.10480995.

    Goodman LA, Kruskal WH. (1954) "Measures of association for cross classifications." Journal of the American Statistical Association 49, 732-764. doi:10.1080/01621459.1954.10501231.

    Goodman LA, Kruskal WH. (1963) "Measures of association for cross classifications III: Approximate sampling theory." Journal of the American Statistical Association 58, 310-364. doi:10.1080/01621459.1963.10500850.

See Also

calcWINS(), calcWINS.formula(), calcWINS.data.frame().

Examples

# Example 1
COVID19HCE <- hce(GROUP = COVID19$GROUP, TRTP = COVID19$TRTP)
calcWINS(COVID19HCE)
# Example 2
COVID19bHCE <- hce(GROUP = COVID19b$GROUP, TRTP = COVID19b$TRTP)
calcWINS(COVID19bHCE, ref = "Placebo", WOnull = 1.1, alpha = 0.01)

A generic function for calculating win odds

Description

A generic function for calculating win odds

Usage

calcWO(x, ...)

Arguments

x

an object used to select a method.

...

further arguments passed to or from other methods.

Value

a data frame containing calculated values.

See Also

calcWO.hce(), calcWO.formula(), calcWO.data.frame() methods.


Win odds calculation using a data frame

Description

Win odds calculation using a data frame

Usage

## S3 method for class 'data.frame'
calcWO(x, AVAL, TRTP, ref, alpha = 0.05, WOnull = 1, ...)

Arguments

x

a data frame containing subject-level data.

AVAL

variable in the data with ordinal analysis values.

TRTP

the treatment variable in the data.

ref

the reference treatment group.

alpha

significance level. The default is 0.05.

WOnull

the null hypothesis. The default is 1.

...

additional parameters.

Value

a data frame containing the win odds and its confidence interval. It contains the following columns:

  • WO calculated win odds.

  • LCL lower confidence limit.

  • UCL upper confidence limit.

  • SE standard error of the win odds.

  • WOnull win odds of the null hypothesis (specified in the WOnull argument).

  • alpha two-sided significance level for calculating the confidence interval (specified in the alpha argument).

  • Pvalue p-value associated with testing the null hypothesis.

  • WP calculated win probability.

  • WP_SE standard error of the win probability.

  • WP_SD standard deviation of the win probability, calculated as WP_SE multiplied by sqrt(N).

  • N total number of patients in the analysis.

References

Gasparyan SB et al. "Adjusted win ratio with stratification: calculation methods and interpretation." Statistical Methods in Medical Research 30.2 (2021): 580-611. doi:10.1177/0962280220942558

See Also

calcWO(), calcWO.hce(), calcWO.formula().

Examples

data(HCE4)
calcWO(x = HCE4, AVAL = "AVAL", TRTP = "TRTP", ref = "P")

Win odds calculation using formula syntax

Description

Win odds calculation using formula syntax

Usage

## S3 method for class 'formula'
calcWO(x, data, ...)

Arguments

x

an object of class formula.

data

a data frame.

...

additional parameters.

Value

a data frame containing the win odds and its confidence interval. It contains the following columns:

  • WO calculated win odds.

  • LCL lower confidence limit.

  • UCL upper confidence limit.

  • SE standard error of the win odds.

  • WOnull win odds of the null hypothesis (specified in the WOnull argument).

  • alpha two-sided significance level for calculating the confidence interval (specified in the alpha argument).

  • Pvalue p-value associated with testing the null hypothesis.

  • WP calculated win probability.

  • WP_SE standard error of the win probability.

  • WP_SD standard deviation of the win probability, calculated as WP_SE multiplied by sqrt(N).

  • N total number of patients in the analysis.

  • formula returning the specified formula in the x argument.

  • ref showing how the reference group was selected. Can be modifying by specifying the ref argument.

References

Gasparyan SB et al. "Adjusted win ratio with stratification: calculation methods and interpretation." Statistical Methods in Medical Research 30.2 (2021): 580-611. doi:10.1177/0962280220942558

See Also

calcWO(), calcWO.hce(), calcWO.data.frame().

Examples

#Example 1
data(HCE1)
calcWO(AVAL ~ TRTP, data = HCE1)

#Example 2
calcWO(data = COVID19, GROUP ~ TRTP, ref = "Placebo")

Win odds calculation for hce objects

Description

Win odds calculation for hce objects

Usage

## S3 method for class 'hce'
calcWO(x, ...)

Arguments

x

an hce object.

...

additional parameters.

Value

a data frame containing the win odds and its confidence interval. It contains the following columns:

  • WO calculated win odds.

  • LCL lower confidence limit.

  • UCL upper confidence limit.

  • SE standard error of the win odds.

  • WOnull win odds of the null hypothesis (specified in the WOnull argument).

  • alpha two-sided significance level for calculating the confidence interval (specified in the alpha argument).

  • Pvalue p-value associated with testing the null hypothesis.

  • WP calculated win probability.

  • WP_SE standard error of the win probability.

  • WP_SD standard deviation of the win probability, calculated as WP_SE multiplied by sqrt(N).

  • N total number of patients in the analysis.

References

Gasparyan SB et al. "Adjusted win ratio with stratification: calculation methods and interpretation." Statistical Methods in Medical Research 30.2 (2021): 580-611. doi:10.1177/0962280220942558

See Also

calcWO(), calcWO.formula(), calcWO.data.frame().

Examples

Rates_A <- c(1, 1.5) 
Rates_P <- c(2, 2) 
dat <- simHCE(n = 500, TTE_A = Rates_A, TTE_P = Rates_P, CM_A = 1.25, CM_P = 1)
calcWO(dat)
calcWO(dat, ref = "A", WOnull = 1, alpha = 0.01)

COVID-19 ordinal scale dataset (full report).

Description

A dataset with COVID-19 ordinal scale outcomes for 1062 patients.

Usage

COVID19

Format

a data frame with 1062 rows and 2 variables:

GROUP

type of the event, ordinal outcomes 1-8, where a higher value means a better outcome

TRTP

treatment values, A Active or P Placebo, character

Source

Beigel JH et al. "Remdesivir for the treatment of Covid-19-final report." New England Journal of Medicine 383.19 (2020): 1813-1836. doi:10.1056/NEJMoa2007764.

Examples

#Frequencies
table(COVID19)
mosaicplot(table(COVID19), col = c(1, 8, 6, 2, 4, 5, 3, 7), 
xlab = "Treatment", ylab = "Ordinal Scale", main = "COVID-19 ordinal scale")
# Convert to an hce object
COVID19HCE <- hce(GROUP = COVID19$GROUP, TRTP = COVID19$TRTP)
# Summary wins, losses, and ties with win odds
summaryWO(COVID19HCE, ref = "Placebo")

COVID-19 ordinal scale dataset (preliminary report).

Description

A dataset with COVID-19 ordinal scale outcomes for 844 patients.

Usage

COVID19b

Format

a data frame with 844 rows and 2 variables:

GROUP

type of the event, ordinal outcomes 1-8, where a higher value means a better outcome

TRTP

treatment values, Active or Placebo, character

Source

Beigel JH et al. "Remdesivir for the treatment of Covid-19-final report." New England Journal of Medicine 383.19 (2020): 1813-1836. doi:10.1056/NEJMoa2007764.

Examples

#Frequencies
table(COVID19b)
mosaicplot(table(COVID19b), col = c(1, 8, 6, 2, 4, 5, 3, 7), 
xlab = "Treatment", ylab = "Ordinal Scale", main = "COVID-19 ordinal scale")
# Calculate win statistics
calcWINS(x = COVID19b, AVAL = "GROUP", TRTP = "TRTP", ref = "Placebo")

COVID-19 ordinal scale dataset for a combination therapy.

Description

A dataset with COVID-19 ordinal scale outcomes for 1033 patients.

Usage

COVID19plus

Format

a data frame with 1033 rows and 4 variables:

ID

patient identifiers, numeric

TRTP

treatment values, A Active or P Placebo, character

GROUP

type of the event, ordinal outcomes 1-8, where a higher value means a better outcome

BASE

baseline ordinal values

Source

Kalil AC et al. "Baricitinib plus Remdesivir for Hospitalized Adults with Covid-19." New England Journal of Medicine 384.9 (2021): 795-807. doi:10.1056/NEJMoa2031994.

Examples

COVID19HCE <- hce(GROUP = COVID19plus$GROUP, TRTP = COVID19plus$TRTP)
# Summary wins, losses, and ties with win odds
summaryWO(COVID19HCE, ref = "P")

Helper function for hce objects

Description

Helper function for hce objects

Usage

hce(
  GROUP = character(),
  TRTP = character(),
  AVAL0 = 0,
  ORD = sort(unique(GROUP))
)

Arguments

GROUP

a character vector of the same length as AVAL containing events.

TRTP

a character vector of the same length as AVAL containing assigned treatment groups.

AVAL0

a numeric vector of analysis values within each category. The default is 0.

ORD

a character vector containing ordered unique values of the GROUP variable for determining the hierarchy of events.

Value

an object of class hce. Its is a subject-level data frame (each row corresponds to one subject), containing the following columns:

  • SUBJID subject ID.

  • GROUP a character vector specifying the type of the outcome the patient experienced - either a TTE (time-to-event) or C (continuous).

  • GROUPN a numeric vector version of the GROUP column.

  • AVAL0 original analysis values - time of the time-to-event outcomes or the continuous outcome.

  • AVAL derived analysis value AVAL = AVAL0 + GROUPN.

  • TRTP assigned treatment groups.

See Also

as_hce() for coercing to hce objects.

Examples

# Example 1
set.seed(2022)
d <- hce(GROUP = sample(x = c("A", "B", "C"), size = 10, replace = TRUE), 
TRTP = rep(c("Active", "Control"), each = 5), 
AVAL0 = c(rnorm(5, mean = 1), rnorm(5)), ORD = c("A", "B", "C"))
calcWO(d, ref = "Control")

HCE1, HCE2, HCE3, HCE4 datasets for 1000 patients with different treatment effects.

Description

A simulated dataset containing the ordinal values and other attributes for 1000 patients. HCE1

Usage

HCE1

Format

a data frame with 1000 rows and 6 variables:

ID

subject ID, numbers from 1 to 1000

TRTP

treatment values, A Active or P Placebo, character

GROUP

type of the event, either Time-To-Event (TTE) or Continuous (C), character

GROUPN

type of the event, for the ordering of outcomes in the GROUP variable, numeric

AVALT

the timing of the time-to-event outcomes, numeric

AVAL0

original values for each type of the event, time for TTE outcomes, numeric values for Continuous outcomes, numeric

AVAL

AVAL = AVAL0 + GROUPN, ordinal analysis values for the HCE analysis. For the continuous outcome the values of AVAL0 are shifted to start always from 0. Numeric, but caution NOT to apply numeric operations; will give meaningless results

PADY

primary analysis day, the length of fixed follow-up in days, numeric


HCE1, HCE2, HCE3, HCE4 datasets for 1000 patients with different treatment effects.

Description

A simulated dataset containing the ordinal values and other attributes for 1000 patients. HCE2

Usage

HCE2

Format

a data frame with 1000 rows and 6 variables:

ID

subject ID, numbers from 1 to 1000

TRTP

treatment values, A Active or P Placebo, character

GROUP

type of the event, either Time-To-Event (TTE) or Continuous (C), character

GROUPN

type of the event, for the ordering of outcomes in the GROUP variable, numeric

AVALT

the timing of the time-to-event outcomes, numeric

AVAL0

original values for each type of the event, time for TTE outcomes, numeric values for Continuous outcomes, numeric

AVAL

AVAL = AVAL0 + GROUPN, ordinal analysis values for the HCE analysis. For the continuous outcome the values of AVAL0 are shifted to start always from 0. Numeric, but caution NOT to apply numeric operations; will give meaningless results

PADY

primary analysis day, the length of fixed follow-up in days, numeric


HCE1, HCE2, HCE3, HCE4 datasets for 1000 patients with different treatment effects.

Description

A simulated dataset containing the ordinal values and other attributes for 1000 patients. HCE3

Usage

HCE3

Format

a data frame with 1000 rows and 6 variables:

ID

subject ID, numbers from 1 to 1000

TRTP

treatment values, A Active or P Placebo, character

GROUP

type of the event, either Time-To-Event (TTE) or Continuous (C), character

GROUPN

type of the event, for the ordering of outcomes in the GROUP variable, numeric

AVALT

the timing of the time-to-event outcomes, numeric

AVAL0

original values for each type of the event, time for TTE outcomes, numeric values for Continuous outcomes, numeric

AVAL

AVAL = AVAL0 + GROUPN, ordinal analysis values for the HCE analysis. For the continuous outcome the values of AVAL0 are shifted to start always from 0. Numeric, but caution NOT to apply numeric operations; will give meaningless results

PADY

primary analysis day, the length of fixed follow-up in days, numeric


HCE1, HCE2, HCE3, HCE4 datasets for 1000 patients with different treatment effects.

Description

A simulated dataset containing the ordinal values and other attributes for 1000 patients. HCE4

Usage

HCE4

Format

a data frame with 1000 rows and 6 variables:

ID

subject ID, numbers from 1 to 1000

TRTP

treatment values, A Active or P Placebo, character

GROUP

type of the event, either Time-To-Event (TTE) or Continuous (C), character

GROUPN

type of the event, for the ordering of outcomes in the GROUP variable, numeric

AVALT

the timing of the time-to-event outcomes, numeric

AVAL0

original values for each type of the event, time for TTE outcomes, numeric values for Continuous outcomes, numeric

AVAL

AVAL = AVAL0 + GROUPN, ordinal analysis values for the HCE analysis. For the continuous outcome the values of AVAL0 are shifted to start always from 0. Numeric, but caution NOT to apply numeric operations; will give meaningless results

PADY

primary analysis day, the length of fixed follow-up in days, numeric


Kidney Hierarchical Composite Endpoint dataset.

Description

A dataset with kidney ordinal scale outcomes of 1500 patients in the ADSL dataset.

Usage

KHCE

Format

a data frame with 1500 rows and 11 variables:

ID

patient identifiers, numeric

TRTPN

treatment values, 1 Active or 2 Placebo, numeric

AVAL0

original values for each type of the event, time for TTE outcomes 1-6, numeric values for Continuous outcome 7, numeric

AVAL

AVAL = AVAL0 + GROUPN, ordinal analysis values for the HCE analysis, numeric, but caution NOT to apply numeric operations; will give meaningless results

GROUP

name of the event, character

GROUPN

ordinal outcomes corresponding to PARAMN values, numeric

PARAMCD

coded name of the event, character

PARAMN

severity of the event, outcomes 1-7, where a higher value means a better outcome, character

STRATAN

strata 1-4, higher value means more severe kidney disease, numeric

EGFRBL

Baseline GFR values of patients, numeric

TRTP

treatment values, A Active or P Placebo, character

PADY

primary analysis day (in years), length of the fixed follow-up, numeric

Source

Heerspink HL et al "Development and validation of a new hierarchical composite endpoint for clinical trials of kidney disease progression." Journal of the American Society of Nephrology (2023): doi:10.1681/ASN.0000000000000243.

Examples

# Adjusted win odds
res <- regWO(x = KHCE, AVAL = "AVAL", TRTP = "TRTP", COVAR = "STRATAN", ref = "P")
res

Minimum detectable or WO for alternative hypothesis for given power (no ties)

Description

Minimum detectable or WO for alternative hypothesis for given power (no ties)

Usage

minWO(N, power = 0.5, SD = NULL, k = 0.5, alpha = 0.05, WOnull = 1, digits = 2)

Arguments

N

a numeric vector of sample size values (two arms combined).

power

the given power. The default is 0.5 corresponding to the minimum detectable win odds. A numeric vector of length 1.

SD

assumed standard deviation of the win proportion. By default uses the conservative SD. A numeric vector of length 1.

k

proportion of active group in the overall sample size. Default is 0.5 (balanced randomization). A numeric vector of length 1.

alpha

the significance level for the 2-sided test. Default is 0.05. A numeric vector of length 1.

WOnull

the win odds value of the null hypothesis (default is 1). A numeric vector of length 1.

digits

precision to use for reporting calculated win odds.

Value

a data frame containing the calculated WO with input values.

References

Gasparyan SB et al. (2021) "Power and sample size calculation for the win odds test: application to an ordinal endpoint in COVID-19 trials." Journal of Biopharmaceutical Statistics 31.6: 765-787. doi:10.1080/10543406.2021.1968893

See Also

powerWO(), sizeWO() for WO power and sample size calculation.

Examples

minWO(N = 100, digits = 5)
minWO(N = 1200, power = 0.9, k = 0.75)
# Compare the minimum detectable win odds from shifted alternatives to max and ordered alternatives
WO <- minWO(N = 1200, k = 0.5, power = 0.67, digits = 7)$WO
powerWO(N = 1200, WO = WO, k = 0.5, alternative = "shift")
powerWO(N = 1200, WO = WO, k = 0.5, alternative = "ordered")
powerWO(N = 1200, WO = WO, k = 0.5, alternative = "max")

A print method for hce_results objects

Description

A print method for hce_results objects

Usage

## S3 method for class 'hce_results'
plot(x, ...)

Arguments

x

an object of class hce_results.

...

additional arguments to be passed to base::plot() function.

Value

no return value, called for plotting.

Examples

WO <- minWO(N = 100:1000)
plot(WO)
POW <- powerWO(N = 100:1000, WO = 1.2)
plot(POW, ylim = c(0, 1))

Power calculation for the win odds test (no ties)

Description

Power calculation for the win odds test (no ties)

Usage

powerWO(
  N,
  WO,
  SD = NULL,
  k = 0.5,
  alpha = 0.05,
  WOnull = 1,
  alternative = c("shift", "max", "ordered")
)

Arguments

N

a numeric vector of sample size values.

WO

the given win odds for the alternative hypothesis. A numeric vector of length 1.

SD

assumed standard deviation of the win proportion. By default uses the conservative SD. A numeric vector of length 1.

k

proportion of active group in the overall sample size. Default is 0.5 (balanced randomization). A numeric vector of length 1.

alpha

the significance level for the 2-sided test. Default is 0.05. A numeric vector of length 1.

WOnull

the win odds value of the null hypothesis (default is 1). A numeric vector of length 1.

alternative

a character string specifying the class of the alternative hypothesis, must be one of "shift" (default), "max" or "ordered". You can specify just the initial letter.

Details

alternative = "max" refers to the maximum variance of the win proportion across all possible alternatives. The maximum variance equals WP*(1 - WP)/k where the win probability is calculated as ⁠WP = WO/(WO + 1).⁠ alternative = "shift" specifies the variance across alternatives from a shifted family of distributions (Wilcoxon test). The variance formula, as suggested by Noether, is calculated based on the null hypothesis as follows ⁠1/(12*k*(1 - k)).⁠ alternative = "ordered" specifies the variance across alternatives from stochastically ordered distributions which include shifted distributions.

Value

a data frame containing the calculated power with input values.

References

  • All formulas were presented in

    Bamber D (1975) "The area above the ordinal dominance graph and the area below the receiver operating characteristic graph." Journal of Mathematical Psychology 12.4: 387-415. doi:10.1016/0022-2496(75)90001-2.

  • Noether's formula for shifted alternatives

    Noether GE (1987) "Sample size determination for some common nonparametric tests." Journal of the American Statistical Association 82.398: 645-7. doi:10.1080/01621459.1987.10478478.

  • For shift alternatives see also

    Gasparyan SB et al. (2021) "Power and sample size calculation for the win odds test: application to an ordinal endpoint in COVID-19 trials." Journal of Biopharmaceutical Statistics 31.6: 765-787. doi:10.1080/10543406.2021.1968893.

See Also

sizeWO(), minWO() for WO sample size or minimum detectable WO calculation.

Examples

# Example 1- Use the default standard deviation
powerWO(N = 1000, WO = 1.2)
powerWO(N = seq(500, 1500, 100), WO = 1.2)
# Example 2 - Use data-driven win odds and standard deviation from the COVID19 dataset
res <- calcWO(x = COVID19, AVAL = "GROUP", TRTP = "TRTP", ref = "Placebo")
print(res)
powerWO(N = 500, WO = res$WO, SD = res$SD_WP)
powerWO(N = 500, WO = res$WO) # power with the default standard deviation for the win proportion.
# Example 3 - Non-balanced 3:1 randomization
powerWO(N = 1000, WO = 1.2, k = 0.75)
# Example 4 - Comparison of different alternatives
powerWO(N = 1000, WO = 1.2, alternative = "m")
powerWO(N = 1000, WO = 1.2, alternative = "s")
powerWO(N = 1000, WO = 1.2, alternative = "o")

A print method for hce_results objects

Description

A print method for hce_results objects

Usage

## S3 method for class 'hce_results'
print(x, ...)

Arguments

x

an object of class hce_results.

...

additional arguments to be passed to base::print() function.

Value

no return value, called for printing.

Examples

print(powerWO(N = 1000, WO = 1.2))

Proportion of wins/losses/ties given the win odds and the win ratio

Description

Proportion of wins/losses/ties given the win odds and the win ratio

Usage

propWINS(WO, WR, Overall = 1, alpha = NULL, N = NULL)

Arguments

WO

win odds.

WR

win ratio.

Overall

number of comparisons, the sample size of the active treatment multiplied by the sample size of the placebo. The default is 1, hence gives the proportion.

alpha

significance level for the win ratio confidence interval. The default is NULL hence the confidence interval is not produced.

N

the combined sample size of two treatment groups. The default is NULL. If alpha is specified then either N should be specified or Overall > 1. For given Overall, the pooled sample size is calculated as N = 2*sqrt(Overall).

Details

Calculation formula

Value

a data frame with a number (or proportion if Overall = 1) of wins/losses/ties. If alpha is specified returns also WR confidence interval.

References

  • For the relationship between win odds and win ratio see

    Gasparyan SB et al. "Hierarchical Composite Endpoints in COVID-19: The DARE-19 Trial". Case Studies in Innovative Clinical Trials, Chapter 7 (2023): 95-148. Chapman and Hall/CRC. doi:10.1201/9781003288640-7.

  • The win ratio CI uses the standard error presented in

    Yu RX, Ganju J. (2022) "Sample size formula for a win ratio endpoint." Statistics in Medicine 41.6: 950-63. doi:10.1002/sim.9297.

Examples

# Example 1
propWINS(WR = 2, WO = 1.5)
# Example 2 - Back-calculation 
COVID19HCE <- hce(GROUP = COVID19$GROUP, TRTP = COVID19$TRTP)
res <- calcWINS(COVID19HCE)
WR <- res$WR1$WR
WO <- res$WO$WO
Overall <- res$summary$TOTAL
propWINS(WR = WR, WO = WO, Overall = Overall)
## Verify 
res$summary
# Example 3 - Confidence interval
 propWINS(WR = 1.4, WO = 1.3, alpha = 0.05, Overall = 2500)
 propWINS(WR = 2, WO = 1.5, alpha = 0.01, N = 500)

A generic function for win odds regression

Description

A generic function for win odds regression

Usage

regWO(x, ...)

Arguments

x

an object used to select a method.

...

further arguments passed to or from other methods.

Value

a data frame containing calculated values.

See Also

regWO.data.frame() methods.


Win odds regression using a data frame

Description

Win odds regression using a data frame

Usage

## S3 method for class 'data.frame'
regWO(x, AVAL, TRTP, COVAR, ref, alpha = 0.05, WOnull = 1, ...)

Arguments

x

a data frame containing subject-level data.

AVAL

variable in the data with ordinal analysis values.

TRTP

the treatment variable in the data.

COVAR

a numeric covariate.

ref

the reference treatment group.

alpha

significance level. The default is 0.05.

WOnull

the null hypothesis. The default is 1.

...

additional parameters.

Value

a data frame containing the win odds and its confidence interval.

  • WO_beta adjusted win odds.

  • LCL lower confidence limit for adjusted WO.

  • UCL upper confidence limit for adjusted WO.

  • SE standard error of the adjusted win odds.

  • WOnull win odds of the null hypothesis (specified in the WOnull argument).

  • alpha two-sided significance level for calculating the confidence interval (specified in the alpha argument).

  • Pvalue p-value associated with testing the null hypothesis.

  • N total number of patients in the analysis.

  • beta adjusted win probability.

  • SE_beta standard error for the adjusted win probability.

  • SD_beta standard deviation for the adjusted win probability.

  • WP (non-adjusted) win probability.

  • SE_WP standard error of the non-adjusted win probability.

  • SD_WP standard deviation of the non-adjusted win probability.

  • WO non-adjusted win odds.

  • COVAR_MEAN_DIFF mean difference between two treatment groups of the numeric covariate.

  • COVAR_VAR sum of variances of two treatment groups of the numeric covariate.

  • COVAR_COV covariance between the response and the numeric covariate.

References

Gasparyan SB et al. (2021) "Adjusted win ratio with stratification: calculation methods and interpretation." Statistical Methods in Medical Research 30.2: 580-611. doi:10.1177/0962280220942558.

See Also

regWO().

Examples

# A baseline covariate that is highly correlated with the outcome
set.seed(2023)
dat <- COVID19
n <- nrow(dat)
dat$Severity <- ifelse(dat$GROUP > 4, rnorm(n, 0), rnorm(n, 100))
tapply(dat$Severity, dat$TRTP, mean)
regWO(x = dat, AVAL = "GROUP", TRTP = "TRTP", COVAR = "Severity", ref = "Placebo")
# Without adjustment
calcWO(x = dat, AVAL = "GROUP", TRTP = "TRTP", ref = "Placebo")

Simulate adhce object with given event rates of time-to-event outcomes (Weibull), mean and SD of the continuous outcome (normal or log-normal) by treatment group

Description

Simulate adhce object with given event rates of time-to-event outcomes (Weibull), mean and SD of the continuous outcome (normal or log-normal) by treatment group

Usage

simADHCE(
  n,
  n0 = n,
  TTE_A,
  TTE_P,
  CM_A,
  CM_P,
  CSD_A = 1,
  CSD_P = CSD_A,
  fixedfy = 1,
  yeardays = 360,
  pat = 100,
  shape = 1,
  logC = FALSE,
  seed = NULL,
  dec = 2
)

Arguments

n

sample size in the active treatment group.

n0

sample size in the placebo group.

TTE_A

event rates per year in the active group for the time-to-event outcomes.

TTE_P

event rates per year in the placebo group for the time-to-event outcomes. Should have the same length as TTE_A.

CM_A

mean value for the continuous outcome of the active group.

CM_P

mean value for the continuous outcome of the placebo group.

CSD_A

standard deviation for the continuous outcome of the active group.

CSD_P

standard deviation for the continuous outcome of the placebo group.

fixedfy

length of follow-up in years.

yeardays

number of days in a year.

pat

scale of provided event rates (per pat-years).

shape

shape of the Weibull distribution for time-to-event outcomes. Default is exponential distribution with shape = 1.

logC

logical, whether to use log-normal distribution for the continuous outcome.

seed

for generating random numbers.

dec

decimal places for the continuous outcome used for rounding. The default is dec = 2.

Value

an object of class adhce containing an hce object with its source datasets ADET (event-time dataset for all time-to-event outcomes per patient) and BDS (basic data structure for the continuous outcome for all patients). The hce object has the following columns:

  • ID subject identifier.

  • TRTP planned treatment group - "A" for active, "P" for Placebo.

  • GROUP type of the outcome, either "TTE" for time-to-event outcomes or "C" for continuous. Only one continuous outcome is possible, but no restriction on the number of "TTE" outcomes.

  • GROUPN order of outcomes in GROUP, with a higher value signifying a better outcome.

  • AVALT the timing of the time-to-event outcomes.

  • AVAL0 numeric values of the continuous outcome and the timing of "TTE" outcomes.

  • AVAL analysis values derived as AVAL0 + GROUPN. For the continuous outcome the values of AVAL0 are shifted to start always from 0.

  • seed the seed of the random sample. If not specified in seed argument will be selected based on system time.

  • PADY primary analysis day, the length of fixed follow-up in days calculated as yeardays multiplied by fixedfy.

See Also

simHCE() for directly simulating hce objects.

Examples

# Example 1
Rates_A <- c(1.72, 1.74, 0.58, 1.5, 1)
Rates_P <- c(2.47, 2.24, 2.9, 4, 6)
l <- simADHCE(n = 2500, TTE_A = Rates_A, TTE_P = Rates_P,
              CM_A = -3, CM_P = -6, CSD_A = 16, CSD_P = 15, fixedfy = 3, seed = 2024)
names(l)
head(l$HCE)
head(l$ADET)
head(l$BDS)

# Example 2
Rates_A <- 10
Rates_P <- 15
l <- simADHCE(n = 1000, n0 = 500, TTE_A = Rates_A, TTE_P = Rates_P, 
CM_A = 0.1, CM_P = 0, seed = 5, shape = 0.2, logC = TRUE, dec = 0)
summaryWO(l$HCE)

Simulate hce object with given event rates of time-to-event outcomes (Weibull), mean and SD of the continuous outcome (normal or log-normal) by treatment group

Description

Simulate hce object with given event rates of time-to-event outcomes (Weibull), mean and SD of the continuous outcome (normal or log-normal) by treatment group

Usage

simHCE(
  n,
  n0 = n,
  TTE_A,
  TTE_P,
  CM_A,
  CM_P,
  CSD_A = 1,
  CSD_P = CSD_A,
  fixedfy = 1,
  yeardays = 360,
  pat = 100,
  shape = 1,
  logC = FALSE,
  seed = NULL,
  dec = 2
)

Arguments

n

sample size in the active treatment group.

n0

sample size in the placebo group.

TTE_A

event rates per year in the active group for the time-to-event outcomes.

TTE_P

event rates per year in the placebo group for the time-to-event outcomes. Should have the same length as TTE_A.

CM_A

mean value for the continuous outcome of the active group.

CM_P

mean value for the continuous outcome of the placebo group.

CSD_A

standard deviation for the continuous outcome of the active group.

CSD_P

standard deviation for the continuous outcome of the placebo group.

fixedfy

length of follow-up in years.

yeardays

number of days in a year.

pat

scale of provided event rates (per pat-years).

shape

shape of the Weibull distribution for time-to-event outcomes. Default is exponential distribution with shape = 1.

logC

logical, whether to use log-normal distribution for the continuous outcome.

seed

for generating random numbers.

dec

decimal places for the continuous outcome used for rounding. The default is dec = 2.

Value

an object of class hce containing the following columns:

  • ID subject identifier.

  • TRTP planned treatment group - "A" for active, "P" for Placebo.

  • GROUP type of the outcome, either "TTE" for time-to-event outcomes or "C" for continuous. Only one continuous outcome is possible, but no restriction on the number of "TTE" outcomes.

  • GROUPN order of outcomes in GROUP, with a higher value signifying a better outcome.

  • AVALT the timing of the time-to-event outcomes.

  • AVAL0 numeric values of the continuous outcome and the timing of "TTE" outcomes.

  • AVAL analysis values derived as AVAL0 + GROUPN. For the continuous outcome the values of AVAL0 are shifted to start always from 0.

  • seed the seed of the random sample. If not specified in seed argument will be selected based on system time.

  • PADY primary analysis day, the length of fixed follow-up in days calculated as yeardays multiplied by fixedfy.

See Also

hce(), as_hce() for the helper a coerce function to hce objects.

Examples

# Example 1
Rates_A <- c(1.72, 1.74, 0.58, 1.5, 1)
Rates_P <- c(2.47, 2.24, 2.9, 4, 6)
dat <- simHCE(n = 2500, TTE_A = Rates_A, TTE_P = Rates_P,
              CM_A = -3, CM_P = -6, CSD_A = 16, CSD_P = 15, fixedfy = 3)
head(dat)

# Example 2
Rates_A <- 10
Rates_P <- 15
dat <- simHCE(n = 1000, n0 = 500, TTE_A = Rates_A, TTE_P = Rates_P, 
              CM_A = 0.1, CM_P = 0, seed = 5, shape = 0.2, logC = TRUE, dec = 0)
summaryWO(dat)

Simulate ordinal variables for two treatment groups using categorization of beta distributions

Description

Simulate ordinal variables for two treatment groups using categorization of beta distributions

Usage

simORD(n, n0 = n, M, alpha1 = 8, beta1 = 7, alpha0 = 5, beta0 = 5)

Arguments

n

sample size in the active treatment group.

n0

sample size in the placebo group.

M

number of ordinal values to be simulated.

alpha1

shape1 parameter for the beta distribution in the active group.

beta1

shape2 parameter for the beta distribution in the active group.

alpha0

shape1 parameter for the beta distribution in the placebo group.

beta0

shape2 parameter for the beta distribution in the placebo group.

Value

a data frame containing the following columns:

  • ID subject identifier.

  • TRTP planned treatment group - "A" for active, "P" for Placebo.

  • GROUPN ordinal values. The number of unique values is specified by the variable M0.

  • tau the theoretical win odds.

  • theta the theoretical win probability.

See Also

simHCE(), simADHCE() for simulating hce objects.

Examples

# Example 1
set.seed(2024)
alpha1 <- 8
beta1 <- 8
alpha0 <- 4
beta0 <- 5
d <- simORD(n = 1500, n0 = 1500, M = 5, alpha1 = alpha1, beta1 = beta1, 
alpha0 = alpha0, beta0 = beta0)
x <- seq(0, 1, 0.01)
plot(x, dbeta(x, shape1 = alpha1, shape2 = beta1), 
type = "l", ylab = "Density of beta distribution", col = 2)
lines(x, dbeta(x, shape1 = alpha0, shape2 = beta0), col = 3, lty = 2)
legend("topleft", lty = c(1, 2), col = c(2, 3), legend = c("Control", "Active"))
D <- hce(GROUP = d$GROUPN, TRTP = d$TRTP)
table(D$TRTP, D$GROUPN)
calcWO(D)
# Example 2
set.seed(2024)
d <- simORD(n = 100, n0 = 50, M = 2)
d_hce <- hce(GROUP = d$GROUPN, TRTP = d$TRTP)
calcWO(d_hce)
### compare with the theoretical values of the continuous distributions 
c(tau = unique(d$tau), theta = unique(d$theta))
# Example 2 - Convergence of the win odds to its theoretical value
set.seed(2024)
N <- NULL
size <- c(seq(10, 500, 1))
for(i in size){
  d <- simORD(n = i, M = 2)
  d_hce <- hce(GROUP = d$GROUPN, TRTP = d$TRTP)
  TAU <- calcWO(d_hce)
  D <- data.frame(WO = TAU$WO, n = i, tau = unique(d$tau))
  N <- rbind(N, D)
}
plot(N$n, N$WO, log = "y", ylim = c(0.5, 2), ylab = "Win Odds", xlab = "Sample size", type = "l")
lines(N$n, N$tau, col = "darkgreen", lty = 2, lwd = 2)
abline(h = 1, lty = 4, col = "red")
legend("bottomright", legend = c("Theoretical Win Odds", "Null", "Win Odds Estimate"), 
lty = c(4, 2, 1), col = c("darkgreen", "red", "black"))
title("Convergence of the win odds to its theoretical value")

Sample size calculation for the win odds test (no ties)

Description

Sample size calculation for the win odds test (no ties)

Usage

sizeWO(
  WO,
  power,
  SD = NULL,
  k = 0.5,
  alpha = 0.05,
  WOnull = 1,
  alternative = c("shift", "max", "ordered")
)

Arguments

WO

a numeric vector of win odds values.

power

the given power. A numeric vector of length 1.

SD

assumed standard deviation of the win proportion. By default uses the conservative SD. A numeric vector of length 1.

k

proportion of active group in the overall sample size. Default is 0.5 (balanced randomization). A numeric vector of length 1.

alpha

the significance level for the 2-sided test. Default is 0.05. A numeric vector of length 1.

WOnull

the win odds value of the null hypothesis (default is 1). A numeric vector of length 1.

alternative

a character string specifying the class of the alternative hypothesis, must be one of "shift" (default), "max" or "ordered". You can specify just the initial letter.

Details

alternative = "max" refers to the maximum variance of the win proportion across all possible alternatives. The maximum variance equals WP*(1 - WP)/k where the win probability is calculated as ⁠WP = WO/(WO + 1).⁠ alternative = "shift" specifies the variance across alternatives from a shifted family of distributions (Wilcoxon test). The variance formula, as suggested by Noether, is calculated based on the null hypothesis as follows ⁠1/(12*k*(1 - k)).⁠ alternative = "ordered" specifies the variance across alternatives from stochastically ordered distributions which include shifted distributions.

Value

a data frame containing the sample size with input values.

References

  • All formulas were presented in

    Bamber D (1975) "The area above the ordinal dominance graph and the area below the receiver operating characteristic graph." Journal of Mathematical Psychology 12.4: 387-415. doi:10.1016/0022-2496(75)90001-2.

  • Noether's formula for shifted alternatives

    Noether GE (1987) "Sample size determination for some common nonparametric tests." Journal of the American Statistical Association 82.398: 645-7. doi:10.1080/01621459.1987.10478478.

  • For shift alternatives see also

    Gasparyan SB et al. (2021) "Power and sample size calculation for the win odds test: application to an ordinal endpoint in COVID-19 trials." Journal of Biopharmaceutical Statistics 31.6: 765-787. doi:10.1080/10543406.2021.1968893.

See Also

powerWO(), minWO() for WO power or minimum detectable WO calculation.

Examples

sizeWO(WO = 1.25, power = 0.9)
sizeWO(WO = 1.25, power = 0.9, k = 0.75)
sizeWO(WO = seq(1.05, 1.5, 0.05), power = 0.9)
# Comparison of different alternatives
x <- seq(1.05, 5, 0.05)
N1 <- sizeWO(WO = x, power = 0.9, alternative = "m")$SampleSize
N2 <- sizeWO(WO = x, power = 0.9, alternative = "o")$SampleSize
N3 <- sizeWO(WO = x, power = 0.9, alternative = "s")$SampleSize
d <- data.frame(WO = x, N_m = N1, N_o = N2, N_s = N3)
## Check the power for the ordered alternative
check <- c()
for(i in seq_along(x)){
check[i] <- powerWO(N = d[i, "N_o"], WO = d[i, "WO"], alternative = "o")$power
}
d$power_check_o <- check
print(d)

Sample size calculation for the win ratio test (with WR = 1 null hypothesis)

Description

Sample size calculation for the win ratio test (with WR = 1 null hypothesis)

Usage

sizeWR(WR, power, WO = NULL, Pties = NULL, k = 0.5, alpha = 0.05)

Arguments

WR

a numeric vector of win odds values.

power

the given power. A numeric vector of length 1.

WO

win odds. Should be specified only if Pties is not specified. A numeric vector of length 1.

Pties

probability of ties. A numeric vector of length 1.

k

proportion of active group in the overall sample size. Default is 0.5 (balanced randomization). A numeric vector of length 1.

alpha

the significance level for the 2-sided test. Default is 0.05. A numeric vector of length 1.

Value

a data frame containing the sample size with input values.

References

Yu RX, Ganju J. (2022) "Sample size formula for a win ratio endpoint." Statistics in Medicine, 41.6: 950-63. doi:10.1002/sim.9297.

See Also

sizeWO() for WO sample size calculation.

Examples

sizeWR(WR = 1.35, Pties = 0.125, power = 0.8)
sizeWR(WR = 1.35, WO = 1.3, power = seq(0.5, 0.9, 0.05))

A generic function for stratified win odds with adjustment

Description

A generic function for stratified win odds with adjustment

Usage

stratWO(x, ...)

Arguments

x

an object used to select a method.

...

further arguments passed to or from other methods.

Value

a list containing the stratified results and results by strata.

See Also

stratWO.data.frame() methods.


Stratified win odds with adjustment

Description

Stratified win odds with adjustment

Usage

## S3 method for class 'data.frame'
stratWO(
  x,
  AVAL,
  TRTP,
  STRATA,
  ref,
  COVAR = NULL,
  alpha = 0.05,
  WOnull = 1,
  ...
)

Arguments

x

a data frame containing subject-level data.

AVAL

variable in the data with ordinal analysis values.

TRTP

the treatment variable in the data.

STRATA

a character variable for stratification.

ref

the reference treatment group.

COVAR

a numeric covariate.

alpha

the reference treatment group.

WOnull

the null hypothesis. The default is 1.

...

additional parameters.

Value

a data frame containing the following columns:

  • WO stratified (or adjusted/stratified) win odds.

  • LCL lower confidence limit for adjusted (or adjusted/stratified) WO.

  • UCL upper confidence limit for adjusted (or adjusted/stratified) WO.

  • SE standard error of the adjusted (or adjusted/stratified) win odds.

  • WOnull win odds of the null hypothesis (specified in the WOnull argument).

  • alpha two-sided significance level for calculating the confidence interval (specified in the alpha argument).

  • Pvalue p-value associated with testing the null hypothesis.

  • WP adjusted (or adjusted/stratified) win probability.

  • SE_WP standard error for the adjusted (or adjusted/stratified) win probability.

  • SD_WP standard deviation of the adjusted (or adjusted/stratified) win probability.

  • N total number of patients in the analysis.

  • Type "STRATIFIED" or "STRATIFIED/ADJUSTED" depending on whether COVAR is specified.

References

Gasparyan SB et al. (2021) "Adjusted win ratio with stratification: calculation methods and interpretation." Statistical Methods in Medical Research 30.2: 580-611. doi:10.1177/0962280220942558.

See Also

stratWO().

Examples

# Stratified win odds
res <- stratWO(x = KHCE, AVAL = "AVAL", TRTP = "TRTP", 
STRATA = "STRATAN", ref = "P")
res
## Compare with the win odds in each stratum separately
lapply(split(KHCE, KHCE$STRATAN), calcWO, AVAL = "AVAL", TRTP = "TRTP", ref = "P")
# Stratified and adjusted win odds
res <- stratWO(x = KHCE, AVAL = "AVAL", COVAR = "EGFRBL", 
TRTP = "TRTP", STRATA = "STRATAN", ref = "P")
res

A generic function for summarizing win odds

Description

A generic function for summarizing win odds

Usage

summaryWO(x, ...)

Arguments

x

an object used to select a method.

...

further arguments passed to or from other methods.

Value

a data frame containing calculated values.

See Also

summaryWO.hce(), summaryWO.formula(), summaryWO.data.frame() methods.


Win odds summary for a data frame

Description

Win odds summary for a data frame

Usage

## S3 method for class 'data.frame'
summaryWO(x, AVAL, TRTP, ref, GROUP = NULL, ...)

Arguments

x

a data frame containing subject-level data.

AVAL

variable in the data with ordinal analysis values.

TRTP

the treatment variable in the data.

ref

the reference treatment group.

GROUP

an optional variable for grouping.

...

additional parameters.

Value

a list containing the summary of wins, losses, and ties. It contains the following named objects:

  • summary a data frame containing number of wins, losses, and ties by treatment group and the overall number of comparisons.

  • summary_by_GROUP (if GROUP variable is specified) a summary data frame by GROUP.

  • WO calculated WO (win odds) and WP (win probability) and their standard errors.

See Also

calcWO(), summaryWO(), summaryWO.data.frame() methods.

Examples

summaryWO(x = HCE3, AVAL = "AVAL", TRTP = "TRTP", ref = "P", GROUP = "GROUP")

Win odds summary using formula syntax

Description

Win odds summary using formula syntax

Usage

## S3 method for class 'formula'
summaryWO(x, data, ...)

Arguments

x

an object of class formula.

data

a data frame.

...

additional parameters.

Value

a list containing the summary of wins, losses, and ties. It contains the following named objects:

  • summary a data frame containing number of wins, losses, and ties by treatment group and the overall number of comparisons.

  • WO calculated WO (win odds) and WP (win probability) and their standard errors.

  • formula returning the specified formula in the x argument.

  • ref showing how the reference group was selected. Can be modifying by specifying the ref argument.

Examples

summaryWO(data = COVID19, GROUP ~ TRTP)
summaryWO(data = COVID19, GROUP ~ TRTP, GROUP = "GROUP", ref = "Placebo")

Win odds summary for hce objects

Description

Win odds summary for hce objects

Usage

## S3 method for class 'hce'
summaryWO(x, ...)

Arguments

x

an hce object.

...

additional parameters.

Value

a list containing the summary of wins, losses, and ties. It contains the following named objects:

  • summary a data frame containing number of wins, losses, and ties by treatment group and the overall number of comparisons.

  • summary_by_GROUP (if GROUP variable is specified) a summary data frame by GROUP.

  • WO calculated WO (win odds) and WP (win probability) and their standard errors.

See Also

calcWO(), summaryWO(), summaryWO.data.frame() methods.

Examples

dat <- as_hce(HCE4)
summaryWO(dat, ref = "P")