{'fraction_non_alphanumeric': 0.03462244144208545, 'fraction_numerical': 0.01112779088331308, 'mean_word_length': 4.56604774535809, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Design of Trials with Composite Endpoints with the R Package CompAREdesign

Composite endpoints are widely used as primary endpoints in clinical trials. Designing trials with time-to-event endpoints can be particularly challenging because the proportional hazard assumption usually does not hold when using a composite endpoint, even when the premise remains true for their components. Consequently, the conventional formulae for sample size calculation do not longer apply. We present the R package CompAREdesign by means of which the key elements of trial designs, such as the sample size and effect sizes, can be computed based on the information on the composite endpoint components. CompAREdesign provides the functions to assess the sensitivity and robustness of design calculations to variations in initial values and assumptions. Furthermore, we describe other features of the package, such as functions for the design of trials with binary composite endpoints, and functions to simulate trials with composite endpoints under a wide range of scenarios.


Introduction
Composite endpoints are defined as the occurrence of any of the set of events of interest in trials with binary endpoints and as the time from randomization to the first observed event among all events of interest in time-to-event trials. Composite endpoints are often chosen as primary efficacy endpoints to answer the main research question in confirmatory clinical trials. For instance, progression-free survival, the composite of occurrence of death and clinical progression, is one of the most common primary endpoint in oncology clinical trials. Major adverse cardiovascular events (MACE), the composite of cardiovascular death, myocardial infarction, stroke and target vessel revascularization, is frequently used in cardiovascular research [1,2,3,4].
There is a large and established literature on designing and analyzing trials with multiple time-to-event endpoints in which case the focus is on the time from randomization to the first observed event among all components. The reader may refer to [5] for methods for planning and evaluating clinical trials with primary composite endpoints, [6] for sample size determination in trials with with multiple endpoints, and [7] for a revision of methods for the analysis of trials with multiple endpoints in small populations. In the particular context of composite endpoints, analyses that weight the composite's components contribution [8,9], matched-paired approaches such as the win-ratio method [10,11,12] have been proposed as well as methods for sample size calculation [13,1,14].
To our knowledge, only a few R packages in the R CRAN repository are exclusively focused on composite endpoints. Furthermore, those are more concentrated on the analysis rather than on the design. The WR and WWR packages address the analysis of studies with prioritized composite endpoints through the Win Ratio measure. The wcep package provides the Kaplan-Meier survival curves in the presence of weighted composite endpoints. The Wcompo implements inferential and graphic procedures for the semi-parametric proportional means regression of weighted composite endpoint of recurrent events and death. The idem package implements a procedure for comparing treatments based on the composite endpoint of a functional (unobserved) outcome and a time-to-event endpoint. On the other hand, there are a variety of packages for designing trials with multiple endpoints, but surprisingly do not consider composite endpoints. The Mediana library considers different multivariate distributions to calculate by simulation the sample size needed to analyze multiple events. The gMCP and gMCPLite provide functions for the analysis of trials with multiple hypotheses using graph-based procedures. The ADCT package performs power and sample size calculations for adaptive designs with co-primary endpoints. Finally, the cats allows to simulate platform trials with co-primary binary endpoints.
In this paper, we present the R package CompAREdesign ( [15]) which addresses different aspects of the design of randomized controlled trials (RCT) with composite endpoints. This package was conceived as a natural way to provide the functions implemented on the web-app CompARE (https://www.grbio.eu/ compareCover/), developed with the shiny R package by the same authors as the library presented in this work. The main features of the CompAREdesign package are: 1) to anticipate the relative efficiency of the design using a composite endpoint with respect to the design based on a single outcome as primary endpoint; 2) to quantify the expected treatment effect of the intervention on the composite endpoint; and 3) to compute the sample size to detect that treatment effect. Although this paper mainly refers to trials with time-to-event endpoints and presents the R functions for that, the corresponding functions for trials with binary endpoints are implemented as well in CompAREdesign We end this article with an overview of the functions of CompAREdesign for binary composite endpoints and a brief explanation of some functions to generate data for composite endpoints based on the information of the components.

Methodological background
Consider a RCT comparing an experimental treatment (i = 1) and a control arm (i = 0). Suppose that n (i) patients are allocated to arm i and followed for a prespecified time τ . Consider a composite endpoint (ε * ) consisting of two single events, ε 1 and ε 2 , and assume that ε 1 is more relevant for the trial purposes. Denote by T 1 and T 2 the times to ε 1 and ε 2 , respectively, and T * the time to the composite endpoint ε * , that is, T * = min{T 1 , T 2 } is the time to the first occurrence of any of the events ε 1 and ε 2 . Furthermore, when required, we denote by T (i) k the time to ε k in the arm i.

Distribution functions for the composite endpoint
In order to derive the law for the composite endpoint, we have to distinguish between whether death (or any other fatal event) is included in ε 1 and ε 2 . We will refer to case 1: when none of the events includes a fatal event that precludes from observing the other event (e.g., death); cases 2 and 3: when, respectively, either ε 2 or ε 1 includes a fatal event; and case 4: when both events include a fatal event. This distinction matters since, depending on the case, the cause-specific hazard rate function for T 1 and T 2 has to be used instead of the corresponding marginal hazard rate functions. For simplicity, in this paper, we will focus on case 3 (ε 1 including a fatal event). The reader is referred to [16] for a thorough explanation of all the cases.
To derive the law of T (i) * the joint distribution between T (i) 1 and T (i) 2 (i = 0, 1) has to be characterized. This is accomplished by means of a copula binding the marginal distributions of T (i) 1 and T (i) 2 through an association parameter that can been chosen between Spearman's rank correlation coefficient ρ and Kendall's τ . We assume that ρ and τ are the same in both groups. The marginal laws for T (i) k (i = 0, 1; k = 1, 2) are chosen from the Weibull family of distributions. They depend on a shape parameter which allows increasing, constant and decreasing hazard functions and a scale parameter that is specified in terms of the probabilities p in the control group. Finally, we assume that treatment groups have proportional (cause-specific) hazard rates for each component and denote by HR 1 and HR 2 the respective (cause-specific) hazard ratios which have to be anticipated. Without loss of generality, we assume that both events E 1 and E 2 are harmful and that the new treatment is expected to reduce the risk of both events, that is, HR k < 1, k = 1, 2. See [13] for further details.

Effect size
In trials with survival endpoints, the efficacy of a treatment is routinely quantified by means of the hazard ratio based on the proportional hazards model. However, this proportionality is not usually met for time-to-event composite endpoints and different summaries, such as the geometric average hazard ratio, the average hazard ratio, the median ratio or the restricted mean survival time ratio could be then a more convenient alternative [17,18]. In what follows, we describe them.
The geometric average hazard ratio, gAHR, is defined as the exponentiated mean of the logarithm of the hazard ratio, that is, gAHR = exp {E(log HR * (T))} where the expectation is taken with respect to a given event-time distribution, which in this case is the average distribution of T (0) * and T (1) * . For a given maximum follow-up time τ , the geometric average hazard ratio up to τ is defined as where f       (1) * (τ ))/2 is the average probability of experiencing the event ε * over both groups by time τ . In contrast to HR * (t) which is expected to change over time, gAHR(τ ) is independent of time and keeps its interpretability under non-proportional hazards. Furthermore, the geometric average hazard ratio and the all-cause hazard ratios take identical values under proportionality of the all-cause hazard rates. Last, gAHR(τ ) is the natural effect measure when using the logrank test to compare the hazard rates of two groups and should be used instead of the standard hazard ratio [19].
The average hazard ratio, AHR, introduced in [20], provides a summary statistic of the effect size that has an interpretation in the absence of proportionality among the hazard rates. The average hazard ratio up to time τ is defined is the overall hazard function among the two groups. The average hazard ratio up to time τ can be interpreted as an average of the hazard ratios at all death times, also under non-proportional hazards. Previous work based on simulations ( [13]) shows that the values of AHR and gAHR are very close, which entails that gAHR could be interpreted as a measure of proportional hazards just in the same way as AHR. In addition, the gAHR has the advantage of a direct relationship with the sample size calculation (as explained below).
The median ratio, mR * , corresponds to the ratio of the median times to ε * over both arms. Therefore, if m The median ratio is another appropriate alternative to the gAHR(τ ) and the AHR(τ ), which coincides with those in case the event rate is constant over time. Furthermore, the mR * gives a measure of the time-to-event gain in one group relative to another, giving it greater interpretability than risk-based measures (e.g., gAHR(τ ) or AHR(τ )) ( [21]). The restricted mean survival time ratio, RM ST R * (τ ), corresponds to the ratio of the restricted mean survival times to ε * over both groups up to time τ . The restricted mean survival time (RMST) of ε * in arm i up to time τ ( [22]) is the area under the survival curve up to τ , given by RM ST The restricted mean survival time ratio is then defined as follows: Although the difference in restricted means as an alternative measure of treatment effect is often used, we advocate here for the ratio for analogy with all the other effect size measures.

Sample size
Sample size calculation to detect a hypothesized difference between treatments is a key point in the design of a RCT. In survival trials with composite endpoints, the sample size can be based on the geometric average hazard ratio, gAHR, in case the proportional hazards assumption can be assumed to hold for the components, but not for the composite endpoint. The required number of events, sample size and power formulae are based on the non-centrality parameter of the logrank test under the alternative hypothesis which is a function of the gAHR.
Suppose we aim at testing the superiority of the new treatment (i = 1) against the control arm and that the logrank test statistic Z * is used for the null hypothesis of no effect on T * . If using the geometric average hazard ratio as the treatment effect measure, the null hypothesis of no effect on T * will be rejected for a one-sided α significance level whenever Z * < −z α , where z α is the α-quantile of the standard normal distribution. Note here that negative values of Z * favor the new treatment. Since Z * follows a normal distribution with mean µ * (τ ) and variance 1, the power 1 − β is such that 1 − β = Prob{Z * < −z α }. Hence, the total sample size for both groups for a balanced design (equal sample size in both groups) is: and the expected number of composite endpoint events e * = n · p (a) * (τ ) is given by To obtain expression (6) from expression (5) (or vice versa), the same follow-up period (τ ) had to be assumed for all study participants, regardless of how recruitment was carried out. Observe that, formula (6) corresponds to Schoenfeld's formula [23] for the required number of events if the hazard ratio is substituted by the geometric average hazard ratio. The main difference lies, however, in that while in Schoenfeld's formula you are assuming that the hazard rates are proportional when dealing with a composite endpoint the all-cause hazard rates do not have to be proportional.

Endpoint selection
When designing a trial with multiple endpoints, one might wonder which endpoint is better from a point of view of the statistical efficiency of the trial. Specially when composite endpoints are considered, adding more endpoints to the primary composite endpoint can dilute the effect of some of the most relevant endpoints. The Asymptotic Relative Efficiency (ARE) was proposed as a measure to evaluate the statistical efficiency gain of the composite endpoint versus one of its components. Specifically, the ARE for survival composite endpoints compares the efficiency of using the logrank test Z * based on the composite endpoint ε * versus the logrank test Z based on the relevant endpoint ε 1 . In what follows, we sketch the main idea of the method, but for further details, we refer to the article [16].
Given that both tests Z and Z * are asymptotically N(0,1) under H 0 : no effect on T 1 and H * 0 : no effect on T * and are asymptotically normal with variance 1 under a sequence of contiguous alternatives to the null hypothesis, the ARE is given by the square of the ratio of their non-centrality parameters µ and µ * , respectively, and admits the following expression where f    1) * (t) correspond to the hazard functions of T * under the control and experimental groups, respectively and HR 1 stands for the constant hazard ratio for endpoint T 1 . The ARE measure can be roughly interpreted as the ratio of the required sample sizes using ε 1 versus ε * to attain the same power for a given significance level. This measure therefore yields to the following criterion: whenever ARE >1, choose ε * as primary endpoint to guide the study; otherwise, use ε 1 .

