idem : An R Package for Inferences in Clinical Trials with Death and Missingness

In randomized controlled trials of seriously ill patients, death is common and often deﬁned as the primary endpoint. Increasingly, non-mortality outcomes such as functional outcomes are co-primary or secondary endpoints. Functional outcomes are not deﬁned for patients who die, referred to as “truncation due to death”, and among survivors, functional outcomes are often unobserved due to missed clinic visits or loss to follow-up. It is well known that if the functional outcomes “truncated due to death” or missing are handled inappropriately, treatment eﬀect estimation can be biased. In this paper, we describe the package idem that implements a procedure for comparing treatments that is based on a composite endpoint of mortality and the functional outcome among survivors. Among survivors, the procedure incorporates a missing data imputation procedure with a sensitivity analysis strategy. A web-based graphical user interface is provided in the idem package to facilitate users conducting the proposed analysis in an interactive and user-friendly manner. We demonstrate idem using data from a recent trial of sedation interruption among mechanically ventilated patients. missing outcomes for all survivors with functional outcomes to generate complete datasets. The following code shows how to use imImpAll to get M = 5 ( n.imp = 5 ) imputed complete datasets for sensitivity parameters ∆ T = − 0 . 2 , − 0 . 15 , . . . , 0 . 2; in this example, the residuals are not assumed to follow a Normal distribution ( normal = FALSE ). Please note that the choices of ∆ T are application-speciﬁc. Once again, we refer readers to Wang et al. (2017) for further instructions about choosing the sensitivity parameters.


Introduction
In randomized clinical trials (RCTs) that evaluate medical interventions for patients at high risk of death, functional outcomes scheduled to be measured at pre-specified post-randomization time points may be pre-empted due to death. Furthermore, patients alive at a pre-specified time may fail to be evaluated due to missed visits or withdrawal, yielding missing data. The distinction between the two types of unobserved functional outcomes is that data pre-empted due to death are considered to be undefined, whereas missing data exist but were not collected.
The so-called issue of "truncation due to death" is challenging even if there is no missing data among survivors. One method proposed for analyzing such data is to create a composite endpoint that combines mortality information among patients who die prior to the pre-specified time and the functional outcome among survivors (Diehr, Patrick, Spertus, Kiefe, Donell, and Fihn 2001;Lachin 1999;Chen, Gould, and Nessly 2005). In cases where patients can be ordered in a scientifically meaningful way, the simplicity of the composite outcome approach can be a useful way of globally assessing treatment effects which have causal interpretations. Wang, Scharfstein, Colantuoni, Girard, and Yan (2017) integrated the composite endpoint definition based on Lachin (1999) with a missing data imputation approach for intermittent missing data. They proposed a ranking scheme that ranks all the patients who died before the end of the study according to their time of death (earlier times are worse than later times) lower than patients who survived past the end of the study and survivors are then ranked according to their functional outcome. Inference for treatment effects compares the distribution of ranks across the treatment arms, accounting for the possibility of ties. Their method considered the complete case missing value constraints (Little 1993) as the benchmark assumption for intermittent missing data imputation and suggested a global sensitivity analysis framework to further assess the robustness of the findings through exponential tilting.
In this paper, we describe the R (R Core Team 2020) package idem (Wang, Leroux, Colantuoni, and Scharfstein 2020) that implements the proposed method in Wang et al. (2017) for making inferences in randomized clinical trials with both intermittent missing data and deaths. Notably, there are several extensions and modifications in idem from the original paper. First, Wang et al. (2017) proposed a Metropolis-Hastings algorithm for imputing missing data from their target distributions. In contrast, the package idem implements a rejection sampling approach where the candidate samples are drawn by rstan (Carpenter et al. 2017). Second, the package idem implements two alternative approaches to estimate and test for a treatment effect when data are "truncated due to death", the survivors only analysis and the survivor average causal effect (SACE) analysis (Chiba and VanderWeele 2011). Lastly, the package idem implements a web-based graphical user interface (GUI) where users can conduct the analysis in an interactive and user-friendly manner.
There are several software packages on the Comprehensive R Archive Network (CRAN) for analyzing death truncated data. The package JM (Rizopoulos 2010) applies shared parameter models for the joint modeling of longitudinal and survival data and the package JMbayes (Rizopoulos 2016) implements the shared parameter joint modeling approach under the Bayesian framework. The joint modeling approach implemented in the two packages introduces a shared set of latent random effects for modeling both the functional outcome and survival. In this approach, the model for the functional outcome allows trajectories of the functional outcome after death, which is not scientifically meaningful. The package sensitivityPStrat (Dupont and Shepherd 2014) applies the causal inference framework that addresses the problem in terms of counterfactuals and seeks to estimate the "principal stratum" causal effect (Frangakis and Rubin 2002;Hayden, Pauler, and Schoenfeld 2005;Chiba and VanderWeele 2011), e.g., the SACE. Although this approach is useful for understanding the mechanistic effect of treatment on clinical outcomes, it requires strong assumptions to identify whether a patient is a member of the "principal stratum" at the time of the treatment decision. To the best of our knowledge, there is no statistical software package that handles both the "truncation due to death" problem and intermittent missing data among survivors for RCTs, let alone one with a graphical user interface (GUI).
In this paper, we demonstrate idem by using data from the Awakening and Breathing Controlled (ABC) trial (Girard et al. 2008). The ABC trial randomized acute respiratory failure patients receiving mechanical ventilation 1:1 within each study site to management with a paired sedation plus ventilator weaning protocol involving daily interruption of sedatives through spontaneous awakening trials (SATs) and spontaneous breathing trials (SBTs) or sedation per usual care (UC) and SBTs (Girard et al. 2008). In a single-site substudy, cognitive, psychological and physical function was measured at 3-and 12-months post-randomization among n = 94 and n = 93 patients in the UC+SBT and SAT+SBT arms, respectively. We analyze a continuous measure of cognitive function where higher scores indicate better cognition.
The remainder of the paper is organized as follows. In Section 2, we briefly introduce the method proposed in Wang et al. (2017). We demonstrate the idem package in the R interactive mode using data from the ABC trial in Section 3. In Section 4, we describe the details of the idem GUI. In Section 5, we demonstrate the idem GUI using the ABC trial. Section 6 is devoted to discussion.

