Title: | Win Ratio for Prioritized Outcomes and 95% Confidence Interval |
---|---|
Description: | Calculate the win ratio for prioritized outcomes and the 95% confidence interval based on Bebu and Lachin (2016) <doi:10.1093/biostatistics/kxv032>. Three type of outcomes can be analyzed: survival "failure-time" events, repeated survival "failure-time" events and continuous or ordinal "non-failure time" events that are captured at specific time-points in the study. |
Authors: | Kevin Duarte, Joao Pedro Ferreira |
Maintainer: | Kevin Duarte <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2024-12-08 07:16:02 UTC |
Source: | CRAN |
Calculate the win ratio for prioritized outcomes and the 95% confidence interval based on Bebu and Lachin (2016). Three type of outcomes can be analyzed: survival "failure-time" events, repeated survival "failure-time" events and continuous or ordinal "non-failure time" events that are captured at specific time-points in the study.
Kevin Duarte, Joao Pedro Ferreira
Maintainer: Kevin Duarte <[email protected]>
Pocock S.J., Ariti C.A., Collier T.J., Wang D. The win ratio: a new approach to the analysis of composite endpoints in clinical trials based on clinical priorities. Eur Heart Journal. 2012; 33:176-182. DOI: 10.1093/eurheartj/ehr352.
Bebu I. and Lachin J.M. Large sample inference for a win ratio analysis of a composite outcome based on prioritized components. Biostatistics. 2016; 17:178-187. DOI: 10.1093/biostatistics/kxv032.
is.binary is used to test if a vector is of binary type, i.e. if a vector contains only 0 and/or 1 values.
is.binary(x)
is.binary(x)
x |
a vector to be tested. |
is.binary returns TRUE or FALSE depending on whether a vector is of binary type or not.
x1 <- runif(100, 0, 1) x2 <- ifelse(x1 < 0.5, 1, 0) is.binary(x1) is.binary(x2)
x1 <- runif(100, 0, 1) x2 <- ifelse(x1 < 0.5, 1, 0) is.binary(x1) is.binary(x2)
This function is used for summarizing the results for class 'WinRatio'
objects.
## S3 method for class 'WinRatio' summary(object, ..., digits = 2)
## S3 method for class 'WinRatio' summary(object, ..., digits = 2)
object |
an object of class |
... |
additional arguments affecting the summary produced. |
digits |
the number of significant digits to use when printing win ratio and 95% confidence interval. |
## For examples see example(winratio)
## For examples see example(winratio)
Calculate the win ratio for prioritized outcomes and the 95% confidence interval based on Bebu and Lachin (2016). Three type of outcomes can be analyzed: survival "failure-time" events, repeated survival "failure-time" events and continuous or ordinal "non-failure time" events that are captured at specific time-points in the study.
winratio(id, trt, active = NULL, outcomes, fu, data, keep.matrix = FALSE)
winratio(id, trt, active = NULL, outcomes, fu, data, keep.matrix = FALSE)
id |
a string indicating the patient ID variable. The patient ID variable must not contain missing values or duplicates. |
trt |
a string indicating the treatment variable. The variable can be of any type (binary, numeric, character, factor) and must imperatively have 2 unique values/levels. |
active |
a numeric or string value used to define the active treatment group for the calculation of the win ratio. If
|
outcomes |
a list used to define all outcomes in order of priority. The first element to be defined must be the outcome considered as being of greater clinical importance, usually this outcome is a fatal event. Each element must be a character vector of length 3 or a character list of length 3 depending on the type of outcome (survival event, repeated survival event, continuous or ordinal event):
|
fu |
a string indicating the name of the follow-up time variable. |
data |
a data frame containing all the variables listed in the |
keep.matrix |
a logical value indicating if the 'win-loss' matrix is kept. Default value is |
Let n1
the number of patients in the active group and n0
the number of patients in the other group.
The 'win-loss' matrix is a matrix M
of dimension n1 x n0
with its element M[i,j]
is defined as:
M[i,j] = 1
if i
wins against j
on 1st outcome,
M[i,j] = -1
if i
loses against j
on 1st outcome,
M[i,j] = k
if i
wins on outcome k
after ties with j
on outcomes 1
to (k-1)
,
M[i,j] = -k
if i
loses on outcome k
after ties with j
on outcomes 1
to (k-1)
,
M[i,j] = 0
if i
and j
ties on all outcomes.
call |
a list with all arguments entered |
group1 |
the value/level of the active group (group 1). |
group0 |
the value/level of the other group (group 0). |
n1 |
the number of subjects in group 1. |
n0 |
the number of subjects in group 0. |
n |
the total number of subjects. |
wins |
a vector of numbers of 'winners' for each outcome. |
loss |
a vector of numbers of 'losers' for each outcome. |
total.wins |
the total number of 'winners'. |
total.loss |
the total number of 'losers'. |
total.ties |
the total number of ties. |
wr |
the win ratio. |
v |
the estimated variance of win ratio. |
z |
the value of the test statistic. |
p.value |
the p-value of the test. |
wr.lower |
the lower end of the 95% confidence interval. |
wr.upper |
the upper end of the 95% confidence interval. |
wr.matrix |
the 'win-loss' matrix (only if |
# Load survival package to use the dataset 'bladder1' library(survival) # Creation of dataset 'df' with 3 outcomes: # Outcome 1: death (survival event) # Outcome 2: cancer recurrence (repeated survival event) # Outcome 3: size of largest initial tumour (continuous event) data1 <- bladder1 %>% mutate(trt = if_else(treatment == "placebo", "Placebo", "Treatment")) %>% group_by(id) %>% mutate(death = if_else(max(status) %in% c(2, 3), 1, 0), t2death = max(stop)) %>% ungroup() %>% select(id, trt, death, t2death, number, size) %>% unique() data2 <- bladder1 %>% filter(status == 1) %>% select(id, t2recurr = stop) %>% mutate(recurr = 1) %>% arrange(id, t2recurr) %>% group_by(id) %>% mutate(nrecurr = row_number()) %>% ungroup() %>% full_join((data1 %>% select(id)), by = "id") %>% complete(id, nrecurr) %>% filter(!is.na(nrecurr)) %>% full_join((data1 %>% select(id, t2death)), by = "id") %>% mutate( recurr = replace(recurr, is.na(recurr), 0), t2recurr = if_else(is.na(t2recurr), t2death, t2recurr) ) %>% select(id, nrecurr, recurr, t2recurr) data3 <- data2 %>% pivot_wider(id_cols = "id", names_from = nrecurr, values_from = recurr, names_prefix = "recurr") data4 <- data2 %>% pivot_wider(id_cols = "id", names_from = nrecurr, values_from = t2recurr, names_prefix = "t2recurr") data5 <- full_join(data3, data4, by = "id") df <- full_join(data1, data5, by = "id") # Calculate the win ratio wr <- winratio(id = "id", trt = "trt", active = "Treatment", outcomes = list(outc1 = c("death", "s", "t2death"), outc2 = list(paste0("recurr", 1:9), "r", paste0("t2recurr", 1:9)), outc3 = c("size", "c", ">")), fu = "t2death", data = df) summary(wr)
# Load survival package to use the dataset 'bladder1' library(survival) # Creation of dataset 'df' with 3 outcomes: # Outcome 1: death (survival event) # Outcome 2: cancer recurrence (repeated survival event) # Outcome 3: size of largest initial tumour (continuous event) data1 <- bladder1 %>% mutate(trt = if_else(treatment == "placebo", "Placebo", "Treatment")) %>% group_by(id) %>% mutate(death = if_else(max(status) %in% c(2, 3), 1, 0), t2death = max(stop)) %>% ungroup() %>% select(id, trt, death, t2death, number, size) %>% unique() data2 <- bladder1 %>% filter(status == 1) %>% select(id, t2recurr = stop) %>% mutate(recurr = 1) %>% arrange(id, t2recurr) %>% group_by(id) %>% mutate(nrecurr = row_number()) %>% ungroup() %>% full_join((data1 %>% select(id)), by = "id") %>% complete(id, nrecurr) %>% filter(!is.na(nrecurr)) %>% full_join((data1 %>% select(id, t2death)), by = "id") %>% mutate( recurr = replace(recurr, is.na(recurr), 0), t2recurr = if_else(is.na(t2recurr), t2death, t2recurr) ) %>% select(id, nrecurr, recurr, t2recurr) data3 <- data2 %>% pivot_wider(id_cols = "id", names_from = nrecurr, values_from = recurr, names_prefix = "recurr") data4 <- data2 %>% pivot_wider(id_cols = "id", names_from = nrecurr, values_from = t2recurr, names_prefix = "t2recurr") data5 <- full_join(data3, data4, by = "id") df <- full_join(data1, data5, by = "id") # Calculate the win ratio wr <- winratio(id = "id", trt = "trt", active = "Treatment", outcomes = list(outc1 = c("death", "s", "t2death"), outc2 = list(paste0("recurr", 1:9), "r", paste0("t2recurr", 1:9)), outc3 = c("size", "c", ">")), fu = "t2death", data = df) summary(wr)