Overview of CompAREdesign R package
In this section, we provide a general description of the package. We start explaining the installation and dependencies, and continue describing the functions and arguments for time-to-event functions. We postpone to section 5 the description of the functions for composite binary endpoints. CompAREdesign provides either numerical and graphical outputs for all methods described in the methodological section for the design of trials with composite endpoints. Further details on the usage of the functions can be found in the corresponding R package manual.

Installation and dependencies
The CompAREdesign package is available on CRAN at: https://cran.r-project.org/web/packages/CompAREdesign/index.html. and can be installed and loaded by running the R commands: The package depends on the copula package [24], which implements joint distributions binned by copulas; the packages ggplot2 [25] and ggpubr [26], needed for the graphical tools; and the packages rootSolve [27] and numDeriv [28], required to numerically compute some integrals needed in the developments.

Explanation of functions
CompAREdesign consists of thirteen functions. Six of them refer to time to event composite endpoints, and seven refer to the binary composite endpoint. The functions whose name ends with tte are those for the time-to-event case, cbe for the binary case, and two extra functions named lower corr and upper corr concern the bounds of the correlation between binary endpoints. All these functions are implemented in the shiny web-tool CompARE allowing an interactive way of using them. Table 1 gives a high-level description of these functions and relates them to the capabilities of the app.
In what follows we describe the time-to-event functions included in the package: • surv tte draws, in the same graphical window, for each treatment arm, the survival functions of each component as well as of the composite endpoint.
• effectsize tte provides the anticipated treatment effect for the composite endpoint in terms of the following measures: the geometric average hazard ratio gAHR * (τ ), the average hazard ratio AHR * (τ ), the median ratio mR * , and the restricted mean survival time ratio RM ST R * (τ ). In addition, for each treatment arm, this function returns: the RM ST (i) * , the m (i) * and the probability of observing the event in each group, p (i) * (i = 0, 1).
• samplesize tte returns the required sample size for the three following designs which depend on which primary endpoint is used: 1) sample size for a design based on the relevant component of the composite endpoint ε 1 ; 2) sample size for a design based on the second component ε 2 ; and 3) sample size for a design based on the composite endpoint ε * .
• ARE tte provides the Asymptotic Relatively Efficiency (ARE) value for comparing the efficiency of using a design with the composite endpoint as primary endpoint versus a design with the first component as the primary endpoint. An ARE value larger than one indicates a benefit, in terms of power efficiency, when using a composite endpoint and otherwise, the relevant endpoint is the preferred one.
• plot tte is a summary function that draws the following four plots: 1) the survival function of the composite endpoint for each treatment arm; 2) the expected hazard ratio over the follow-up time; 3) the ARE value with respect to the correlation between components; and 4) the required sample size as function of the correlation. Simulates binary data for the (Not implemented) composite and its components.
• simula tte simulates two-arm trials with composite endpoints. This functions is further explained in Section 6.
In the next section, we describe the arguments needed for these functions, and we illustrate and further explain the functions in Section 4.

