-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5_result_tables.R
60 lines (41 loc) · 2.09 KB
/
5_result_tables.R
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
library(dplyr)
load("APC_df.RData")
source("functions.R")
sim <- expand.grid(AGEY_M=sort(unique(APC_df$AGEY_M)),
period=sort(unique(APC_df$period)),
birthcohort2=sort(unique(APC_df$birthcohort2)))
#repeat 10 times
sim <- sim[rep(seq_len(nrow(sim)), each = 10), ]
###main analysis----
load("Mediationresults_aggregated.RData")
## make tables
SMOK <- decomp_table(SMOK.BS.nc2, SMOK.BS.cf2)
SMOK2 <- rel.diff_contr_table(SMOK.BS.nc2, SMOK.BS.cf2)
BMI <- decomp_table(BMI.BS.nc2, BMI.BS.cf2)
BMI2 <- rel.diff_contr_table(BMI.BS.nc2, BMI.BS.cf2)
DRINK <- decomp_table(DRINK.BS.nc2, DRINK.BS.cf2)
DRINK2 <- rel.diff_contr_table(DRINK.BS.nc2, DRINK.BS.cf2)
PHYSACT <- decomp_table(PHYSACT.BS.nc2, PHYSACT.BS.cf2)
PHYSACT2 <- rel.diff_contr_table(PHYSACT.BS.nc2, PHYSACT.BS.cf2)
###BY SEX----
load("Mediationresults_bysex_aggregated.RData")
## make tables
SMOK <- decomp_table(SMOK.BS.nc2, SMOK.BS.cf2, strata="sex")
SMOK2 <- rel.diff_contr_table(SMOK.BS.nc2, SMOK.BS.cf2, strata="sex")
BMI <- decomp_table(BMI.BS.nc2, BMI.BS.cf2, strata="sex")
BMI2 <- rel.diff_contr_table(BMI.BS.nc2, BMI.BS.cf2, strata="sex")
DRINK <- decomp_table(DRINK.BS.nc2, DRINK.BS.cf2, strata="sex")
DRINK2 <- rel.diff_contr_table(DRINK.BS.nc2, DRINK.BS.cf2, strata="sex")
PHYSACT <- decomp_table(PHYSACT.BS.nc2, PHYSACT.BS.cf2, strata="sex")
PHYSACT2 <- rel.diff_contr_table(PHYSACT.BS.nc2, PHYSACT.BS.cf2, strata="sex")
####by ethnicity----
load("Mediationresults_byethn_aggregated.RData")
## make tables
SMOK <- decomp_table(SMOK.BS.nc2, SMOK.BS.cf2, strata="ethn")
SMOK2 <- rel.diff_contr_table(SMOK.BS.nc2, SMOK.BS.cf2, strata="ethn")
BMI <- decomp_table(BMI.BS.nc2, BMI.BS.cf2, strata="ethn")
BMI2 <- rel.diff_contr_table(BMI.BS.nc2, BMI.BS.cf2, strata="ethn")
DRINK <- decomp_table(DRINK.BS.nc2, DRINK.BS.cf2, strata="ethn")
DRINK2 <- rel.diff_contr_table(DRINK.BS.nc2, DRINK.BS.cf2, strata="ethn")
PHYSACT <- decomp_table(PHYSACT.BS.nc2, PHYSACT.BS.cf2, strata="ethn")
PHYSACT2 <- rel.diff_contr_table(PHYSACT.BS.nc2, PHYSACT.BS.cf2, strata="ethn")