---
title: "Composite Endpoint Analysis Report"
author: "[Missing Data Matters](http://sow.familyds.com/shiny/composite/)"
date: "`r Sys.Date()`"
toc: true
number_sections: true
output: pdf_document
---

\newpage

# Data Summary

```{r, echo=FALSE, eval=TRUE}
library(xtable);
data.all <- get.data();
summary(data.all$data);
```

# Analysis Summary

The basic settings of the analysis are as follows:

```{r,echo=FALSE, eval=TRUE}
    print(data.all);
```


# Missingness Summary

```{r,echo=FALSE, eval=TRUE, results='asis'}
    mis.tbl <- summary(data.all, type = "misstable");
    print(xtable(mis.tbl), comment = FALSE, align=c("r", rep("c",4)));
```


# Survival

```{r,echo=FALSE, eval=TRUE}
    plot(data.all, type = "KM");
```

\newpage

# Imputation Result

## Imputed Outcomes

```{r,echo=FALSE, eval=TRUE}
deltas   <- get.deltas();
imp.data <- get.imputed.full();

if (any(is.null(c(imp.data)))) {
  print("Not available");
} else {
    plot(imp.data, type = "imputed",
         deltas = sort(unique(c(0, range(deltas)))));
}
	 
```

## Imputed Endpoint

```{r,echo=FALSE, eval=TRUE}
if (is.null(c(imp.data))) {
  print("Not available");
} else {
    plot(imp.data, type = "imputed",
         deltas = sort(unique(c(0, range(deltas)))),
         endp = TRUE);
}

```

## Composite Quantile

```{r,echo=FALSE, eval=TRUE}
if (is.null(imp.data)) {
  print("Not available");
} else {
  plot(imp.data, type = "composite");
}
```

\newpage

# Bootstrap Results

## Hypothesis Testing

```{r,echo=FALSE, eval=TRUE, results='asis'}

sum.boot <- get.rst.boot();
if (!is.null(sum.boot)) {
    print(xtable(sum.boot$theta), comment=FALSE);
} else {
  print("Not available");
}

```

## Median
```{r,echo=FALSE, eval=TRUE, results='asis'}
if (!is.null(sum.boot)) {
    print(xtable(sum.boot$effect.quantiles), comment=FALSE);
} else {
  print("Not available");
}
```

## Contour plot
```{r,echo=FALSE, eval=TRUE}
   plot(sum.boot, nlevels = 30, con.v=0.05, zlim=c(0, 0.05));
```