Explanation of the parameters
Most functions in CompAREdesign package use common arguments. All arguments in CompAREdesign are briefly described in Table 2. Note that in some cases, the same arguments are used for time-to-event and binary functions. Probability of occurrence of ε 1 and ε 2 in the control arm (Numeric) X X eff e1, eff e2 Anticipated effect for the composite component ε 1 and ε 2 (Numeric) X effm e1, effm e2, effm ce Effect measure used for the event ε 1 , ε 2 and ε * (Character) X HR e1, HR e2 Expected cause specific hazard ratio for the ε 1 and ε 2 (Numeric) X beta e1, beta e2 Shape parameter of a Weibull distribution for the ε 1 , ε 2 in the control arm (Numeric) X rho Pearson, Spearman or Kendall correlation between ε 1 and ε 2 (Numeric) X X rho type Type of correlation (Character) X case 1 to 4 depending on whether death is included in ε 1 or ε 2 or both or neither (Numeric) X copula Type of copula to build the joint distribution (Character) X Indicates if the plot should be stored (Logical) X sample size Desired sample size for each arm when simulating data (Integer) X p0 e1 and p0 e2 represent the probabilities of observing the event in the reference arm during the follow-up period. It must be kept in mind that, for a single participant, p0 e1 is the probability of observing the ε 1 even if ε 2 had previously observed and vice versa. Those probabilities could be easily obtained from the literature, for example, using the proportion of observed events at the end of the study in trials that the pertinent component is used as primary endpoint.
HR e1 and HR e2 are the anticipated treatment effects for the composite components ε 1 and ε 2 in terms of the cause-specific hazard ratios. They could also be found in previous published trial results with ε 1 or ε 2 as primary endpoints.
The arguments beta 1 (β 1 ) and beta 2 (β 2 ) are the shape parameter of the marginal Weibull distribution behind each component. They can be guessed taking into account that values below unity imply a decreasing risk of that event occurring over time and vice versa, while a β j = 1, j = 1, 2 indicates a constant risk. Our recommendation is: • If the risk of suffering the event decreases throughout the follow-up period (e.g., an infection after a surgical intervention), then assign a β j = 0.5 • If the risk of suffering the event remains constant during the follow-up period (e.g., death after a non-invasive intervention in mild patients), then assign a β j = 1 • If the risk of suffering the event increases during the follow-up period (e.g., contracting an infectious disease at the start of a pandemic), then assign a β j = 2 The ARE method is based on a copula binding the distribution of the times to ε 1 and ε 2 through a measure of association, for example, the Spearman's rank correlation coefficient (rho) between these times. As it can be hard to anticipate a measure of association, the package provides both the sample size and the ARE for different positive correlation values (we assume that the association between components cannot be negative). Time-to-event functions implement another association measure, the Kendall's τ , that could be used instead of the Spearman's ρ by means of the argument rho type. A note of caution is that Spearman's ρ cannot be obtained from the data in the presence of competing risk, i.e. when ε 1 and/or ε 2 is death.
The case parameter indicates in which of the two components that make up the composite event, a fatal event is present. This is important to address the scenario of competing risks: • If case = 1, then none of the events of interest includes a fatal event that precludes from observing other events (such as death) • If case = 2, then ε 2 is a fatal event • If case = 3, then ε 1 is a fatal event • If case = 4, then both components are fatal events. An example of this is cause-specific mortality, such as the composite includes deaths by different causes (e.g., death from heart disease, death from cancer, death from other causes, etc.) The copula argument indicates which type of copula is used to obtain the joint distribution. Currently, the Archimedean copulas of Frank (default), Gumbel and Clayton are implemented. The former provides the same weight to all the events along time, while the Gumbel and Clayton copulas provide more weight at the start and at the end of the follow up, respectively [29].
alpha and power are relevant parameters for the sample size calculation. alpha (α) represents the probability of Type I error, that is the probability of finding a statistically significant treatment effect when it really does not exist. The power (1 − β) is the desired probability of detecting a treatment effect when it really exists. The parameter ss formula gives the user two options to calculate the required number of events: the Schoenfeld's or the Freedman's formula (see [30]).
followup time (τ ) argument represents the length of the follow up (measured in any time unit). It facilitates the interpretation of some graphics since the range of the x-axis is fitted to this follow-up period. Moreover, time-dependent effect measures, such as the mR * or the RM ST * are calculated taking into account this value. By default, an unitary time is assumed (e.g., one year).
The purpose of the parameter subdivisions is to set in how many points some functions (e.g., HR * ) are evaluated to be plotted. The higher the value, the more accuracy at a higher computational cost.
Finally, plot res and plot store indicate if the plots returned by some functions should be displayed and stored (for further customization), respectively.

