This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
03.slade_aurum_cohort_tables.R
947 lines (535 loc) · 43.9 KB
/
03.slade_aurum_cohort_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
####################
## Description:
## - In this file we:
## - Produce tables to describe cohorts
## - Produce tables to describe forest plots.
####################
### Load libraries required
library(tidyverse)
library(tableone)
### Load functions required
source("02.slade_aurum_set_data.R")
source("01.slade_aurum_functions.R")
#:--------------------------------------------------------------------------------------
## Start of the file
### Run through the inclusion criteria to make all necessary datasets.
set_up_data_sglt2_glp1(dataset.type = "diagnostics")
### Make tables for each of the datasets
# Variables to be used in the table
vars <- c("yrdrugstart","agetx", "t2dmduration", "sex", "ethnicity", "drug_canagliflozin",
"drug_dapagliflozin", "drug_empagliflozin", "drug_ertugliflozin", "drug_dulaglutide",
"drug_exenatide_short", "drug_exenatide_long", "drug_liraglutide", "drug_lixisenatide",
"deprivation", "smoke", "drugline", "ncurrtx", "MFN", "SU", "DPP4", "SGLT2", "TZD",
"GLP1", "prehba1c", "prehba1c_na", "prebmi", "prebmi_na", "preegfr", "preegfr_na",
"prehdl", "prehdl_na", "prealt", "prealt_na", "prealbuminblood", "prealbuminblood_na",
"prebilirubin", "prebilirubin_na", "pretotalcholesterol", "pretotalcholesterol_na",
"premap", "premap_na", "prediabeticnephropathy", "preneuropathy", "preretinopathy",
"preangina","CV_problems", "microvascular_complications", "ASCVD", "preaf",
"prerevasc", "preheartfailure", "prehypertension", "preihd", "premyocardialinfarction",
"prepad", "prestroke","pretia", "preckd", "precld", "qrisk2_10yr_score", "qrisk2_10yr_score_na",
"posthba1cfinal", "posthba1cfinal_na", "hba1cmonth", "hba1cmonth_na")
#:-----------------------
############## Predicted treatment benefits
####### > 5 mmol for either drug
### HbA1c train - dataset with complete variables used for fitting the model (smaller than hba1c.train)
hba1c.train.complete.benefit.simple <- set_up_data_sglt2_glp1(dataset.type = "hba1c.train") %>%
left_join(readRDS("Samples/SGLT2-GLP1/Aurum//ps_model/patient_prop_scores.rds"), by = c("patid", "pated")) %>%
# drop the variables with the most missingness
select(-preacr, -preast, -prehaematocrit, -prehaemoglobin, -pretriglyceride) %>%
# only complete cases
drop_na() %>%
as.data.frame() %>%
# selected variables from SparseBCF
select(patid, pated, posthba1cfinal, drugclass, unique(c(readRDS("Samples/SGLT2-GLP1/Aurum//response_model_bcf/variables_mu.rds"), readRDS("Samples/SGLT2-GLP1/Aurum/response_model_bcf/variables_tau.rds"))), prop.score) %>%
# only complete cases
drop_na() %>%
as.data.frame() %>%
left_join(readRDS("Samples/SGLT2-GLP1/Aurum/response_model_bcf/patient_effects.rds"), by = c("patid", "pated")) %>%
mutate(benefit = ifelse(effects < -5, "SGLT2i", ifelse(effects > 5, "GLP1-RA", NA_real_))) %>%
select(patid, pated, benefit)
hba1c.train.complete.benefit <- new.vars(hba1c.train.complete.benefit.simple)
tab.benefits <- CreateTableOne(vars = c("drugclass", vars), factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "benefit", data = hba1c.train.complete.benefit, test = FALSE)
## Show table with SMD
print(tab.benefits, smd = TRUE)
### HbA1c test - dataset with complete variables used for validation
hba1c.test.complete.benefit.simple <- set_up_data_sglt2_glp1(dataset.type = "hba1c.test") %>%
left_join(readRDS("Samples/SGLT2-GLP1/Aurum//ps_model/patient_prop_scores.rds"), by = c("patid", "pated")) %>%
# selected variables from SparseBCF
select(patid, pated, posthba1cfinal, drugclass, unique(c(readRDS("Samples/SGLT2-GLP1/Aurum//response_model_bcf/variables_mu.rds"), readRDS("Samples/SGLT2-GLP1/Aurum/response_model_bcf/variables_tau.rds"))), prop.score) %>%
# only complete cases
drop_na() %>%
as.data.frame() %>%
left_join(readRDS("Samples/SGLT2-GLP1/Aurum/response_model_bcf/patient_effects.rds"), by = c("patid", "pated")) %>%
mutate(benefit = ifelse(effects < -5, "SGLT2i", ifelse(effects > 5, "GLP1-RA", NA_real_))) %>%
select(patid, pated, benefit)
hba1c.test.complete.benefit <- new.vars(hba1c.test.complete.benefit.simple)
tab.benefits <- CreateTableOne(vars = c("drugclass", vars), factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "benefit", data = hba1c.test.complete.benefit, test = FALSE)
## Show table with SMD
print(tab.benefits, smd = TRUE)
### HbA1c train
hba1c.train.benefit.simple <- set_up_data_sglt2_glp1(dataset.type = "hba1c.train") %>%
left_join(readRDS("Samples/SGLT2-GLP1/Aurum/response_model_bcf/patient_effects.rds"), by = c("patid", "pated")) %>%
mutate(benefit = ifelse(effects < -5, "SGLT2i", ifelse(effects > 5, "GLP1-RA", NA_real_))) %>%
select(patid, pated, benefit)
hba1c.train.benefit <- new.vars(hba1c.train.benefit.simple)
# Abstract values (results)
tab.benefits <- CreateTableOne(vars = c("drugclass", vars), factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "benefit", data = hba1c.train.benefit, test = FALSE)
## Show table with SMD
print(tab.benefits, smd = TRUE)
### Full cohort
full.cohort.benefit.simple <- set_up_data_sglt2_glp1(dataset.type = "full.cohort") %>%
left_join(readRDS("Samples/SGLT2-GLP1/Aurum/response_model_bcf/patient_effects.rds"), by = c("patid", "pated")) %>%
mutate(benefit = ifelse(effects < -5, "SGLT2i", ifelse(effects > 5, "GLP1-RA", NA_real_))) %>%
select(patid, pated, benefit)
full.cohort.benefit <- new.vars(full.cohort.benefit.simple)
tab.benefits <- CreateTableOne(vars = c("drugclass", vars), factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "benefit", data = full.cohort.benefit, test = FALSE)
## Show table with SMD
print(tab.benefits, smd = TRUE)
####### any benefit for either drug
### Full cohort
full.cohort.any_benefit.simple <- set_up_data_sglt2_glp1(dataset.type = "full.cohort") %>%
left_join(readRDS("Samples/SGLT2-GLP1/Aurum/response_model_bcf/patient_effects.rds"), by = c("patid", "pated")) %>%
mutate(benefit = ifelse(effects < 0, "SGLT2i", ifelse(effects > 0, "GLP1-RA", NA_real_))) %>%
select(patid, pated, benefit)
full.cohort.any_benefit <- new.vars(full.cohort.any_benefit.simple)
tab.benefits <- CreateTableOne(vars = c("drugclass", vars), factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "benefit", data = full.cohort.any_benefit, test = FALSE)
## Show table with SMD
print(tab.benefits, smd = TRUE)
table(full.cohort.any_benefit.simple$sex, full.cohort.any_benefit.simple$benefit)
#:-----------------------------------------------------------------------------
############## Generic table description
### Full cohort
full.cohort.simple <- set_up_data_sglt2_glp1(dataset.type = "full.cohort") %>%
select(patid, pated)
full.cohort <- new.vars(full.cohort.simple)
## Construct a table
tab.full.cohort <- CreateTableOne(vars = vars, factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "drugclass", data = full.cohort, test = FALSE)
## Show table with SMD
print(tab.full.cohort, smd = TRUE)
summary(full.cohort%>%select(agetx)) # results values
sd(full.cohort%>%select(agetx)%>%unlist(), na.rm = TRUE)
summary(full.cohort%>%select(sex))
table(full.cohort%>%select(sex))/nrow(full.cohort)*100
summary(full.cohort%>%select(ethnicity))
table(full.cohort%>%select(ethnicity))/nrow(full.cohort)*100
#:----------------------------
### PS model train
ps.model.train.simple <- set_up_data_sglt2_glp1(dataset.type = "ps.model.train") %>%
select(patid, pated)
ps.model.train <- new.vars(ps.model.train.simple)
## Construct a table
tab.ps.model.train <- CreateTableOne(vars = vars, factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "drugclass", data = ps.model.train, test = FALSE)
## Show table with SMD
print(tab.ps.model.train, smd = TRUE)
#:----------------------------
### PS model test
ps.model.test.simple <- set_up_data_sglt2_glp1(dataset.type = "ps.model.test") %>%
select(patid, pated)
ps.model.test <- new.vars(ps.model.test.simple)
## Construct a table
tab.ps.model.test <- CreateTableOne(vars = vars, factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "drugclass", data = ps.model.test, test = FALSE)
## Show table with SMD
print(tab.ps.model.test, smd = TRUE)
#:----------------------------
### HbA1c model train
hba1c.train.simple <- set_up_data_sglt2_glp1(dataset.type = "hba1c.train") %>%
select(patid, pated)
hba1c.train <- new.vars(hba1c.train.simple)
## Construct a table
tab.hba1c.train <- CreateTableOne(vars = vars, factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "drugclass", data = hba1c.train, test = FALSE)
## Show table with SMD
print(tab.hba1c.train, smd = TRUE)
# abstract values (methods)
summary(hba1c.train %>% select(prehba1c, agetx))
sd(hba1c.train%>%select(prehba1c)%>%unlist());sd(hba1c.train%>%select(agetx)%>%unlist())
table(hba1c.train %>% select(sex))/nrow(hba1c.train)*100
#:----------------------------
### HbA1c model test
hba1c.test.simple <- set_up_data_sglt2_glp1(dataset.type = "hba1c.test") %>%
select(patid, pated)
hba1c.test <- new.vars(hba1c.test.simple)
## Construct a table
tab.hba1c.test <- CreateTableOne(vars = vars, factorVars = c("MFN", "SU", "DPP4", "SGLT2", "TZD", "GLP1"), includeNA = TRUE, strata = "drugclass", data = hba1c.test, test = FALSE)
## Show table with SMD
print(tab.hba1c.test, smd = TRUE)
#:-------------------------------------------------------------------------------------
#:-------------------------------------------------------------------------------------
#:-------------------------------------------------------------------------------------
#:-------------------------------------------------------------------------------------
output_path <- "Samples/SGLT2-GLP1/Aurum"
interval_breaks <- c(-5, -3, 0, 3, 5)
## Read in propensity scores
patient_prop_scores <- readRDS(paste0(output_path, "/ps_model/patient_prop_scores.rds"))
## Read in treatment effects
treatment_effects <- readRDS(paste0(output_path, "/response_model_bcf/patient_effects.rds"))
# load in variables used in the model
variables_mu <- readRDS(paste0(output_path, "/response_model_bcf/variables_mu.rds"))
variables_tau <- readRDS(paste0(output_path, "/response_model_bcf/variables_tau.rds"))
#### Tables containing the numerical results for clinical utilities
### HbA1c predictions of change
model_variables <- unique(c(variables_mu, variables_tau))[which(unique(c(variables_mu, variables_tau)) != "sex")]
## CPRD
## HbA1c clinical subgroups - predicted hba1c benefit
full.dataset <- set_up_data_sglt2_glp1(dataset.type = "full.cohort") %>%
left_join(patient_prop_scores, by = c("patid", "pated")) %>%
left_join(treatment_effects, by = c("patid", "pated")) %>%
mutate(hba1c.change = posthba1cfinal - prehba1c,
drugclass = factor(drugclass, levels = c("GLP1", "SGLT2")))
# still population into subgroups
group.full.dataset <- group_values(data = full.dataset,
variable = "effects",
breaks = interval_breaks) %>%
drop_na(intervals) %>%
rename("hba1c_diff" = "effects")
# predictions for the hba1c adjusted model
predictions_hba1c_stan_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_hba1c_stan_adjusted_overall.rds")) %>%
as.data.frame() %>%
mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci))
# predictions for the hba1c adjusted model full
predictions_hba1c_stan_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_hba1c_stan_adjusted_full.rds")) %>%
as.data.frame() %>%
mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci))
print(predictions_hba1c_stan_adjusted_full, digits = 4)
print(predictions_hba1c_stan_adjusted_overall, digits = 2)
### HbA1c treatment effect
# combine everyone that can be included in the HbA1c analysis
hba1c <- set_up_data_sglt2_glp1(dataset.type = "hba1c.train") %>%
left_join(patient_prop_scores, by = c("patid", "pated")) %>%
left_join(treatment_effects, by = c("patid", "pated")) %>%
rbind(
set_up_data_sglt2_glp1(dataset.type = "hba1c.test") %>%
left_join(patient_prop_scores, by = c("patid", "pated")) %>%
left_join(treatment_effects, by = c("patid", "pated"))
)
# split into subgroups according to hba1c benefit predicted
group.hba1c.dataset <- group_values(data = hba1c,
variable = "effects",
breaks = interval_breaks) %>%
drop_na(intervals) %>%
rename("hba1c_diff" = "effects")
# Full dataset
#-- PSM
ATE_psm_1_1_hba1c_full <- calc_ATE_validation_prop_matching(group.hba1c.dataset%>%mutate(intervals = as.numeric(1)), "posthba1cfinal", group.hba1c.dataset$prop.score, quantile_var = "intervals", adjust = FALSE, order = "largest")
ATE_psm_1_1_hba1c <- calc_ATE_validation_prop_matching(group.hba1c.dataset%>%mutate(intervals = as.numeric(intervals)), "posthba1cfinal", group.hba1c.dataset$prop.score, quantile_var = "intervals", adjust = FALSE, order = "largest")
print(ATE_psm_1_1_hba1c_full[["effects"]], digits =3)
print(ATE_psm_1_1_hba1c[["effects"]], digits =3) # abstract values (results)
#-- PSM + adjust
ATE_psm_1_1_adjust_hba1c_full <- calc_ATE_validation_prop_matching(group.hba1c.dataset%>%mutate(intervals = as.numeric(1)), "posthba1cfinal", group.hba1c.dataset$prop.score, quantile_var = "intervals", breakdown = model_variables, adjust = TRUE, order = "largest")
ATE_psm_1_1_adjust_hba1c <- calc_ATE_validation_prop_matching(group.hba1c.dataset%>%mutate(intervals = as.numeric(intervals)), "posthba1cfinal", group.hba1c.dataset$prop.score, quantile_var = "intervals", breakdown = model_variables, adjust = TRUE, order = "largest")
print(ATE_psm_1_1_adjust_hba1c_full[["effects"]], digits =3)
print(ATE_psm_1_1_adjust_hba1c[["effects"]], digits =3)
#-- Adjust
ATE_adjust_hba1c_full <- calc_ATE_validation_adjust(group.hba1c.dataset %>% mutate(intervals = as.numeric(1)), "posthba1cfinal", quantile_var = "intervals", breakdown = model_variables, adjust = TRUE)
ATE_adjust_hba1c <- calc_ATE_validation_adjust(group.hba1c.dataset, "posthba1cfinal", quantile_var = "intervals", breakdown = model_variables, adjust = TRUE)
print(ATE_adjust_hba1c_full[["effects"]], digits =3)
print(ATE_adjust_hba1c[["effects"]], digits =3)
# Strata by sex
group.hba1c.dataset.male <- group.hba1c.dataset %>% filter(sex == "Male")
group.hba1c.dataset.female <- group.hba1c.dataset %>% filter(sex == "Female")
#-- PSM
#------ Male
ATE_psm_1_1_hba1c_male_full <- calc_ATE_validation_prop_matching(group.hba1c.dataset.male%>%mutate(intervals = as.numeric(1)), "posthba1cfinal", group.hba1c.dataset.male$prop.score, quantile_var = "intervals", adjust = FALSE, order = "largest")
ATE_psm_1_1_hba1c_male <- calc_ATE_validation_prop_matching(group.hba1c.dataset.male%>%mutate(intervals = as.numeric(intervals)), "posthba1cfinal", group.hba1c.dataset.male$prop.score, quantile_var = "intervals", adjust = FALSE, order = "largest")
print(ATE_psm_1_1_hba1c_male_full[["effects"]], digits =3)
print(ATE_psm_1_1_hba1c_male[["effects"]], digits =3)
#------ Female
ATE_psm_1_1_hba1c_female_full <- calc_ATE_validation_prop_matching(group.hba1c.dataset.female%>%mutate(intervals = as.numeric(1)), "posthba1cfinal", group.hba1c.dataset.female$prop.score, quantile_var = "intervals", adjust = FALSE, order = "largest")
ATE_psm_1_1_hba1c_female <- calc_ATE_validation_prop_matching(group.hba1c.dataset.female%>%mutate(intervals = as.numeric(intervals)), "posthba1cfinal", group.hba1c.dataset.female$prop.score, quantile_var = "intervals", adjust = FALSE, order = "largest")
print(ATE_psm_1_1_hba1c_female_full[["effects"]], digits =3)
print(ATE_psm_1_1_hba1c_female[["effects"]], digits =3)
#-- PSM + adjust
#------ Male
ATE_psm_1_1_adjust_hba1c_male_full <- calc_ATE_validation_prop_matching(group.hba1c.dataset.male%>%mutate(intervals = as.numeric(1)), "posthba1cfinal", group.hba1c.dataset.male$prop.score, quantile_var = "intervals", breakdown = model_variables, adjust = TRUE, order = "largest")
ATE_psm_1_1_adjust_hba1c_male <- calc_ATE_validation_prop_matching(group.hba1c.dataset.male%>%mutate(intervals = as.numeric(intervals)), "posthba1cfinal", group.hba1c.dataset.male$prop.score, quantile_var = "intervals", breakdown = model_variables, adjust = TRUE, order = "largest")
print(ATE_psm_1_1_adjust_hba1c_male_full[["effects"]], digits =3)
print(ATE_psm_1_1_adjust_hba1c_male[["effects"]], digits =3)
#------ Female
ATE_psm_1_1_adjust_hba1c_female_full <- calc_ATE_validation_prop_matching(group.hba1c.dataset.female%>%mutate(intervals = as.numeric(1)), "posthba1cfinal", group.hba1c.dataset.female$prop.score, quantile_var = "intervals", breakdown = model_variables, adjust = TRUE, order = "largest")
ATE_psm_1_1_adjust_hba1c_female <- calc_ATE_validation_prop_matching(group.hba1c.dataset.female%>%mutate(intervals = as.numeric(intervals)), "posthba1cfinal", group.hba1c.dataset.female$prop.score, quantile_var = "intervals", breakdown = model_variables, adjust = TRUE, order = "largest")
print(ATE_psm_1_1_adjust_hba1c_female_full[["effects"]], digits =3)
print(ATE_psm_1_1_adjust_hba1c_female[["effects"]], digits =3)
#-- Adjust
#------ Male
ATE_adjust_hba1c_male_full <- calc_ATE_validation_adjust(group.hba1c.dataset.male%>%mutate(intervals = as.numeric(1)), "posthba1cfinal", quantile_var = "intervals", breakdown = model_variables, adjust = TRUE)
ATE_adjust_hba1c_male <- calc_ATE_validation_adjust(group.hba1c.dataset.male, "posthba1cfinal", quantile_var = "intervals", breakdown = model_variables, adjust = TRUE)
print(ATE_adjust_hba1c_male_full[["effects"]], digits =3)
print(ATE_adjust_hba1c_male[["effects"]], digits =3)
#------ Female
ATE_adjust_hba1c_female_full <- calc_ATE_validation_adjust(group.hba1c.dataset.female%>%mutate(intervals = as.numeric(1)), "posthba1cfinal", quantile_var = "intervals", breakdown = model_variables, adjust = TRUE)
ATE_adjust_hba1c_female <- calc_ATE_validation_adjust(group.hba1c.dataset.female, "posthba1cfinal", quantile_var = "intervals", breakdown = model_variables, adjust = TRUE)
print(ATE_adjust_hba1c_female_full[["effects"]], digits =3)
print(ATE_adjust_hba1c_female[["effects"]], digits =3)
## Scotland
# THIS IS STILL MISSING, NEEDS TO BE SOLVED
## America Vets dataset
# THIS IS STILL MISSING, NEEDS TO BE SOLVED
### Weight
## CPRD
# Full dataset
## Read in data for weight
weight.dataset <- set_up_data_sglt2_glp1(dataset.type = "weight.dataset") %>%
left_join(patient_prop_scores, by = c("patid", "pated")) %>%
left_join(treatment_effects, by = c("patid", "pated")) %>%
mutate(w.change = postweight - preweight)
group.weight.dataset <- group_values(data = weight.dataset,
variable = "effects",
breaks = interval_breaks) %>%
drop_na(intervals)
#-- PSM
predictions_weight_stan_psm_1_1_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_weight_stan_psm_1_1_full.rds"))
predictions_weight_stan_psm_1_1_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_weight_stan_psm_1_1_overall.rds"))
print(predictions_weight_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_weight_stan_psm_1_1_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
predictions_weight_stan_psm_1_1_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_weight_stan_psm_1_1_adjusted_full.rds"))
predictions_weight_stan_psm_1_1_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_weight_stan_psm_1_1_adjusted_overall.rds"))
print(predictions_weight_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_weight_stan_psm_1_1_adjusted_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
predictions_weight_stan_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_weight_stan_adjusted_full.rds"))
predictions_weight_stan_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_weight_stan_adjusted_overall.rds"))
print(predictions_weight_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_weight_stan_adjusted_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
# Strata by sex
#-- PSM
#------ Male
predictions_weight_stan_psm_1_1_full
predictions_weight_stan_psm_1_1 <- readRDS(paste0(output_path, "/additional_outcomes/predictions_weight_stan_psm_1_1.rds"))
print(predictions_weight_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_weight_stan_psm_1_1%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_weight_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_weight_stan_psm_1_1%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
#------ Male
predictions_weight_stan_psm_1_1_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_weight_stan_psm_1_1_adjusted.rds"))
print(predictions_weight_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_weight_stan_psm_1_1_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_weight_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_weight_stan_psm_1_1_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
#------ Male
predictions_weight_stan_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_weight_stan_adjusted.rds"))
print(predictions_weight_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_weight_stan_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_weight_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_weight_stan_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
### eGFR
## CPRD
# Full dataset
#-- PSM
predictions_egfr_stan_psm_1_1_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_egfr_stan_psm_1_1_full.rds"))
predictions_egfr_stan_psm_1_1_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_egfr_stan_psm_1_1_overall.rds"))
print(predictions_egfr_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_egfr_stan_psm_1_1_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
predictions_egfr_stan_psm_1_1_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_egfr_stan_psm_1_1_adjusted_full.rds"))
predictions_egfr_stan_psm_1_1_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_egfr_stan_psm_1_1_adjusted_overall.rds"))
print(predictions_egfr_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_egfr_stan_psm_1_1_adjusted_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
predictions_egfr_stan_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_egfr_stan_adjusted_full.rds"))
predictions_egfr_stan_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_egfr_stan_adjusted_overall.rds"))
print(predictions_egfr_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_egfr_stan_adjusted_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
# Strata by sex
#-- PSM
#------ Male
predictions_egfr_stan_psm_1_1_full
predictions_egfr_stan_psm_1_1 <- readRDS(paste0(output_path, "/additional_outcomes/predictions_egfr_stan_psm_1_1.rds"))
print(predictions_egfr_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_egfr_stan_psm_1_1%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_egfr_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_egfr_stan_psm_1_1%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
#------ Male
predictions_egfr_stan_psm_1_1_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_egfr_stan_psm_1_1_adjusted.rds"))
print(predictions_egfr_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_egfr_stan_psm_1_1_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_egfr_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_egfr_stan_psm_1_1_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
#------ Male
predictions_egfr_stan_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_egfr_stan_adjusted.rds"))
print(predictions_egfr_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_egfr_stan_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_egfr_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_egfr_stan_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
### Discontinuation
## CPRD
discontinuation.dataset <- set_up_data_sglt2_glp1(dataset.type = "discontinuation.dataset") %>%
left_join(patient_prop_scores, by = c("patid", "pated")) %>%
left_join(treatment_effects, by = c("patid", "pated")) %>%
mutate(stopdrug_6m_3mFU = factor(stopdrug_6m_3mFU))
group.discontinuation.dataset <- group_values(data = discontinuation.dataset,
variable = "effects",
breaks = interval_breaks) %>%
drop_na(intervals)
# Full dataset
#-- PSM
predictions_discontinuation_stan_psm_1_1_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_discontinuation_stan_psm_1_1_full.rds"))
predictions_discontinuation_stan_psm_1_1_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_discontinuation_stan_psm_1_1_overall.rds"))
print(predictions_discontinuation_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_discontinuation_stan_psm_1_1_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
predictions_discontinuation_stan_psm_1_1_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_discontinuation_stan_psm_1_1_adjusted_full.rds"))
predictions_discontinuation_stan_psm_1_1_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_discontinuation_stan_psm_1_1_adjusted_overall.rds"))
print(predictions_discontinuation_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_discontinuation_stan_psm_1_1_adjusted_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
predictions_discontinuation_stan_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_discontinuation_stan_adjusted_full.rds"))
predictions_discontinuation_stan_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_discontinuation_stan_adjusted_overall.rds"))
print(predictions_discontinuation_stan_adjusted_full%>%mutate(mean = as.numeric(mean)*100, lci = as.numeric(lci)*100, uci = as.numeric(uci)*100), digits = 3)
print(predictions_discontinuation_stan_adjusted_overall%>%mutate(mean = as.numeric(mean)*100, lci = as.numeric(lci)*100, uci = as.numeric(uci)*100), digits = 3)
# Strata by sex
#-- PSM
#------ Male
predictions_discontinuation_stan_psm_1_1_full
predictions_discontinuation_stan_psm_1_1 <- readRDS(paste0(output_path, "/additional_outcomes/predictions_discontinuation_stan_psm_1_1.rds"))
print(predictions_discontinuation_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_discontinuation_stan_psm_1_1%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_discontinuation_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_discontinuation_stan_psm_1_1%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
#------ Male
predictions_discontinuation_stan_psm_1_1_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_discontinuation_stan_psm_1_1_adjusted.rds"))
print(predictions_discontinuation_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_discontinuation_stan_psm_1_1_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_discontinuation_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_discontinuation_stan_psm_1_1_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
#------ Male
predictions_discontinuation_stan_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_discontinuation_stan_adjusted.rds"))
print(predictions_discontinuation_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_discontinuation_stan_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_discontinuation_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_discontinuation_stan_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
### CVD
## CPRD
# Full dataset
patient_prop_scores_qrisk <- readRDS(paste0(output_path, "/additional_outcomes/patient_prop_scores_qrisk.rds"))
no_co.dataset <- set_up_data_sglt2_glp1(dataset.type="no_co.dataset") %>%
left_join(patient_prop_scores_qrisk, by = c("patid", "pated")) %>%
left_join(treatment_effects, by = c("patid", "pated"))
group.no_co.dataset <- group_values(data = no_co.dataset,
variable = "effects",
breaks = interval_breaks) %>%
drop_na(intervals)
#-- PSM
predictions_no_co_cvd_stan_psm_1_1_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_cvd_stan_psm_1_1_full.rds"))
predictions_no_co_cvd_stan_psm_1_1_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_cvd_stan_psm_1_1_overall.rds"))
print(predictions_no_co_cvd_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_cvd_stan_psm_1_1_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
predictions_no_co_cvd_stan_psm_1_1_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_cvd_stan_psm_1_1_adjusted_full.rds"))
predictions_no_co_cvd_stan_psm_1_1_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_cvd_stan_psm_1_1_adjusted_overall.rds"))
print(predictions_no_co_cvd_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_cvd_stan_psm_1_1_adjusted_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
predictions_no_co_cvd_stan_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_cvd_stan_adjusted_full.rds"))
predictions_no_co_cvd_stan_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_cvd_stan_adjusted_overall.rds"))
print(predictions_no_co_cvd_stan_adjusted_full%>%mutate(mean = exp(as.numeric(mean)), lci = exp(as.numeric(lci)), uci = exp(as.numeric(uci))), digits = 3)
print(predictions_no_co_cvd_stan_adjusted_overall%>%mutate(mean = exp(as.numeric(mean)), lci = exp(as.numeric(lci)), uci = exp(as.numeric(uci))), digits = 3)
# Strata by sex
#-- PSM
#------ Male
predictions_no_co_cvd_stan_psm_1_1_full
predictions_no_co_cvd_stan_psm_1_1 <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_cvd_stan_psm_1_1.rds"))
print(predictions_no_co_cvd_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_cvd_stan_psm_1_1%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_no_co_cvd_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_cvd_stan_psm_1_1%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
#------ Male
predictions_no_co_cvd_stan_psm_1_1_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_cvd_stan_psm_1_1_adjusted.rds"))
print(predictions_no_co_cvd_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_cvd_stan_psm_1_1_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_no_co_cvd_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_cvd_stan_psm_1_1_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
#------ Male
predictions_no_co_cvd_stan_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_cvd_stan_adjusted.rds"))
print(predictions_no_co_cvd_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_cvd_stan_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_no_co_cvd_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_cvd_stan_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
### Microvascular complications
## CPRD
# Full dataset
patient_prop_scores_qrisk <- readRDS(paste0(output_path, "/additional_outcomes/patient_prop_scores_qrisk.rds"))
micro_comp.dataset <- set_up_data_sglt2_glp1(dataset.type="micro_comp.dataset") %>%
left_join(patient_prop_scores_qrisk, by = c("patid", "pated")) %>%
left_join(treatment_effects, by = c("patid", "pated"))
group.micro_comp.dataset <- group_values(data = micro_comp.dataset,
variable = "effects",
breaks = interval_breaks) %>%
drop_na(intervals)
# predictions for the Microvascular complications outcomes in the population with no Microvascular complications
predictions_micro_comp_micro_comp_stan_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_micro_comp_micro_comp_stan_adjusted_overall.rds"))
# predictions for the Microvascular complications outcomes in the population with no Microvascular complications
predictions_micro_comp_micro_comp_stan_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_micro_comp_micro_comp_stan_adjusted_full.rds"))
print(predictions_micro_comp_micro_comp_stan_adjusted_full%>%mutate(mean = exp(as.numeric(mean)), lci = exp(as.numeric(lci)), uci = exp(as.numeric(uci))), digits = 2)
print(predictions_micro_comp_micro_comp_stan_adjusted_overall%>%mutate(mean = exp(as.numeric(mean)), lci = exp(as.numeric(lci)), uci = exp(as.numeric(uci))), digits = 2)
### HF
## CPRD
# Full dataset
#-- PSM
predictions_no_co_hf_stan_psm_1_1_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_hf_stan_psm_1_1_full.rds"))
predictions_no_co_hf_stan_psm_1_1_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_hf_stan_psm_1_1_overall.rds"))
print(predictions_no_co_hf_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_hf_stan_psm_1_1_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
predictions_no_co_hf_stan_psm_1_1_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_hf_stan_psm_1_1_adjusted_full.rds"))
predictions_no_co_hf_stan_psm_1_1_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_hf_stan_psm_1_1_adjusted_overall.rds"))
print(predictions_no_co_hf_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_hf_stan_psm_1_1_adjusted_overall%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
predictions_no_co_hf_stan_adjusted_full <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_hf_stan_adjusted_full.rds"))
predictions_no_co_hf_stan_adjusted_overall <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_hf_stan_adjusted_overall.rds"))
print(predictions_no_co_hf_stan_adjusted_full%>%mutate(mean = exp(as.numeric(mean)), lci = exp(as.numeric(lci)), uci = exp(as.numeric(uci))), digits = 2)
print(predictions_no_co_hf_stan_adjusted_overall%>%mutate(mean = exp(as.numeric(mean)), lci = exp(as.numeric(lci)), uci = exp(as.numeric(uci))), digits = 2)
# Strata by sex
#-- PSM
#------ Male
predictions_no_co_hf_stan_psm_1_1_full
predictions_no_co_hf_stan_psm_1_1 <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_hf_stan_psm_1_1.rds"))
print(predictions_no_co_hf_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_hf_stan_psm_1_1%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_no_co_hf_stan_psm_1_1_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_hf_stan_psm_1_1%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- PSM + adjust
#------ Male
predictions_no_co_hf_stan_psm_1_1_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_hf_stan_psm_1_1_adjusted.rds"))
print(predictions_no_co_hf_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_hf_stan_psm_1_1_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_no_co_hf_stan_psm_1_1_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_hf_stan_psm_1_1_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#-- Adjust
#------ Male
predictions_no_co_hf_stan_adjusted <- readRDS(paste0(output_path, "/additional_outcomes/predictions_no_co_hf_stan_adjusted.rds"))
print(predictions_no_co_hf_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_hf_stan_adjusted%>%filter(sex=="Male")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
#------ Female
print(predictions_no_co_hf_stan_adjusted_full%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
print(predictions_no_co_hf_stan_adjusted%>%filter(sex=="Female")%>%mutate(mean = as.numeric(mean), lci = as.numeric(lci), uci = as.numeric(uci)), digits = 3)
### CKD
#-- Adjust
# predictions for the CKD - stage 3/4/5 outcomes in the population with no CVD/HF/CKD
predictions_no_co_egfr40_or_ckd5_stan_adjusted_overall <- readRDS("Samples/SGLT2-GLP1/Aurum/additional_outcomes/predictions_no_co_egfr40_or_ckd5_stan_adjusted_overall.rds")
# predictions for the CKD - stage 3/4/5 outcomes in the population with no CVD/HF/CKD
predictions_no_co_egfr40_or_ckd5_stan_adjusted_full <- readRDS("Samples/SGLT2-GLP1/Aurum/additional_outcomes/predictions_no_co_egfr40_or_ckd5_stan_adjusted_full.rds")
print(predictions_no_co_egfr40_or_ckd5_stan_adjusted_full%>%mutate(mean = exp(as.numeric(mean)), lci = exp(as.numeric(lci)), uci = exp(as.numeric(uci))), digits = 2)
print(predictions_no_co_egfr40_or_ckd5_stan_adjusted_overall%>%mutate(mean = exp(as.numeric(mean)), lci = exp(as.numeric(lci)), uci = exp(as.numeric(uci))), digits = 2)