Method
In this section, we briefly introduce the composite endpoint approach implemented in Wang et al. (2017), the survivors only analysis, and the SACE analysis.

Notation
Consider a randomized study with K post-randomization assessment times l 1 , . . . , l K . Let Y k (k = 1, . . . , K) denote the functional outcome scheduled to be measured at time l k . We use Y k to denote (Y 1 , Y 2 , . . . , Y k ). Let X denote covariates measured at baseline, which may or may not include the functional outcome, Y 0 . Let T define the treatment assignment. Let L denote the survival time and A k = I(L > l k ), an indicator that the patient survived past assessment time l k . Let Z = g(Y 0 , . . . , Y K ) be the study's functional endpoint (e.g., Z = Y K − Y 0 ). Assume that higher values of Z denote better outcomes. In the absence of missing data, patients i and j are ranked as follows: • If A K,j = 0 and A K,i = 1, then patient i is ranked better than patient j.
• If A K,i = A K,j = 0, then patient i is ranked better than patient j if L i > L j and ranked the same if L i = L j .
More formally, let U be a function of (A K , W ) where W = L if A K = 0 and W = Z if A K = 1 with the ordering following the above ranking rules. Wang et al. (2017) argued that U is a composite endpoint in the sense that it is univariate and contains information on survival and functional status.
When A k = 1, define R k to be the indicator that Y k is observed. For patients alive at l K (i.e., A K = 1), let S = (R 1 , . . . , R K ) denote the missing data pattern; further, let Y (s) denote the observed and missing post-randomization functional outcomes. Note that Z is only observed when S = 1, where 1 is a K-dimensional vector of 1's, if g(·) is a non-constant function of all Y k 's.