CompAREdesign for time-to-event endpoints
This section introduces the main features of the package via a lung cancer case study. This illustration exemplifies those aspects of the design of a RCT that can benefit of the capabilities of the implemented functions in this package.

Planning a lung cancer trial based on ZODIAC trial
We show a case study to design an RCT based on the results from the ZODIAC trial ( [31]), which compared the efficacy of vandetanib plus docetaxel versus placebo plus docetaxel as second-line treatment in patients with advanced non-small-cell lung cancer. The co-primary endpoints of this trial were overall survival (OS, ε 1 ) and progression free survival (PFS, ε * ), defined as the absence of death and disease progression (DP, ε 2 ). Let's assume that we want to conduct a new RCT to compare two treatments similar to those tested in the ZODIAC trial.
Some of the required values for the arguments of the functions are obtained from the published article of the trial. It reports: i) the cause-specific HRs for each component: 0.91 for OS (ε 1 ) and 0.77 for DP (ε 2 ); ii) the probabilities of observing deaths (taken into account those subsequent to the DP) or DP were 0.59 and 0.74, respectively. However, some assumptions have to be made because there is no other further information on the components. For example, we can expect that the risk of death remains constant (β 1 = 1) over time while DP has an increasing risk (β 1 = 2) to be occurred. Also, we could anticipate a moderate correlation (ρ = 0.5) between both components. The first step before using the package is to specify all the arguments on which we are going to base our RCT design:

