Skip to content
Permalink
4bf46dbce4
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
120 lines (89 sloc) 3.76 KB
---
title: "R Notebook"
output: html_notebook
---
```{r}
source("../scripts/Equity_metrics.R")
source("../scripts/sunburst_process.R")
source("../scripts/table_process.R")
library(plotly)
library(formattable)
```
Read in the datasets
```{r}
ATUSreference<-read.csv(file = "../data/Atus/atus_train.csv")
ATUSsynthetic<-read.csv(file = "../data/Atus/atus_train_synthetic.csv")
MIMICRacereference<-read.csv(file = "../data/Mimic/mimic_3.csv")
MIMICRacesynthetic<-read.csv(file = "../data/Mimic/mimic_3_synthetic.csv")
```
Preprocess the ATUS data
```{r}
ATUSreference_processed<-ATUSreference %>%
group_by(TESEX, TEAGE) %>%
summarise(background_n = n())
colnames(ATUSreference_processed)<-c("Gender","Age","background_n")
ATUSsynthetic_processed<-ATUSsynthetic %>%
group_by(TESEX, TEAGE) %>%
summarise(background_n = n())
colnames(ATUSsynthetic_processed)<-c("Gender","Age","user_n")
ATUSreference_processed<-ATUSreference_processed %>% mutate(Gender=recode(Gender,
`1`="Male",
`2`="Female"),
Age=recode(Age,
`0`="15-24",
`1`="25-34",
`2`="35-44",
`3`="45-54",
`4`="55-64",
`5`="65-74",
`6`="75+"))
ATUSsynthetic_processed<-ATUSsynthetic_processed %>% mutate(Gender=recode(Gender,
`1`="Male",
`2`="Female"),
Age=recode(Age,
`0`="15-24",
`1`="25-34",
`2`="35-44",
`3`="45-54",
`4`="55-64",
`5`="65-74",
`6`="75+"))
```
Preprocess the MIMIC data
```{r}
MIMICRacereference_processed<-MIMICRacereference %>%
group_by(GENDER,AGE,ETHNICITY,mortality_withinthirtydays) %>%
summarise(background_n = n())
colnames(MIMICRacereference_processed)<-c("Gender","Age","Ethnicity","Mortality","background_n")
MIMICRacesynthetic_processed<-MIMICRacesynthetic %>%
group_by(GENDER,AGE, ETHNICITY, mortality_withinthirtydays) %>%
summarise(background_n = n())
colnames(MIMICRacesynthetic_processed)<-c("Gender","Age","Ethnicity","Mortality","user_n")
MIMICRacereference_processed$Mortality<-as.factor(MIMICRacereference_processed$Mortality)
MIMICRacesynthetic_processed$Mortality<-as.factor(MIMICRacesynthetic_processed$Mortality)
MIMICRacereference_processed<-MIMICRacereference_processed %>% mutate(Gender=recode(Gender,
`M`="Male",
`F`="Female"),
Mortality =recode(Mortality,
`0`="Alive",
`1`="Died"))
MIMICRacesynthetic_processed<-MIMICRacesynthetic_processed %>% mutate(Gender=recode(Gender,
`M`="Male",
`F`="Female"),
Mortality =recode(Mortality,
`0`="Alive",
`1`="Died"))
```
Evaluation on ATUS data
```{r}
test_sunburst2(ATUSreference_processed,c("Gender","Age"),ATUSsynthetic_processed, "ATUSEquity1.csv", sig_t = 0.05,lower_t = -log(0.9), upper_t = -log(0.8) )
```
Evaluation on MIMIC data
```{r}
test_sunburst2(MIMICRacereference_processed,c("Mortality","Ethnicity","Age","Gender"),MIMICRacesynthetic_processed,"MIMICRaceEquity1.csv", sig_t = 0.05,lower_t = -log(0.9), upper_t = -log(0.8))
```
Tables for ATUS and MIMIC with significance threshold =0.05, lower metric threshold = -log(0.9), upper metric threshold = -log(0.8), metric = log disparity
```{r}
generate_table(0.05,-log(0.9),-log(0.8), "LDI", "ATUS")
generate_table(0.05,-log(0.9),-log(0.8), "LDI", "MIMIC")
```