-
Notifications
You must be signed in to change notification settings - Fork 0
/
03d_Display_Cox_Model_Input.Rmd
59 lines (47 loc) · 1.86 KB
/
03d_Display_Cox_Model_Input.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: "Display Cox Model Input"
output: html_document
date: "2023-05-17"
---
```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
descriptors = c ("ageYear", "n_risk_gps", "Sex", "age_gp", "covid_vs", "flu_vs", "urban_rural_classification", "simd", "icu_admit_age", "death_28", "hosp_los_gp", "num_prev_admission_gp", "ethnic_gp", "health_board")
descriptors_labels = c ("Age", "Number of Risk Groups", "Sex", "Age Groups", "Covid Vaccination Status",
"Flu Vaccination Status", "Urban/Rural Classification", "SIMD", "ICU Admittance", "Death",
"Length of Stay", "Number of previous admissions", "Ethnic Group", "Health Board")
var_labels = setNames(as.list(descriptors_labels), descriptors)
```
## Case/Control Split
```{r}
print(table(df_all$event))
```
## Cox Model Input Description
```{r}
z_df = df_all %>% mutate(type = if_else(event == 1, "Case", "Selected Control"))
z_all_controls = df_controls %>% mutate(type = "Population Control",
time = 0)
z_df = z_df %>% rbind(z_all_controls)
z_df$type = as.factor(z_df$type)
z_df = z_df %>%
mutate(simd = factor(simd)) %>%
mutate(health_board = as.factor(health_board)) %>%
mutate(ethnic_gp = as.factor(ethnic_gp)) %>%
mutate(death_28 = as.factor(death_28))
z_df = z_df %>% set_variable_labels(.labels=var_labels, .strict=FALSE)
kable(summary_factorlist_wt(z_df, "type", descriptors))
```
## All controls
```{r}
print(sum(df_controls$eave_weight))
```
```{r}
z_df = df_controls %>%
mutate(value = TRUE) %>%
mutate(simd = factor(simd)) %>%
mutate(health_board = as.factor(health_board)) %>%
mutate(ethnic_gp = as.factor(ethnic_gp)) %>%
mutate(death_28 = as.factor(death_28))
z_df = z_df %>% set_variable_labels(.labels=var_labels, .strict=FALSE)
kable(summary_factorlist_wt(z_df, "value", descriptors))
```