General overview and characterization of the law of T *
The plot tte function is intended to be an all-in-one function that displays all relevant plots for decision making in an RCT. Figure 1 shows the main graphics to assess the behavior of the CE in the trial design.
> plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case, copula, rho, rho_type, followup_time, alpha, power, ss_formula) The two top plots in Figure 1 show the survival and hazard ratio functions of the composite endpoint over time. The survival curves (top-left) reveal that almost no censored data is expected in either of the two treatment arms due to the high proportion of expected events at the end of the study (0.59 and 0.74 for ε 1 and ε 2 , respectively). If one wants to obtain, in addition, the survival curves for each component, the function surv tte can be called for this purpose using the same input parameters that plot tte. The follow-up period can be specified to plot the survival curves at the relevant scale for a better interpretation. For instance, we can indicate that we plan to follow the participants during two years by the followup time argument: > surv_tte (p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case, copula, rho, rho_type, plot_res = TRUE, plot_store = FALSE, followup_time = 2) On the top-right of Figure 1, the hazard ratio of the composite endpoint shows that does not remain constant over time. Indeed, HR * (t) decreases from HR * (0) ≈ 0.90 to HR * (0.5) ≈ 0.77 in the first half of the study. From here on, the treatment effect, given by the hazard ratio, seems to remain constant for the rest of the follow up. This plot can be very useful when planning a trial to visually assess whether the proportional hazards assumption is satisfied in a specific setting.
As the association between the composite components, in the planning phase of a trial, is commonly unknown, our package provides the ARE and the sample size as a function of the selected association measure (see Figure 1 with Spearman's rank correlation ρ). The bottom-left plot allows the user to assess the possible impact that the correlation has on the ARE value.
Note that, for this particular example, the design that includes the composite endpoint as the primary endpoint is clearly more efficient than the one that considers death (ε 1 ) as the main outcome of interest. This holds regardless of the correlation between components, as the ARE takes values around 10 for all possible values of Spearman's correlation. Therefore, in this situation, the value of ρ should not guide our decision.
On the other hand, on the bottom-right plot, we can observe the sample size of the composite endpoint in terms of the correlation ρ. In this particular case, the sample size takes values between 650 and 700, not varying greatly on basis of the correlation. A conservative choice could be to use the largest sample size (700 in this case) in this trial.

Effect size calculation by means of effectsize tte
As mentioned in the methodological section, the common effect measure in survival trials is the hazard ratio which relies on the proportional hazards assumption. Other effect measures have been proposed instead, which might be useful when the hazard ratio deviates from the proportional hazards assumption. The function effectsize tte allows to anticipate the expected treatment effect for the composite endpoint based on the information of the components. The function returns the treatment effect is given using different measures, as well as a plot of the HR * (t) over time.
To compute the anticipated effect for the hypothetical trial based on the ZODIAC trial, we can use then: > effectsize_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case, copula, rho, rho_type, followup_time = 4, subdivisions = 1000, plot_res = FALSE, plot_store = FALSE) Effect measure Effect value | Group measure Reference Treated The output gives two summary measures of the HR * (t) over time: the geometric average hazard ratio gAHR * (τ ) (see (1)) and the average hazard ratio AHR * (τ ) (see (2)), which in this case provide quite similar values (both, close to 0.80, as one can deduce from the second plot of Figure 1). When HR(t) is not constant, the gAHR * (τ ) and the AHR * (τ ) should be cautiously interpreted since they do not reflect an overall effect. The function also reports other effect measures: the restricted mean survival time up to the end of follow-up (τ ) RM ST R * (τ ) (see (4)), and the median ratio mR * (τ )(see (3)). In this case, these measures take values about 1.13, indicating that the intervention provides a 13% gain in the time to event of the ε * . Finally, some measures for each treatment arm are provided, such as the RM ST , the median, and the probability of observing the events (ε 1 , ε 2 , or ε * ). The output also includes the plot of the HR * (t) (not shown here).
The medians for the composite endpoint in each arm can always be calculated using the marginal Weibull distributions. However, the results should be taken cautiously when some of these medians go beyond the follow-up time (τ ).

