-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKleynhans analysis.Rmd
59 lines (48 loc) · 2.88 KB
/
Kleynhans analysis.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
---
title: "Kleynhans analysis"
author: "Dan Weinberger"
date: "12/18/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
#Analysis described by Kleynhans et al.
##Install needed packages
```{r}
#Used to check for relevant packages and update them if out of date or install them if not installed.
update_packages <- TRUE #Whether to update outdated packages.
install_packages <- TRUE #Whether to install missing packages.
install_pandoc <- TRUE #Whether to install pandoc, which requires an external installer, and rmarkdown, a package that depends on pandoc's successful installation.
```
## Assign variable values
```{r}
group_name <- 'age' #Name of column containing group labels.
date_name <- 'date' #Name of column containing dates.
outcome_name <- 'Pneum' #Name of column containing outcome.
denom_name <- 'denom' #Name of column containing denominator to be used in offset.
country <- 'South Africa' #Country or region name.
n_seasons <- 12 #Number of months (seasons) per year. 12 for monthly, 4 for quarterly, 3 for trimester data.
exclude_covar <- c('AllRes', 'PI', 'POth', 'AllDiar', 'Pneum', 'Menin', 'BactMenin', 'Bact', 'OtMed', 'Mast', 'SeptArthr', "denom", "A20_B99_excl_bac", "A16", "A17", "A18", "A19", "R00_R09", "R10_R19", "R20_R39", "R40_R49", "R50_R69", "R70_R94", "R95_R99", "D50_D89")
exclude_group <- c() #User-defined list of groups to exclude from analyses.
code_change <- FALSE
```
```{r}
input_directory <- './Data/' #Directory (or URL) containing input data file. JK: Leave this blank and just copy data directly into the file with the R files
output_directory <- './Results/Results' #Directory where results will be saved.
output_directory <- paste(output_directory, format(Sys.time(), '%Y-%m-%d-%H%M%S'), '/', sep = '') #Adds a subfolder to output directory to organize results by date and time run.
file_name <- 'RSA.csv' #Name of file containing data for analysis. Must be a .csv file.
```
```{r}
#MOST DATES MUST BE IN FORMAT "YYYY-MM-01", exception is end of pre period, which is 1 day before end of post period
start_date <- as.Date('1999-01-01') #Indicates the date of the first data point.
intervention_date <- as.Date('2009-04-01') #Indicates the date of intervention in the data.
end_date <- as.Date('2016-12-01') #Indicates the date of the last data point.
pre_period <- as.Date(c('1999-01-01', '2009-03-31')) #Range over which the data is trained for the CausalImpact model.
post_period <- as.Date(c('2009-04-01', '2016-12-01')) #Range from the intervention date to the end date.
eval_period <- as.Date(c('2012-01-01', '2016-12-01')) #Range over which rate ratio calculation will be performed.
```
## Run analysis and generate HTML report
```{r}
source('./main analysis components/synthetic_control_report.R', local = TRUE)
```