-
Notifications
You must be signed in to change notification settings - Fork 0
/
chapter_10_part1.Rmd
73 lines (53 loc) · 2.48 KB
/
chapter_10_part1.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
title: "Dealing with irregular and informative visits"
author: "Thomas Debray"
date: "This report was generated on `r format(Sys.time(), '%d %B, %Y')`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(message = FALSE)
source("Chapter 10 - Dealing with irregular and informative visits/sim.r")
source("Chapter 10 - Dealing with irregular and informative visits/fig_functions.r")
```
# Introduction
## Data generation
We simulate a randomized clinical trial with no treatment effect.
```{r}
sim_data <- sim_data_EDSS(tx_alloc_FUN = treatment_alloc_randomized, delta_xt = 0)
```
The data frame `sim_data` contains information on the treatment allocation `x` and two baseline covariates include `age` and `edss` (EDSS at treatment start). The outcome `y` represents the Expanded Disability Status Scale (EDSS) score after `time` months of treatment exposure. Briefly, the EDSS is a semi-continuous measure that varies from 0 (no disability) to 10 (death).
```{r}
plot_distribution_edss(sim_data)
```
Finally, we have a binary outcome `progression` representing disease progression which is defined as follows:
- An increase in 1.5 points from `edss` \>= 0 and \< 1
- An increase in 1.0 points from `edss` \>= 1 and \< 6
- An increase of 0.5 points from `edss` \>= 6
```{r}
plot_distribution_progression(sim_data)
```
Simulate a randomized clinical trial with a (linear) treatment effect
```{r}
sim_data <- sim_data_EDSS(tx_alloc_FUN = treatment_alloc_randomized, delta_xt = -0.007)
plot_distribution_edss(sim_data)
plot_distribution_progression(sim_data)
```
Simulate a dataset with unequal treatment allocation
```{r}
sim_data <- sim_data_EDSS(tx_alloc_FUN = treatment_alloc_confounding, delta_xt = -0.007)
plot_distribution_edss(sim_data)
```
## Introduce missing visits
The following censoring functions are available to introduce informative patient visits:
- `censor_visits_a1` : Patient visits are missing according to center only
- `censor_visits_a2` : Patient visits are missing according to center and received treatment
- `censor_visits_a3` : Visit schedules are regular but differ between treatment groups
- `censor_visits_a4` : Patient visits are missing according to their received treatment and current EDSS score
```{r}
sim_data_censored <- censor_visits_a2(data = sim_data)
plot_prob_visit(sim_data_censored)
sim_data_censored <- censor_visits_a3(data = sim_data)
plot_prob_visit(sim_data_censored)
```
## Impute missing data