Sample size calculation by means of samplesize tte
We have implemented the sample size calculation for survival trials with composite endpoints in the function samplesize tte. This function allows the user to compute the required sample size to have 1 − β power to detect the treatment effect at significance level α. The function samplesize tte returns the total sample size (assuming equal-sized arms) that would be required if the trial is designed to detect an effect on the composite endpoint. For comparison, the needed sample sizes for trials using endpoint 1 (ε 1 ) or endpoint 2 (ε 1 ) as primary endpoint instead, are also provided.
We show the usage of the function using the ZODIAC trial as an example. We use the values displayed in Section 4.1 as input arguments, and additionally we set the power and significance level to be equal to 0.80 and 0.05, respectively. The usage of samplesize tte is then as follows: > samplesize_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case, copula, rho, rho_type, alpha, power, ss_formula)

Endpoint
Total sample size -Endpoint 1 6162 Endpoint 2 620 Composite endpoint 636 Note that the design that requires a smaller sample size is the one that considers DP (ε 2 ) as the primary endpoint. This is due to the fact that the effect for endpoint 2 is larger than the one for endpoint 1 and therefore it requires less participants to have 0.80 probability to detect the effect. Furthermore, the number of expected observed events is higher for the DP (0.74 versus 0.59), which also makes the sample size for the design that only considers endpoint 1 (ε 1 , OS) to be larger than the one using endpoint 2. The consideration of the composite endpoint as primary endpoint leads to a reduction of the sample size up to almost a 90% in comparison of using the design that considers ε 1 as the only relevant event.
As it is well known the sample size calculation is in general sensitive to modification of the parameters this relies on. The choice of certain input arguments in the samplesize tte function might significantly modify the obtained sample size. CompAREdesign can be useful to evaluate the robustness or sensitivity of the sample size calculations according to the assumptions and parameter inputs. As an example, Figure 2 shows the sample size calculation according to the Weibull shape parameter (β 2 ) and the treatment effect (HR 2 ) for the second component. If there is low or no association between both components, the choice of β 2 barely impacts on the total sample size, which ranges between 670 and 700. The discrepancies are more extensive as the correlation increases. For example, for Spearman's correlation equal to 0.75, the total size could range from 600 if the DP risk increases over time to 750 if the hazard decreases. Obviously, modifying the treatment effect is more critical; the right graph shows that considering an HR of 0.85 instead of 0.65 can increase the total sample size from around 300 to 1,600. These plots have been obtained by setting the parameter plot store = TRUE and later, manipulating the returned ggplot class object obtained through the ggplot2 package [25].