Missing data imputation
To impute the missing functional outcomes, Y (s) mis , for patients alive at l K , the following class of untestable assumptions are posited: for all s = 1, where ∆ T is a treatment-specific sensitivity parameter.
In general, the class of assumptions (1) state that for subjects alive at l K , who are observed with functional measure Y (s) obs and baseline factors Y 0 and X, the distribution of their missing functional measures Y (s) mis , when ∆ T > 0 (< 0), are more heavily weighted toward higher (lower) values of Y (s) mis than those whose functional measures are fully observed and share the same functional measures as Y (s) obs and baseline factors Y 0 and X. Note that the benchmark assumption in the class (i.e., ∆ T = 0) is the complete case missing value (CCMV) restrictions (Little 1993).
To avoid non-sensical imputations that generate out-of-bound functional outcomes, Wang et al. (2017) suggested the following data transformation of Y k (k = 1, . . . , K): where (B L , B U ) denote the lower and upper bound of the functional outcome.
Note that there is a one-to-one mapping between the conditional distributions h(Y Let α k,t denote the least squares estimator of α k,t . The density function h k,t can be estimated by kernel density estimation based on the residuals or estimated with parametric assumptions (e.g., normality) if the sample size is small. Let h k,t denote the kernel density estimator of h k,t . We then estimate f ( For conducting sensitivity analysis to evaluate the robustness of the findings, Wang et al. (2017) suggest to choose the range of ∆ T such that the induced shift in the functional outcome, relative to the benchmark imputation, represents a change that is clinically important. We refer readers to Wang et al. (2017) for the detailed discussion about the interpretation and the choices of ∆ T .

Treatment effect quantification: Composite endpoint approach
Let i and j be random individuals randomized to treatment T = 0 and T = 1, respectively. Wang et al. (2017) proposed to quantify the treatment effect, denoted θ, as Values of θ > 0 and θ < 0 favor T = 1 and T = 0, respectively. Note that θ = 0 under the null hypothesis of no treatment effect.
In the absence of missing data, θ can be estimated by where n 0 and n 1 are the sample size of treatment arm T = 0 and T = 1, respectively.
In addition to estimating θ, Wang et al. (2017) suggested reporting quantiles (e.g., median) of the treatment-specific distribution of the composite endpoint U to further help characterize the treatment effect.

Treatment effect quantification: Alternative approaches
In the absence of missing data, several alternative approaches to quantify the effect of an intervention on the functional endpoint in the presence of mortality have also been proposed and utilized in the statistical and clinical literature.
The survivors only approach defines the treatment effect of the intervention on the functional endpoint as i.e., the difference in the mean functional endpoint comparing survivors receiving the intervention to survivors receiving the control. If survival is independent of the treatment assignment, then this treatment effect definition has a causal interpretation. However, in cases where the intervention affects mortality then this treatment effect definition does not define a causal effect and interpreting the estimated treatment effect can be misleading.
To remedy the potential bias in the survivors only approach, one may compare the functional endpoint within a special subset of patients, referred to as the principle stratum. This special subset of patients would survive to the end of the follow-up regardless of which intervention they receive. To define the survivor average causal effect (SACE), we define what would happen to patients (in terms of survival and functional endpoint) under both intervention and control. Let A K (t) be the indicator that the patient survives to time l K under treatment T = t, and if A K (t) = 1, define Z(t) as the potential functional endpoint observed (otherwise, Z(t) is not defined). Among patients who survive to time l K regardless of which treatment they receive (i.e., A K (0) = A K (1) = 1), the SACE is defined as Since the survival status and functional endpoint are only observed for the treatment that was received, additional assumptions are required to estimate SACE or obtain bounds. Under the monotonicity assumption A K (1) ≥ A K (0), that is, if a patient would survive to time l K under control, then the patient would survive to time l K under intervention, Chiba and VanderWeele (2011) showed that where ∆ SACE is the difference in the mean functional endpoint for surviving intervention arm patients and the mean functional endpoint if surviving control group patients had, contrary to fact, received the intervention. That is, Possible values for ∆ SACE should be elicited from expert opinions. In practice, an additional assumption is often made that the surviving control group patients are healthier than the surviving intervention group patients. Consequently, ∆ SACE is assumed to be non-positive if the healthier patients are expected to obtain a better functional outcome.

Inference
For individual i alive at l K with missing functional outcomes, M copies of the missing functional outcomes can be drawn from the density that is proportional to exp Such a constant exists in the settings we consider where the functional outcome is bounded by its biological boundaries. Rejection sampling candidates are then drawn from f (Y (s)

Installation and overall scheme
The idem package is available from CRAN at https://CRAN.R-project.org/package=idem. To install and load idem, type the following in R: The major steps of conducting an analysis using idem include data preparation, imputation model fitting, missing data imputation, and treatment effect estimation and hypothesis testing. Intermediate results are organized and passed between steps as idem-specific classes. Figure 1 presents the overall scheme and the major functions in idem.
Note that the results obtained might differ with platform and linear algebra library used. Hence, detailed information on the R session which produced the presented results is contained in the supplementary material.

Data format
The idem package requires the dataset to be formatted as follows: Each row represents a subject and includes the treatment assignment, baseline covariates, baseline outcome (if applicable), post-randomization functional outcomes and survival time. It is assumed that there is no censoring of the survival time prior to time l K . For patients who were censored after time l K , their survival time can be entered as any arbitrary number that is longer than l K .
The idem package provides the dataset abc from the ABC trial as an example dataset with a single baseline covariate, Age. Note that baseline cognition was not measured in the ABC trial.

Create analysis data object
As the first step, the function imData combines the original dataset and analysis specification parameters to create an object of class 'IDEMDATA' for the idem analysis. The parameters include variable names in the dataset, functional outcome specification, functional endpoint specification, duration of the study, etc. Details can be found in the help document of imData.
When there are mis-specifications in the parameters, errors and inconsistency messages will be given by imData. Otherwise, the return value is of class 'IDEMDATA' and contains the original dataset and the specification parameters.

Data visualization
Class 'IDEMDATA' resulting from imData has S3 methods summary and plot for data visualization. By default, summary produces a   Figure 4) can be generated by the S3 plot method using options "survivor", "missing" and "KM", respectively. Note that the heatmap plot presents an overview of the amount of missingness as well as the missingness patterns of the functional outcome data. For generating heatmaps, subjects are ordered along the y-axis either based on the amount of missing data (order.by = "amount") or their missingness patterns (order.by = "pattern") in order to provide a more straightforward overview.
R> plot(im.abc, opt = "survivor") R> plot(im.abc, opt = "missing", cols = c("blue", "gray"), + order.by = "pattern") R> plot(im.abc, opt = "KM") In addition, through the S3 summary method, the 'IDEMDATA' class returns the row indices that correspond to the subjects who were alive at the end of the study but had missing functional outcomes, i.e., the subjects that need missing data imputation.

Fit imputation models
For the missing data imputation, the function imFitModel needs to be called first to fit the imputation model(s) (2) among survivors with S = 1, i.e., the patients who were alive at the end of the study without missing functional outcomes. The return value of the imFitModel function has class 'IDEMFIT' and contains lm results for all the imputation models. The S3 plot of the 'IDEMFIT' class generates the goodness of fit diagnostic plots ( Figure 5). Since the normality assumption of the distribution of the residuals does not seem to hold, imputation of the missing data using kernel density estimation of the residuals should be considered (see Section 2.2 for more details).

MCMC convergence checking
Before conducting the imputation for the entire dataset, it is recommended that the MCMC sampling convergence be checked. The idem package provides the function imImpSingle that implements the MCMC sampling under the benchmark assumption (i.e., with ∆ T = 0) for an individual subject. The convergence of the MCMC chains can then be checked by a trace plot of the results (Figure 6). If the mixing of the Markov chains are not satisfactory, users should refer to the rstan documents for options (e.g., adapt_delta) that can improve the convergence.

Conduct imputation
The function imImpAll imputes missing outcomes for all survivors with missing functional outcomes to generate complete datasets. The following code shows how to use imImpAll to get M = 5 (n.imp = 5) imputed complete datasets for sensitivity parameters ∆ T = −0.2, −0.15, . . . , 0.2; in this example, the residuals are not assumed to follow a Normal distribution (normal = FALSE). Please note that the choices of ∆ T are application-specific. Once again, we refer readers to Wang et al. (2017) for further instructions about choosing the sensitivity parameters.
The sensitivity parameters considered were [1] -0.20 -0.15 -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 The last 5 records in the complete dataset are given below as an example: The returned value from function imImpAll has class 'IDEMIMP'. The original functional outcomes are kept in the results with prefix ORIG. The column ENDP corresponds to the functional endpoint calculated by the formula specified in endfml in function imData.
The S3 plot method of class 'IDEMIMP' provides options to generate treatment-specific densities of the imputed functional outcomes (opt = "imputed"). Users may choose to plot the density curves for the imputed functional endpoint (endp = TRUE) or functional outcomes (endp = FALSE). Figure 7 presents the treatment-specific densities of the imputed Y 2 (the functional endpoint) for the ABC trial.

Composite endpoint approach
Given a class 'IDEMIMP' object that contains complete datasets with imputed outcomes, idem uses function imInfer to estimate the treatment effect and quantiles of interest (specified by effect.quantiles) of the composite endpoint distribution. The S3 method print allows users to specify the values of sensitivity parameters ∆ 0 (delta0) and ∆ 1 (delta1), and present the corresponding treatment effect estimates. The sensitivity parameters are with column names Delta0 and Delta1 in the treatment effect summary and Delta in the quantiles summary. Note that the results of quantiles of the composite endpoint may be a survival time or a value of the functional outcome, which are reported in columns QuantY and QuantSurv, respectively.  When choosing the number of bootstrap samples (n.boot) to be bigger than 0, the function imInfer performs non-parametric boostrap to conduct hypothesis testing for the treatment effect including evaluating the uncertainties of the estimated quantiles from the composite endpoint distribution. For bootstrap analysis, the function imInfer supports parallel computation on Unix platforms by specifying ncore > 1. For the other imputation parameters (e.g., normality assumption, number of MCMC chains, etc.), the function imInfer takes the same settings contained in the 'IDEMIMP' class object.
For different sensitivity parameters ∆ 0 (Delta0) and ∆ 1 (Delta1), the estimated treatment effect (Theta), the standard deviation of the bootstraps for the estimated θ (SD), two-sided p values for testing the null hypothesis of θ = 0 (PValue), quantiles of the composite endpoint (QuantY, QuantSurv), and the CIs for θ and the quantiles (Q2.5, Q97.5) are obtained by summarizing results from the bootstrap analysis. The columns Q2.5_Surv and Q97.5_Surv of the quantiles are indicators for Q2.5 and Q97.5, respectively, of being a survival time.
Note that levels of the CIs may be specified using the quant.ci parameter of the imInfer function.
Note that these results are for the demonstration of imInfer only. In order to achieve rigorous results, a much larger number of bootstrap samples (e.g., 2000) are required. The detailed analysis of the ABC trial can be found in Wang et al. (2017).
A contour plot of two-sided p values for the null hypothesis of θ = 0 as a function of the multiple imputation sensitivity parameters, ∆ T , can be generated by the S3 plot method of the imInfer function result. Alternatively, the contour plot of the estimated treatment effect θ can be generated by specifying the option to be effect. Figure 9 presents these two types of plots.

Survivors only approach
The default summary of the 'IDEMINFER' class, returned by the imInfer function, generates the survivors only analysis results. As a cautious note, the printout emphasizes that the survivors only analysis is only valid when the treatment has no effect on survival.

SACE approach
The summary function of the 'IDEMINFER' class will generate the SACE analysis results when the option (opt) is specified as SACE. The sensitivity parameters ∆ SACE (4) are passed to the summary function by its argument sace.delta. The default values of sace.delta are provided based on the standard deviation of the bootstraps for the estimated treatment effect on the functional outcomes for survivors.
The idem package provides two different types of plots for visualizing the SACE analysis results. With by.sace = FALSE, the plot function generates the contour plots of p values and θ SACE for given ∆ SACE . With by.sace = TRUE, the plot function of the summary results displays the estimates of and CIs for θ SACE for given imputation sensitivity parameters ∆ 0 and ∆ 1 . Figure 11 presents the different types of plots.

The idem GUI
The idem GUI is web-based and developed in R using the shiny (Chang, Cheng, Allaire, Xie, and McPherson 2020) web application framework. The GUI can be accessed within R using the function imShiny, which calls the runApp function in the R package shiny.

R> imShiny()
The idem GUI provides a series of tab panels which, from left to right, sequentially walk the user through the analysis. The panels are About, Upload Data, Model Specification, Data Exploration, Model Fitting, Configuration, Imputation and Report. The details of each tab panel are given as follows.
About panel: The About panel serves as an introduction page for the software. The sections on this panel present the background information for idem and the purpose of the software. It also explains the basic steps to use the software.

Upload Data panel:
The Upload Data panel provides an interface for users to upload the data to be analyzed. The sections and items within each section on this panel include: • Upload Data

Choose File
Clicking the Browse... button will load local data files in csv or plain text format.

Separator
Field separating character.

Quote
Quoting character.

NA String
String for NA values.

Other
There are two additional options: The Header checkbox indicates if the first line of the file are the names of the columns, the Show Data checkbox indicates whether to present the uploaded data in the Review Data section on this panel.

• Try An Example
Clicking the Try it button will load the example abc dataset.
• Review Data Presents the uploaded dataset in a table view.

Model Specification panel:
The Model Specification panel is designed to specify the idem-parameters. This panel is only available after a dataset has been successfully uploaded. Items on this panel include:

Define Variables
Columns Treatment, Time to death, Outcome, Baseline outcome, Baseline covariates correspond to the idem-parameters trt, surv, outcome, y0 and cov, respectively. The user selects the appropriate variables from the uploaded dataset that define Treatment, Time to death, Outcome, Baseline outcome, and Baseline covariates.

Functional Endpoint
Specify enfml in idem-parameters. This is an R expression indicating the user-specified final functional outcome of interest.

Study Duration
Specify duration, l K , in idem-parameters. This is the length of the study.

Boundary
Specify bounds in idem-parameters. These create a numeric vector of lower and upper bounds for the functional outcomes

Unit Time
A drop-down list that specifies unitTime in idem-parameters. This is the unit of time measurement for survival.

Ranking Rules
Reserved for advanced users.

Labels of Treatment
Specify labels of treatment arms to be used in figures and tables. This is only available after the model specification has been validated.
After the parameters are specified, click the Validate Model button which calls the idem function imChkPars to check if there are any errors or inconsistencies in the specifications.

Data Exploration panel:
The Data Exploration panel provides summary tables and figures for the users to visualize the uploaded dataset including the missing data patterns survival status and functional outcomes among survivors. The items on this panel include: Missing Table  Missingness frequency table generated by imMisTable in idem.

Survival
Kaplan-Meier survival curve generated by imPlotSurv in idem.

Survivors
Spaghetti plot of the observed functional outcomes for survivors generated by imPlotCompleters in idem.

Model Fitting panel:
The Model Fitting panel provides R output and diagnostic plots for each component in the factorized joint distribution of the functional outcomes among survivors with no missing data (Equation 2). The diagnostic plots include the Residuals vs. Fitted plot and the Normal Q-Q plot.

Configuration panel:
The Configuration panel sets the parameters for the multiple imputation and MCMC sampling. The sections and items within each section on this panel include: • General Imputation Settings

Imputed Datasets
Number of complete datasets to be generated.

Cores
Number of cores for parallel bootstap analysis .

Random Seed
Random seed for multiple imputation.

• MCMC Parameters
Iterations Stan parameter specifying how many iterations including burn-in for posterior sampling.
Number of burn-in Stan parameter specifying how many burn-in for posterior sampling.

idem: Inferences in Clinical Trials with Death and Missingness in R
Number of thinning Stan parameter specifying the period for saving posterior samples.

Number of Chains
Stan parameter specifying the number of MCMC chains for sampling.

Acceptance Rate
Stan parameters that affect the MCMC convergence.

Initial
Step-size Stan parameters that affect the MCMC convergence.
• Sensitivity Parameters And Additional Quantile Output

Percentiles
Percentiles of the composite endpoint to be analyzed and reported.

Sensitivity Parameters
Choices of sensitivity parameters ∆ T .

• Check Convergence
Clicking the Check Convergence button will randomly select a subject with at least one missing functional outcome, draw samples of the missing functional outcome(s) by MCMC sampling and present the trace plots of the Markov chains. The trace plots serve as a diagnostic tool for evaluating the mixing of the Markov chains in the imputation.

Imputation panel:
The Imputation panel conducts the imputation and bootstap analysis, presents the results and provides a link to download the imputed data. The sections and items within each section on this panel include: • Benchmark Assumption Imputation After clicking the Benchmark Assumption Imputation button, a progress bar will show up during the imputation. Once the imputation is finished, the following results are presented in this section:

Imputed Data
Contains three panels. The Imputed Dataset panel provides a table view of the complete dataset. The Imputed Outcome and the Imputed Endpoint panel provide the density plots of the imputed functional outcomes and the functional endpoint, respectively, that are generated by the idem function imPlotImputed.

Analysis Results
Presents the tables of the estimated θ and quantiles of the composite endpoint for all values of the sensitivity analysis parameters. It also presents the cumulative distribution function of the composite endpoint under the benchmark assumption that is generated by the imPlotComposite function in idem.

Download
Select the Download button to download the complete datasets as a delimited text file.

• Hypothesis Testing by Bootstrap
Clicking the button Hypothesis Testing by Bootstrap will conduct the bootstrap analysis.

Analysis results
The composite endpoint based analysis results are presented in three panels. The Ranks panel presents the table of θ's, the corresponding standard deviation of the bootstraps and p values for all sensitivity analysis scenarios. The Quantiles panel presents the table of requested quantiles and the corresponding lower and upper bounds for all sensitivity analysis scenarios. The Contour Plot panel presents the contour plot of the p values obtained by testing the null hypothesis of θ = 0 as a function of the treatmentspecific sensitivity analysis. The plot is generated by the idem function imPlotContour.

Survivor only analysis results
The survivor only analysis results are presented in Treatment Effect panel and Contour Plot panel that are similar to the composite endpoint based analysis results.

SACE analysis results
The SACE analysis results are also presented in Treatment Effect panel and Contour Plot panel.
Report panel: The Report panel provides a Download button for downloading the analysis results as a report. The available document formats for the report include PDF, HTML and Word.
The entire analysis can be performed using the following steps: Step 1. Upload the ABC data file to idem from the Upload Data panel (Figure 12). One can also load the data from idem by clicking the Try it button.
Step 2. Specify the idem-parameters on the Model Specification panel (Figure 13). Set the TRT column to be the Treatment, SURV column to be Time to Death, Y1 and Y2 columns to be Outcome and AGE column to be Baseline covariates. Specify the functional endpoint Z as Y2 and study duration to be 365 days. Set the boundaries of the cognition score (i.e., functional outcomes) to be (0, 100).
Click the Validate Model button to validate the model specification settings. If the result is Model specification is valid, specify the treatment labels to be UC+SBT and SAT+SBT, which will be used in figures and tables, and proceed to the next step ( Figure 14).
Step 3. In the Data Exploration panel, review the missing data pattern table (Figure 15), the missing data pattern heatmap, the Kaplan-Meier survival curves ( Figure 16) and the       Step 4. The model fitting results are presented on the Model Fitting panel (Figures 17-18). The residuals vs. fitted plot and the normal Q-Q plot of the model fitting results indicate that the normality assumption for the residuals may not hold.
Step 5. Move to the Configuration panel to specify imputation and bootstrap analysis parameters. Because of the concern about the normality assumption based on the model fitting results, specify the Normality assumption to be No. Specify the number of imputed datasets to be 5 and the number of bootstrap samples for the bootstrap analysis to be 100. Specify the sensitivity parameters to be −0.2, 0, 0.2. Choose 5 cores for bootstap parallel analysis ( Figure 19). Note that the number of cores available may be different depending on the available cores for the R process.
This panel provides a Check Convergence button to randomly select an individual with missing functional outcomes, conduct the imputation under the benchmark assumption for the individual and present the traceplot of the MCMC samples ( Figure 20). If there appears to be an issue with the convergence, the user should consider running a longer Markov chain and adjusting the target Metropolis acceptance rate or initial step-size. In our example, it can be seen that the MCMC chains are mixed well.
Step 6. On the Imputation panel, click the Benchmark Assumption Imputation button to conduct the imputation and the Hypothesis Testing by Bootstrap button to conduct the bootstrap analysis and draw inference. Selected results for the example are presented on       Step 7. After conducting the analysis, choose to download a report as a PDF, HTML, or Word document from the Report panel ( Figure 23). The report contains sections for Data Summary, Analysis Summary, Missingness Summary, Imputation Results and Bootstrap Results. Figure 24 shows the content page of report for the example. Note that generating the PDF version of the report requires a T E X/L A T E X installation.

Conclusion
Missing data and data "truncated due to death" occur frequently in randomized clinical trials. Wang et al. (2017) proposed an approach that was based on the composite of mortality and the functional outcomes among survivors that accounts for both intermittent missing data and data "truncated due to death". Their proposal applied the complete case missing value constraints for missing data imputation and suggested a global sensitivity analysis framework to further assess the robustness of the findings.
In this paper, we introduce the R package idem that implements the proposed method in Wang et al. (2017). The idem package provides functions for users to visualize the missing data patterns, the observed functional outcomes among survivors and the survival curves for all randomized patients. The imputation functions in idem implement the imputation using the adaptive Hamiltonian Monte Carlo algorithm provided by rstan. The idem package also provides functions for conducting bootstrap analysis and drawing inference. In addition, the idem package also provides functions to evaluate the survivors only treatment effect and survivor average causal effect on the functional outcomes based on the same missing data imputation strategy proposed by Wang et al. (2017).
A unique feature of idem is that it provides a shiny-based graphical user interface for users to apply functions in idem in an interactive and user-friendly manner. With the GUI feature, idem can be used by not only statisticians but also analysts that are not familiar with the R environment.