---
title: "Biostatistics III in R"
author:
- Code by Annika Tillander, Andreas Karlsson and Mark Clements
output:
  prettydoc::html_pretty:
    mathjax: https://biostat3.net/js/mathjax/tex-chtml.js
    theme: cayman
    highlight: github
---

## Exercise 4. Localised melanoma: Comparing actuarial and Kaplan-Meier approaches with discrete time data ##


```{r setup, cache=FALSE, message=FALSE, echo=FALSE}
library('knitr')
read_chunk('../q4.R')
opts_chunk$set(cache=FALSE)
```

We load the dependencies:

```{r loadDependencies, message=FALSE}
```

Then load the data and define an indicator:
```{r loadPreprocess}
```

Then we show the results using the actuarial estimator with years:
```{r actuarialYears, results='asis'}
```

Similarly, we use the actuarial estimator using months:
```{r actuarialMonths, results='asis'}
```

Then the code using the Kaplan-Meier estimator with years:
```{r kmYears}
```

And the Kaplan-Meier estimator with data in months:
```{r kmMonths}
```

## (a) ##
The actuarial method is most appropriate because it deals with
        ties (events and censorings at the same time) in a more
        appropriate manner. The fact that there are a reasonably large
        number of ties in these data means that there is a difference
        between the estimates.

## (b) ##
The K-M estimate changes more. Because the actuarial method
        deals with ties in an appropriate manner it is not biased when
        data are heavily tied so is not heavily affected when we reduce
        the number of ties.


## (c) ##

The plot clearly shows that the Kaplan-Meier estimator with the
aggregated data is upwardly biased compared with the other curves.

```{r comparisonPlot}
```