Endpoint selection by means of ARE tte
The ARE gives a criterion to decide whether to use a composite endpoint (ε * ) or to use its more relevant component (ε 1 ) as the primary endpoint of the trial. Going back to the toy example based on ZODIAC trial, the decision translates into whether to consider death (overall survival, OS) or a composite endpoint (i.e., progression-free survival) as the primary endpoint. The ARE method is implemented in the ARE tte function. To compare the two previous mentioned designs, the user can use the following code: > ARE tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case, copula, rho, rho_type) [1] 9.303 Note that a value of ARE = 9.3 > 1 implies that is more efficient considering the composite endpoint (PFS) than the OS as primary endpoint (see the Endpoint Selection subsection). This high efficiency might result in smaller required sample size if using PFS instead of OS to attain the same power for a given significance level. In this particular case, a larger proportion of disease progression (DP) events (0.74 versus 0.59) together with a more marked beneficial effect on DS (0.77 versus 0.91) has lead to an ARE value larger than 1.

CompAREdesign for binary composite endpoints
CompAREdesign also includes functions for the design of trials with composite binary endpoints. In this case, composite endpoints are defined as the occurrence of any of the components. Analogously to the time-to-event case, the distribution function for composite binary endpoints relies on the marginal event rates and effect sizes of the composite components, and the correlation between them (see [32]).As it is well known, when assessing the efficacy of an intervention against a control treatment based on a binary endpoint we could use the difference in proportions (or risk difference), the relative risk (or risk ratio), and the odds ratio. The same applies then for the composite binary endpoints. In CompAREdesign, we implemented the effect size and sample size calculation for trials with composite binary endpoints based on the anticipated values of the composite components and their correlation according to risk difference, relative risk, and odds ratio effect measures. An overview of the functions implemented for binary endpoints can be found in Table 1. In what follows, we briefly described the two main functions, effect cbe and samplesize cbe, for the effect size and sample size computation, respectively.
The function effect cbe can be used to compute the effect size of the composite binary endpoint by means of: > effectsize_cbe(p0_e1, p0_e2, eff_e1, effm_e1, eff_e2, effm_e2, effm_ce ="diff", rho) where p0 e1 and p0 e2 denote the probabilities of ε 1 and ε 2 in the control group, respectively; eff e1 and eff e2 are the anticipated effects for the events ε 1 and ε 2 , respectively; rho is Pearson's correlation between ε 1 and ε 2 . The effects for ε 1 and ε 2 can be anticipated in eff e1 and eff e2 by means of the difference of proportions, risk ratio, and odds ratio. The arguments effm e1 and effm e2 can be used for specifying the effect measure preferred. Also, using the argument effm ce, we specify the effect measure we are interested in for the composite endpoint.
Other functions included in the R package are prob cbe to calculate the probability of the composite endpoint, and ARE cbe to compute the ARE method for binary endpoint, as proposed in [33].

