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 |
A dataset with multiple kidney outcomes over time scale outcomes of 1500 patients in the ADSL
dataset.
ADET
ADET
a data frame with 604 rows (events) and 6 variables:
patient identifiers, numeric
occurence time of the event, numeric
name of the event, character
coded name of the event, character
type of the event, outcomes 1-7, where a higher value means a better outcome, numeric
treatment values, 1 Active or 2 Placebo, numeric
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.
head(ADET) # Number of unique patients length(unique(ADET$ID)) # Number of events per event type barplot(table(ADET$PARAM))
head(ADET) # Number of unique patients length(unique(ADET$ID)) # Number of events per event type barplot(table(ADET$PARAM))
A dataset of laboratory measurements of kidney function over time for the 1500 patients in the ADSL
dataset.
ADLB
ADLB
a data frame with 13980 rows and 8 variables:
patient identifiers, numeric
treatment values, 1 Active or 2 Placebo, numeric
measurement value, numeric
measurement day in the study, numeric
hospital visit number, numeric
name of the event, GFR measurments, character
coded name of the event, GFR, character
type of the event is set to 7 for all measurements, numeric
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.
head(ADLB)
head(ADLB)
A data frame with baseline characteristics for 1500 patients used to derive KHCE
dataset.
ADSL
ADSL
a data frame with 1500 rows and 4 variables:
patient identifiers, numeric
treatment values, 1 Active or 2 Placebo, numeric
Baseline GFR values of patients, numeric
strata 1-4, higher value means a higher risk for kidney disease progression, numeric
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.
head(ADSL)
head(ADSL)
hce
objectsA generic function for coercing data structures to hce
objects
as_hce(x, ...)
as_hce(x, ...)
x |
an object used to select a method. |
... |
additional parameters. |
an hce
object.
### data frames data(HCE1) HCE <- as_hce(HCE1) calcWINS(HCE)
### data frames data(HCE1) HCE <- as_hce(HCE1) calcWINS(HCE)
hce
objectCoerce a data frame to an hce
object
## S3 method for class 'data.frame' as_hce(x, ...)
## S3 method for class 'data.frame' as_hce(x, ...)
x |
a data frame. |
... |
additional parameters. |
an hce
object.
KHCE <- as_hce(KHCE) calcWO(KHCE)
KHCE <- as_hce(KHCE) calcWO(KHCE)
A generic function for calculating win statistics
calcWINS(x, ...)
calcWINS(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
a data frame containing calculated values.
calcWINS.hce()
, calcWINS.formula()
, calcWINS.data.frame()
methods.
Win statistics calculation using a data frame
## S3 method for class 'data.frame' calcWINS(x, AVAL, TRTP, ref, alpha = 0.05, WOnull = 1, ...)
## S3 method for class 'data.frame' calcWINS(x, AVAL, TRTP, ref, alpha = 0.05, WOnull = 1, ...)
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. |
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.
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.
calcWINS()
, calcWINS.hce()
, calcWINS.formula()
.
calcWINS(x = COVID19b, AVAL = "GROUP", TRTP = "TRTP", ref = "Placebo")
calcWINS(x = COVID19b, AVAL = "GROUP", TRTP = "TRTP", ref = "Placebo")
Win statistics calculation using formula syntax
## S3 method for class 'formula' calcWINS(x, data, ...)
## S3 method for class 'formula' calcWINS(x, data, ...)
x |
an object of class formula. |
data |
a data frame. |
... |
additional parameters. |
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.
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.
calcWINS()
, calcWINS.hce()
, calcWINS.data.frame()
.
# Example 1 calcWINS(x = GROUP ~ TRTP, data = COVID19b) # Example 2 calcWINS(x = GROUP ~ TRTP, data = COVID19, ref = "Placebo", alpha = 0.01, WOnull = 1.2)
# Example 1 calcWINS(x = GROUP ~ TRTP, data = COVID19b) # Example 2 calcWINS(x = GROUP ~ TRTP, data = COVID19, ref = "Placebo", alpha = 0.01, WOnull = 1.2)
hce
objectsWin statistics calculation for hce
objects
## S3 method for class 'hce' calcWINS(x, ...)
## S3 method for class 'hce' calcWINS(x, ...)
x |
an |
... |
additional parameters. |
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.
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.
calcWINS()
, calcWINS.formula()
, calcWINS.data.frame()
.
# 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)
# 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
calcWO(x, ...)
calcWO(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
a data frame containing calculated values.
calcWO.hce()
, calcWO.formula()
, calcWO.data.frame()
methods.
Win odds calculation using a data frame
## S3 method for class 'data.frame' calcWO(x, AVAL, TRTP, ref, alpha = 0.05, WOnull = 1, ...)
## S3 method for class 'data.frame' calcWO(x, AVAL, TRTP, ref, alpha = 0.05, WOnull = 1, ...)
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. |
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.
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
calcWO()
, calcWO.hce()
, calcWO.formula()
.
data(HCE4) calcWO(x = HCE4, AVAL = "AVAL", TRTP = "TRTP", ref = "P")
data(HCE4) calcWO(x = HCE4, AVAL = "AVAL", TRTP = "TRTP", ref = "P")
Win odds calculation using formula syntax
## S3 method for class 'formula' calcWO(x, data, ...)
## S3 method for class 'formula' calcWO(x, data, ...)
x |
an object of class formula. |
data |
a data frame. |
... |
additional parameters. |
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.
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
calcWO()
, calcWO.hce()
, calcWO.data.frame()
.
#Example 1 data(HCE1) calcWO(AVAL ~ TRTP, data = HCE1) #Example 2 calcWO(data = COVID19, GROUP ~ TRTP, ref = "Placebo")
#Example 1 data(HCE1) calcWO(AVAL ~ TRTP, data = HCE1) #Example 2 calcWO(data = COVID19, GROUP ~ TRTP, ref = "Placebo")
hce
objectsWin odds calculation for hce
objects
## S3 method for class 'hce' calcWO(x, ...)
## S3 method for class 'hce' calcWO(x, ...)
x |
an |
... |
additional parameters. |
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.
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
calcWO()
, calcWO.formula()
, calcWO.data.frame()
.
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)
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)
A dataset with COVID-19 ordinal scale outcomes for 1062 patients.
COVID19
COVID19
a data frame with 1062 rows and 2 variables:
type of the event, ordinal outcomes 1-8, where a higher value means a better outcome
treatment values, A Active or P Placebo, character
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.
#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")
#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")
A dataset with COVID-19 ordinal scale outcomes for 844 patients.
COVID19b
COVID19b
a data frame with 844 rows and 2 variables:
type of the event, ordinal outcomes 1-8, where a higher value means a better outcome
treatment values, Active or Placebo, character
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.
#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")
#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")
A dataset with COVID-19 ordinal scale outcomes for 1033 patients.
COVID19plus
COVID19plus
a data frame with 1033 rows and 4 variables:
patient identifiers, numeric
treatment values, A Active or P Placebo, character
type of the event, ordinal outcomes 1-8, where a higher value means a better outcome
baseline ordinal values
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.
COVID19HCE <- hce(GROUP = COVID19plus$GROUP, TRTP = COVID19plus$TRTP) # Summary wins, losses, and ties with win odds summaryWO(COVID19HCE, ref = "P")
COVID19HCE <- hce(GROUP = COVID19plus$GROUP, TRTP = COVID19plus$TRTP) # Summary wins, losses, and ties with win odds summaryWO(COVID19HCE, ref = "P")
hce
objectsHelper function for hce
objects
hce( GROUP = character(), TRTP = character(), AVAL0 = 0, ORD = sort(unique(GROUP)) )
hce( GROUP = character(), TRTP = character(), AVAL0 = 0, ORD = sort(unique(GROUP)) )
GROUP |
a character vector of the same length as |
TRTP |
a character vector of the same length as |
AVAL0 |
a numeric vector of analysis values within each category. The default is 0. |
ORD |
a character vector containing ordered unique values of the |
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.
as_hce()
for coercing to hce
objects.
# 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")
# 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.A simulated dataset containing the ordinal values and other attributes for 1000 patients. HCE1
HCE1
HCE1
a data frame with 1000 rows and 6 variables:
subject ID, numbers from 1 to 1000
treatment values, A Active or P Placebo, character
type of the event, either Time-To-Event (TTE) or Continuous (C), character
type of the event, for the ordering of outcomes in the GROUP
variable, numeric
the timing of the time-to-event outcomes, numeric
original values for each type of the event, time for TTE outcomes, numeric values for Continuous outcomes, numeric
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
primary analysis day, the length of fixed follow-up in days, numeric
HCE1
, HCE2
, HCE3
, HCE4
datasets for 1000 patients with different treatment effects.A simulated dataset containing the ordinal values and other attributes for 1000 patients. HCE2
HCE2
HCE2
a data frame with 1000 rows and 6 variables:
subject ID, numbers from 1 to 1000
treatment values, A Active or P Placebo, character
type of the event, either Time-To-Event (TTE) or Continuous (C), character
type of the event, for the ordering of outcomes in the GROUP
variable, numeric
the timing of the time-to-event outcomes, numeric
original values for each type of the event, time for TTE outcomes, numeric values for Continuous outcomes, numeric
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
primary analysis day, the length of fixed follow-up in days, numeric
HCE1
, HCE2
, HCE3
, HCE4
datasets for 1000 patients with different treatment effects.A simulated dataset containing the ordinal values and other attributes for 1000 patients. HCE3
HCE3
HCE3
a data frame with 1000 rows and 6 variables:
subject ID, numbers from 1 to 1000
treatment values, A Active or P Placebo, character
type of the event, either Time-To-Event (TTE) or Continuous (C), character
type of the event, for the ordering of outcomes in the GROUP
variable, numeric
the timing of the time-to-event outcomes, numeric
original values for each type of the event, time for TTE outcomes, numeric values for Continuous outcomes, numeric
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
primary analysis day, the length of fixed follow-up in days, numeric
HCE1
, HCE2
, HCE3
, HCE4
datasets for 1000 patients with different treatment effects.A simulated dataset containing the ordinal values and other attributes for 1000 patients. HCE4
HCE4
HCE4
a data frame with 1000 rows and 6 variables:
subject ID, numbers from 1 to 1000
treatment values, A Active or P Placebo, character
type of the event, either Time-To-Event (TTE) or Continuous (C), character
type of the event, for the ordering of outcomes in the GROUP
variable, numeric
the timing of the time-to-event outcomes, numeric
original values for each type of the event, time for TTE outcomes, numeric values for Continuous outcomes, numeric
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
primary analysis day, the length of fixed follow-up in days, numeric
A dataset with kidney ordinal scale outcomes of 1500 patients in the ADSL
dataset.
KHCE
KHCE
a data frame with 1500 rows and 11 variables:
patient identifiers, numeric
treatment values, 1 Active or 2 Placebo, numeric
original values for each type of the event, time for TTE outcomes 1-6, numeric values for Continuous outcome 7, numeric
AVAL = AVAL0 + GROUPN
, ordinal analysis values for the HCE analysis, numeric, but caution NOT to apply numeric operations; will give meaningless results
name of the event, character
ordinal outcomes corresponding to PARAMN
values, numeric
coded name of the event, character
severity of the event, outcomes 1-7, where a higher value means a better outcome, character
strata 1-4, higher value means more severe kidney disease, numeric
Baseline GFR values of patients, numeric
treatment values, A Active or P Placebo, character
primary analysis day (in years), length of the fixed follow-up, numeric
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.
# Adjusted win odds res <- regWO(x = KHCE, AVAL = "AVAL", TRTP = "TRTP", COVAR = "STRATAN", ref = "P") res
# 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)
minWO(N, power = 0.5, SD = NULL, k = 0.5, alpha = 0.05, WOnull = 1, digits = 2)
minWO(N, power = 0.5, SD = NULL, k = 0.5, alpha = 0.05, WOnull = 1, digits = 2)
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. |
a data frame containing the calculated WO with input values.
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
powerWO()
, sizeWO()
for WO power and sample size calculation.
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")
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")
hce_results
objectsA print method for hce_results
objects
## S3 method for class 'hce_results' plot(x, ...)
## S3 method for class 'hce_results' plot(x, ...)
x |
an object of class |
... |
additional arguments to be passed to |
no return value, called for plotting.
WO <- minWO(N = 100:1000) plot(WO) POW <- powerWO(N = 100:1000, WO = 1.2) plot(POW, ylim = c(0, 1))
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)
powerWO( N, WO, SD = NULL, k = 0.5, alpha = 0.05, WOnull = 1, alternative = c("shift", "max", "ordered") )
powerWO( N, WO, SD = NULL, k = 0.5, alpha = 0.05, WOnull = 1, alternative = c("shift", "max", "ordered") )
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 |
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.
a data frame containing the calculated power with input values.
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.
sizeWO()
, minWO()
for WO sample size or minimum detectable WO calculation.
# 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")
# 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")
hce_results
objectsA print method for hce_results
objects
## S3 method for class 'hce_results' print(x, ...)
## S3 method for class 'hce_results' print(x, ...)
x |
an object of class |
... |
additional arguments to be passed to |
no return value, called for printing.
print(powerWO(N = 1000, WO = 1.2))
print(powerWO(N = 1000, WO = 1.2))
Proportion of wins/losses/ties given the win odds and the win ratio
propWINS(WO, WR, Overall = 1, alpha = NULL, N = NULL)
propWINS(WO, WR, Overall = 1, alpha = NULL, N = NULL)
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 |
N |
the combined sample size of two treatment groups. The default is |
a data frame with a number (or proportion if Overall = 1
) of wins/losses/ties. If alpha
is specified returns also WR
confidence interval.
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.
# 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)
# 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
regWO(x, ...)
regWO(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
a data frame containing calculated values.
regWO.data.frame()
methods.
Win odds regression using a data frame
## S3 method for class 'data.frame' regWO(x, AVAL, TRTP, COVAR, ref, alpha = 0.05, WOnull = 1, ...)
## S3 method for class 'data.frame' regWO(x, AVAL, TRTP, COVAR, ref, alpha = 0.05, WOnull = 1, ...)
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. |
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.
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.
# 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")
# 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")
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 groupSimulate 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
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 )
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 )
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 |
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 |
shape |
shape of the Weibull distribution for time-to-event outcomes. Default is exponential distribution with |
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 |
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
.
simHCE()
for directly simulating hce
objects.
# 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)
# 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)
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 groupSimulate 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
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 )
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 )
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 |
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 |
shape |
shape of the Weibull distribution for time-to-event outcomes. Default is exponential distribution with |
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 |
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
.
hce()
, as_hce()
for the helper a coerce function to hce
objects.
# 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)
# 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
simORD(n, n0 = n, M, alpha1 = 8, beta1 = 7, alpha0 = 5, beta0 = 5)
simORD(n, n0 = n, M, alpha1 = 8, beta1 = 7, alpha0 = 5, beta0 = 5)
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. |
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.
simHCE()
, simADHCE()
for simulating hce
objects.
# 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")
# 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)
sizeWO( WO, power, SD = NULL, k = 0.5, alpha = 0.05, WOnull = 1, alternative = c("shift", "max", "ordered") )
sizeWO( WO, power, SD = NULL, k = 0.5, alpha = 0.05, WOnull = 1, alternative = c("shift", "max", "ordered") )
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 |
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.
a data frame containing the sample size with input values.
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.
powerWO()
, minWO()
for WO power or minimum detectable WO calculation.
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)
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)
sizeWR(WR, power, WO = NULL, Pties = NULL, k = 0.5, alpha = 0.05)
sizeWR(WR, power, WO = NULL, Pties = NULL, k = 0.5, alpha = 0.05)
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 |
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. |
a data frame containing the sample size with input values.
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.
sizeWO()
for WO sample size calculation.
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))
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
stratWO(x, ...)
stratWO(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
a list containing the stratified results and results by strata.
stratWO.data.frame()
methods.
Stratified win odds with adjustment
## S3 method for class 'data.frame' stratWO( x, AVAL, TRTP, STRATA, ref, COVAR = NULL, alpha = 0.05, WOnull = 1, ... )
## S3 method for class 'data.frame' stratWO( x, AVAL, TRTP, STRATA, ref, COVAR = NULL, alpha = 0.05, WOnull = 1, ... )
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. |
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.
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.
# 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
# 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
summaryWO(x, ...)
summaryWO(x, ...)
x |
an object used to select a method. |
... |
further arguments passed to or from other methods. |
a data frame containing calculated values.
summaryWO.hce()
, summaryWO.formula()
, summaryWO.data.frame()
methods.
Win odds summary for a data frame
## S3 method for class 'data.frame' summaryWO(x, AVAL, TRTP, ref, GROUP = NULL, ...)
## S3 method for class 'data.frame' summaryWO(x, AVAL, TRTP, ref, GROUP = NULL, ...)
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. |
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.
calcWO()
, summaryWO()
, summaryWO.data.frame()
methods.
summaryWO(x = HCE3, AVAL = "AVAL", TRTP = "TRTP", ref = "P", GROUP = "GROUP")
summaryWO(x = HCE3, AVAL = "AVAL", TRTP = "TRTP", ref = "P", GROUP = "GROUP")
Win odds summary using formula syntax
## S3 method for class 'formula' summaryWO(x, data, ...)
## S3 method for class 'formula' summaryWO(x, data, ...)
x |
an object of class formula. |
data |
a data frame. |
... |
additional parameters. |
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.
summaryWO(data = COVID19, GROUP ~ TRTP) summaryWO(data = COVID19, GROUP ~ TRTP, GROUP = "GROUP", ref = "Placebo")
summaryWO(data = COVID19, GROUP ~ TRTP) summaryWO(data = COVID19, GROUP ~ TRTP, GROUP = "GROUP", ref = "Placebo")
hce
objectsWin odds summary for hce
objects
## S3 method for class 'hce' summaryWO(x, ...)
## S3 method for class 'hce' summaryWO(x, ...)
x |
an |
... |
additional parameters. |
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.
calcWO()
, summaryWO()
, summaryWO.data.frame()
methods.
dat <- as_hce(HCE4) summaryWO(dat, ref = "P")
dat <- as_hce(HCE4) summaryWO(dat, ref = "P")