Simulation feature
As an additional feature, the package CompAREdesign includes functions to generate data from both the components and the composite endpoint. Using the same input parameters previously seen, the simula tte function generates samples size times for each treatment arm and the corresponding censoring indicator variables. We assume non-informative administrative right censoring data, thus, all events not occurring before or at time τ (followup time) are censored at τ .
Simulations are in general a key tool in the design of RCTs to test the robustness of methods with respect of deviations of the assumptions, sensitivity of sample size calculations regarding the parameter values' assumptions, and compare several methods (e.g., a trialist might wish to compare a non-parametric, a semi-parametric and a parametric method under certain conditions) and/or the efficiency of different trial designs.
The function returns a data frame with seven columns. The first 6 represent the times (to event or to censoring) and the censoring indicator (status) for ε 1 , ε 2 , and ε * , respectively. The last column represents the treatment arm. The following example shows simulated data with similar characteristics as those from the ZODIAC trial.

Discussion
Although there are several R packages for the analysis of trials with composite endpoints, to our knowledge, the CompAREdesign package is the first specifically implemented to address the design of RCTs with composite endpoints. The design and analysis of trials with composite endpoints might be specially challenging as they rely on several assumptions of the composite components. For instance, it depends on the functional form of the survival distribution (e.g., the shape parameters of the marginal Weibull distributions) as well as on parameters' values such as the expected effect sizes, that is to say, the hazard ratios for each composite component. Furthermore, the joint distribution between both component endpoints (including the marginal law and the association between both endpoints) needs to be anticipated. Since anticipation of this long list of arguments might be arduous, CompAREdesign can be a great help in the design of the trial. The CompAREdesign package (and its corresponding shiny app) may be of particular interest in cases where the precise value of these parameters is unknown. The sensitivity and robustness of results due to variations in initial values and assumptions can be assessed by means of this package. For instance, by means of the function samplesize tte, one could compare several scenarios depending on the shape parameters of the Weibull distribution (β j ) or the expected effect size in either component (HR j ) as seen in Figure 2. In addition, CompAREdesign includes several association measures and copula functions for addressing different dependency structures between the time to each of the composite components. Although the choice of the copula is not straightforward, preliminary simulation results [34] show a small impact of the choice of the copula on the corresponding percentiles for the composite endpoint, and consequently on the decisions one might have to take.
CompAREdesign has implemented Spearman's correlation and Kendall's tau as association measures. The former is much more frequent and is the one we recommend for time-to-event studies.
To compute the sample size the user can choose between Schoenfeld's and Freedman's formulas. The choice should take into account that their appropriateness depends on the deviation from the proportional hazards assumption: the greater the deviation (less constant hazard ratio over time), the better to use Freedman's instead of Schoenfeld's formula [30].
This package is restricted to two-arm RCTs. As future work, we consider expanding the R package to trials with more than two arms. In particular, we plan to extend the package to also include multi-arm trials where the efficacy of K treatments is tested against a shared control [35]. Also, the package could be expanded to include some adaptive features, such as sample size reassessment [36] and treatment selection [37]. Finally, the package could be enhanced to include trials with composite endpoints with more than two components.