-
Notifications
You must be signed in to change notification settings - Fork 0
/
IPECAD open-source model.R
1520 lines (1315 loc) · 71.3 KB
/
IPECAD open-source model.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
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
######################################## INFORMATION ########################################
# see readme.md on https://github.com/ronhandels/IPECAD for details
######################################## MANUAL PREPARATION ########################################
# install.packages("dampack") # remove '#' at beginning of the line and run once to install this package
setwd("~/GitHub/IPECAD") # if needed, change to the directory to the folder in which the R code and the life table folder is located
######################################## TECHNICAL PREPARATION ########################################
cat("\014") # clear console
rm(list = ls()) # clear environment
library(dampack) # load package
######################################## 1. INPUTS ########################################
######################################## 1.1. ESTIMATED ########################################
# U.S. general population life table 2019 from ssa.gov
## import life table and select only men/women and drop age column (make sure age corresponds to row number, i.e., start with age = 1)
m.lifetable_US_2019 <- as.matrix(read.csv(file="life_tables/lifetable_US_2019_ssa.csv", header=TRUE))[,c("male","female")]
## convert probability to rate
m.mortality_rate_US_2019 <- -log(1-(m.lifetable_US_2019))
## weight rate for male and female
m.mortality_rate_US_2019 <- cbind(m.mortality_rate_US_2019, weighted=NA)
m.mortality_rate_US_2019[,"weighted"] <- m.mortality_rate_US_2019[,"male"] * 0.48 + m.mortality_rate_US_2019[,"female"] * 0.52
# U.S. general population life table 2016 from cdc.gov
m.lifetable_US_2016 <- as.matrix(read.csv(file="life_tables/lifetable_US_2016.csv", header=TRUE))[,c("male","female","total")]
## convert probability to rate
m.mortality_rate_US_2016 <- -log(1-(m.lifetable_US_2016))
## weight rate for male and female
m.mortality_rate_US_2016 <- cbind(m.mortality_rate_US_2016, weighted=NA)
m.mortality_rate_US_2016[,"weighted"] <- m.mortality_rate_US_2016[,"male"] * (1-0.446) + m.mortality_rate_US_2016[,"female"] * 0.446
######################################## 1.2. MODEL INPUTS LIST ########################################
######################################## 1.2.1. INPUTS: CROSS-VALIDATION ICER ########################################
# input parameters (see readme for details)
l.inputs_icer <- list(
v.names_state = c("mcion_c","mciof_c","milon_c","milof_c","mod_c","sev_c","mci_i","mil_i","mod_i","sev_i","dth"), # disease states: mci = mild cognitive impairment; mil = mild dementia; mod = moderate dementia; sev = severe dementia; dth = dead; x_i = living in institutional setting (without '_i' = living in community)
v.names_strat = c("soc","int"), # strategies: soc = standard of care; int = intervention
age_start = 71,
sex = "weighted",
p.starting_state_mci = 0.55,
n.cycle = 29,
p.mci_mil = 0.23,
p.mci_mod = 0,
p.mci_sev = 0,
p.mil_mci = 0.03,
p.mil_mod = 0.35,
p.mil_sev = 0.04,
p.mod_mil = 0.03,
p.mod_sev = 0.42,
p.sev_mil = 0,
p.sev_mod = 0.02,
p.mci_i = 0.024,
p.mil_i = 0.038,
p.mod_i = 0.110,
p.sev_i = 0.259,
m.r.mortality = m.mortality_rate_US_2019,
hr.mort_mci = 1.82,
hr.mort_mil = 2.92,
hr.mort_mod = 3.85,
hr.mort_sev = 9.52,
rr.tx_mci_mil = 0.69,
rr.tx_mci_mod = 1,
rr.tx_mci_sev = 1,
rr.tx_mil_mod = 0.69,
rr.tx_mil_sev = 0.69,
rr.tx_mci_mil_dis = 1,
rr.tx_mci_mod_dis = 1,
rr.tx_mci_sev_dis = 1,
rr.tx_mil_mod_dis = 1,
rr.tx_mil_sev_dis = 1,
p.tx_discontinuation1 = 0.069,
p.tx_discontinuation2 = 0,
tx_discontinuation2_begin = 2,
tx_duration = 29,
tx_waning = 0,
tx_waning_dis = 0,
u.mci_pt = 0.851 - 0.17,
u.mil_pt = 0.851 - 0.22,
u.mod_pt = 0.851 - 0.36,
u.sev_pt = 0.851 - 0.53,
u.mci_pt_i = 0.851 - 0.17,
u.mil_pt_i = 0.851 - 0.19,
u.mod_pt_i = 0.851 - 0.42,
u.sev_pt_i = 0.851 - 0.59,
u.mci_ic = -0.03,
u.mil_ic = -0.05,
u.mod_ic = -0.08,
u.sev_ic = -0.10,
u.mci_ic_i = -0.03,
u.mil_ic_i = -0.05,
u.mod_ic_i = -0.08,
u.sev_ic_i = -0.10,
u.Tx_start = -0.14 * (12/52) * 0.035, # disutility symptomatic ARIA multiplied by average duration (12 weeks) multiplied by prevalence symptomatic ARIA (3.5%)
c.mci_hc = 6042*1.12 + 460,
c.mil_hc = 6042*1.56 + 965 + 0.21*365*0.333, # patient medical + informal carer medical + ChEI
c.mod_hc = 6042*1.93 + 1544 + 0.66*365*0.333,
c.sev_hc = 6042*1.93 + 1930,
c.mci_hc_i = 6042*1.12 + 460,
c.mil_hc_i = 6042*1.56 + 965 + 0.21*365*0.333,
c.mod_hc_i = 6042*1.93 + 1544 + 0.66*365*0.333,
c.sev_hc_i = 6042*1.93 + 1930,
c.mci_sc = 0,
c.mil_sc = 0,
c.mod_sc = 0,
c.sev_sc = 0,
c.mci_sc_i = 7394*12,
c.mil_sc_i = 7394*12,
c.mod_sc_i = 7394*12,
c.sev_sc_i = 7394*12,
c.mci_ic = 69*12*32.46 + 0.204*0.049*20*52*32.46, # informal care + patient productivity loss
c.mil_ic = 113*12*32.46 + 0.112*0.086*20*52*32.46,
c.mod_ic = 169*12*32.46,
c.sev_ic = 298*12*32.46,
c.mci_ic_i = 69*12*32.46*0.44 + 0.204*0.049*20*52*32.46,
c.mil_ic_i = 113*12*32.46*0.44 + 0.112*0.086*20*52*32.46,
c.mod_ic_i = 169*12*32.46*0.44,
c.sev_ic_i = 298*12*32.46*0.44,
c.Tx = 26500 + (52/2)*78.35, # drug annual wholesale acquisition cost + treatment administration frequency * administration cost
c.Tx_start = 261.10*4 + 261.10*3*0.215, # mri cost * 3-month monitoring in year 1 + mri cost * 3 times * proportion aria
discount_EFFECT = 0.03,
discount_QALY = 0.03,
discount_COST = 0.03,
wtp = 100000,
half_cycle_correction = TRUE
)
######################################## 1.2.1. INPUTS: CROSS-VALIDATION AD-ACE ########################################
# input parameters (see readme for details)
l.inputs_adace <- list(
v.names_state = c("mcion_c","mciof_c","milon_c","milof_c","mod_c","sev_c","mci_i","mil_i","mod_i","sev_i","dth"), # disease states: mci = mild cognitive impairment; mil = mild dementia; mod = moderate dementia; sev = severe dementia; dth = dead; x_i = living in institutional setting (without '_i' = living in community)
v.names_strat = c("soc","int"),
age_start = 73,
sex = "weighted",
p.starting_state_mci = 0.781,
n.cycle = 27,
p.mci_mil = 0.23,
p.mci_mod = 0,
p.mci_sev = 0,
p.mil_mci = 0.03,
p.mil_mod = 0.35,
p.mil_sev = 0.04,
p.mod_mil = 0.03,
p.mod_sev = 0.42,
p.sev_mil = 0,
p.sev_mod = 0.02,
p.mci_i = 0,
p.mil_i = 0.038,
p.mod_i = 0.110,
p.sev_i = 0.259,
m.r.mortality = m.mortality_rate_US_2016,
hr.mort_mci = 1,
hr.mort_mil = 2.92,
hr.mort_mod = 3.85,
hr.mort_sev = 9.52,
rr.tx_mci_mil = 0.69,
rr.tx_mci_mod = 1,
rr.tx_mci_sev = 1,
rr.tx_mil_mod = 0.69,
rr.tx_mil_sev = 0.69,
rr.tx_mci_mil_dis = 1,
rr.tx_mci_mod_dis = 1,
rr.tx_mci_sev_dis = 1,
rr.tx_mil_mod_dis = 1,
rr.tx_mil_sev_dis = 1,
p.tx_discontinuation1 = 0.13,
p.tx_discontinuation2 = 0,
tx_discontinuation2_begin = 27,
tx_duration = 27,
tx_waning = 0,
tx_waning_dis = 0,
u.mci_pt = 0.80,
u.mil_pt = 0.74,
u.mod_pt = 0.59,
u.sev_pt = 0.36,
u.mci_pt_i = 0.80,
u.mil_pt_i = 0.74,
u.mod_pt_i = 0.59,
u.sev_pt_i = 0.36,
u.mci_ic = -0,
u.mil_ic = -0.036,
u.mod_ic = -0.070,
u.sev_ic = -0.086,
u.mci_ic_i = -0,
u.mil_ic_i = -0.036,
u.mod_ic_i = -0.070,
u.sev_ic_i = -0.086,
u.Tx_start = -0.14 * (12/52) * 0.126, # disutility ARIA-E multiplied by average duration (12 weeks) multiplied by prevalence ARIA-E (22%)
c.mci_hc = 1254*12,
c.mil_hc = 1471*12,
c.mod_hc = 1958*12,
c.sev_hc = 2250*12,
c.mci_hc_i = 1254*12,
c.mil_hc_i = 1471*12,
c.mod_hc_i = 1958*12,
c.sev_hc_i = 2250*12,
c.mci_sc = 222*12,
c.mil_sc = 410*12,
c.mod_sc = 653*12,
c.sev_sc = 1095*12,
c.mci_sc_i = 8762*12,
c.mil_sc_i = 8762*12,
c.mod_sc_i = 8762*12,
c.sev_sc_i = 8762*12,
c.mci_ic = 754*12 + 988*12, # caregiver healthcare + caregiver informal care
c.mil_ic = 781*12 + 2184*12,
c.mod_ic = 799*12 + 3227*12,
c.sev_ic = 811*12 + 5402*12,
c.mci_ic_i = 754*12 + 435*12,
c.mil_ic_i = 781*12 + 961*12,
c.mod_ic_i = 799*12 + 1420*12,
c.sev_ic_i = 811*12 + 2377*12,
c.Tx = 0,
c.Tx_start = 212.14 * 5 + 0.126 * 0.78 * 212.14 * 2 + 0.126 * 0.22 * 0.91 * 796.80 + 0.126 * 0.22 * (1-0.91) * 1098.27, # monitoring (5x MRI in year 1) and ARIA-E (12.6%) being asymptomatic (78%) (2x MRI), symptomatic (22%) mild/moderate (91%) or symptomatic severe (9%)
discount_EFFECT = 0.03,
discount_QALY = 0.03,
discount_COST = 0.03,
wtp = 100000,
half_cycle_correction = TRUE
)
######################################## 2. RUN MODEL ########################################
# The model is run using 2 functions: run function `f.run_strategy` and run function `f.run_scenario`.
# The second function (`f.run_scenario`) includes a loop over all strategies by calling them one by one.
# Overall, the code follows these steps:
# A: function to run a scenario
# B: prepare and initialize objects to store scenario and strategy outcomes
# C: run each strategy in a loop
# D: prepare inputs to be used in each strategy
# E: run preparations specific for the intervention strategy
# F: store newly created or updated inputs to be used for the function to run a single strategy
# G: function to run the strategy
# G1: prepare transition probability matrix
# G2: some checks
# G3: initialize objects to store strategy outcomes
# G4: starting state
# G5: markov multiplication by looping over cycles
# G6: multiply states with utility and cost estimates
# G7: half-cycle correction
# G8: discount QALYs and costs
# G9: store outcomes to be wrapped up by the 'run scenario' function
# H: store strategy results
# I: add strategy results to scenario outcomes
# Standard naming for objects is ‘x.object_name’, with x:
# v = vector
# m = matrix
# a = array
# l = list
# df = data frame
# f = function
# temp = temporary object
# p = probability or proportion
# r = rate
# rr = relative risk or relative rate
# hr = hazard ratio
# n = number
# u = utility
# c = cost
# This is inspired by recommendations by https://github.com/DARTH-git/darthpack (https://doi.org/10.1007/s40273-019-00837-x table 3).
######################################## 2.1. RUN STRATEGY (STEP G1-G8) ########################################
# run strategy (STEP G: function for running a strategy)
f.run_strategy <- function(l.inputs) {
with(as.list(l.inputs), {
# initialize time-dependent TP matrix (STEP G1: prepare transition probability matrix)
a.TP <- array(data = 0, dim = c(n.state, n.state, n.cycle), dimnames = list(v.names_state,v.names_state,NULL))
# TP matrix state: to death
a.TP["mcion_c","dth",] <- 1-exp(-(v.r.dth * hr.mort_mci))
a.TP["mciof_c","dth",] <- 1-exp(-(v.r.dth * hr.mort_mci))
a.TP["milon_c","dth",] <- 1-exp(-(v.r.dth * hr.mort_mil))
a.TP["milof_c","dth",] <- 1-exp(-(v.r.dth * hr.mort_mil))
a.TP["mod_c", "dth",] <- 1-exp(-(v.r.dth * hr.mort_mod))
a.TP["sev_c", "dth",] <- 1-exp(-(v.r.dth * hr.mort_sev))
a.TP["dth" , "dth",] <- 1
a.TP["mci_i" ,"dth",] <- 1-exp(-(v.r.dth * hr.mort_mci))
a.TP["mil_i" ,"dth",] <- 1-exp(-(v.r.dth * hr.mort_mil))
a.TP["mod_i" ,"dth",] <- 1-exp(-(v.r.dth * hr.mort_mod))
a.TP["sev_i" ,"dth",] <- 1-exp(-(v.r.dth * hr.mort_sev))
# TP matrix state: from mci-on community-setting
a.TP["mcion_c","mcion_c",] <- v.p.mcion_mci * (1-p.mci_i) * (1-v.p.discontinuation) * (1-a.TP["mcion_c","dth",])
a.TP["mcion_c","mciof_c",] <- v.p.mcion_mci * (1-p.mci_i) * v.p.discontinuation * (1-a.TP["mcion_c","dth",])
a.TP["mcion_c","milon_c",] <- v.p.mcion_mil * (1-p.mci_i) * (1-v.p.discontinuation) * (1-a.TP["mcion_c","dth",])
a.TP["mcion_c","milof_c",] <- v.p.mcion_mil * (1-p.mci_i) * v.p.discontinuation * (1-a.TP["mcion_c","dth",])
a.TP["mcion_c","mod_c",] <- v.p.mcion_mod * (1-p.mci_i) * (1-a.TP["mcion_c","dth",])
a.TP["mcion_c","sev_c",] <- v.p.mcion_sev * (1-p.mci_i) * (1-a.TP["mcion_c","dth",])
a.TP["mcion_c","mci_i",] <- v.p.mcion_mci * p.mci_i * (1-a.TP["mcion_c","dth",])
a.TP["mcion_c","mil_i",] <- v.p.mcion_mil * p.mci_i * (1-a.TP["mcion_c","dth",])
a.TP["mcion_c","mod_i",] <- v.p.mcion_mod * p.mci_i * (1-a.TP["mcion_c","dth",])
a.TP["mcion_c","sev_i",] <- v.p.mcion_sev * p.mci_i * (1-a.TP["mcion_c","dth",])
# TP matrix state: from mci-off community-setting
a.TP["mciof_c","mciof_c",] <- v.p.mci_mci * (1-p.mci_i) * (1-a.TP["mciof_c","dth",])
a.TP["mciof_c","milof_c",] <- v.p.mci_mil * (1-p.mci_i) * (1-a.TP["mciof_c","dth",])
a.TP["mciof_c","mod_c",] <- v.p.mci_mod * (1-p.mci_i) * (1-a.TP["mciof_c","dth",])
a.TP["mciof_c","sev_c",] <- v.p.mci_sev * (1-p.mci_i) * (1-a.TP["mciof_c","dth",])
a.TP["mciof_c","mci_i",] <- v.p.mci_mci * p.mci_i * (1-a.TP["mciof_c","dth",])
a.TP["mciof_c","mil_i",] <- v.p.mci_mil * p.mci_i * (1-a.TP["mciof_c","dth",])
a.TP["mciof_c","mod_i",] <- v.p.mci_mod * p.mci_i * (1-a.TP["mciof_c","dth",])
a.TP["mciof_c","sev_i",] <- v.p.mci_sev * p.mci_i * (1-a.TP["mciof_c","dth",])
# TP matrix state: from mild-on community-setting
a.TP["milon_c","mcion_c",] <- v.p.milon_mci * (1-p.mil_i) * (1-v.p.discontinuation) * (1-a.TP["milon_c","dth",])
a.TP["milon_c","mciof_c",] <- v.p.milon_mci * (1-p.mil_i) * v.p.discontinuation * (1-a.TP["milon_c","dth",])
a.TP["milon_c","milon_c",] <- v.p.milon_mil * (1-p.mil_i) * (1-v.p.discontinuation) * (1-a.TP["milon_c","dth",])
a.TP["milon_c","milof_c",] <- v.p.milon_mil * (1-p.mil_i) * v.p.discontinuation * (1-a.TP["milon_c","dth",])
a.TP["milon_c","mod_c",] <- v.p.milon_mod * (1-p.mil_i) * (1-a.TP["milon_c","dth",])
a.TP["milon_c","sev_c",] <- v.p.milon_sev * (1-p.mil_i) * (1-a.TP["milon_c","dth",])
a.TP["milon_c","mci_i",] <- v.p.milon_mci * p.mil_i * (1-a.TP["milon_c","dth",])
a.TP["milon_c","mil_i",] <- v.p.milon_mil * p.mil_i * (1-a.TP["milon_c","dth",])
a.TP["milon_c","mod_i",] <- v.p.milon_mod * p.mil_i * (1-a.TP["milon_c","dth",])
a.TP["milon_c","sev_i",] <- v.p.milon_sev * p.mil_i * (1-a.TP["milon_c","dth",])
# TP matrix state: from mild-off community-setting
a.TP["milof_c","mciof_c",] <- v.p.mil_mci * (1-p.mil_i) * (1-a.TP["milof_c","dth",])
a.TP["milof_c","milof_c",] <- v.p.mil_mil * (1-p.mil_i) * (1-a.TP["milof_c","dth",])
a.TP["milof_c","mod_c",] <- v.p.mil_mod * (1-p.mil_i) * (1-a.TP["milof_c","dth",])
a.TP["milof_c","sev_c",] <- v.p.mil_sev * (1-p.mil_i) * (1-a.TP["milof_c","dth",])
a.TP["milof_c","mci_i",] <- v.p.mil_mci * p.mil_i * (1-a.TP["milof_c","dth",])
a.TP["milof_c","mil_i",] <- v.p.mil_mil * p.mil_i * (1-a.TP["milof_c","dth",])
a.TP["milof_c","mod_i",] <- v.p.mil_mod * p.mil_i * (1-a.TP["milof_c","dth",])
a.TP["milof_c","sev_i",] <- v.p.mil_sev * p.mil_i * (1-a.TP["milof_c","dth",])
# TP matrix state: from moderate community-setting
a.TP["mod_c","milof_c",] <- v.p.mod_mil * (1-p.mod_i) * (1-a.TP["mod_c","dth",])
a.TP["mod_c","mod_c",] <- v.p.mod_mod * (1-p.mod_i) * (1-a.TP["mod_c","dth",])
a.TP["mod_c","sev_c",] <- v.p.mod_sev * (1-p.mod_i) * (1-a.TP["mod_c","dth",])
a.TP["mod_c","mil_i",] <- v.p.mod_mil * p.mod_i * (1-a.TP["mod_c","dth",])
a.TP["mod_c","mod_i",] <- v.p.mod_mod * p.mod_i * (1-a.TP["mod_c","dth",])
a.TP["mod_c","sev_i",] <- v.p.mod_sev * p.mod_i * (1-a.TP["mod_c","dth",])
# TP matrix state: from severe community-setting
a.TP["sev_c","milof_c",] <- v.p.sev_mil * (1-p.sev_i) * (1-a.TP["sev_c","dth",])
a.TP["sev_c","mod_c",] <- v.p.sev_mod * (1-p.sev_i) * (1-a.TP["sev_c","dth",])
a.TP["sev_c","sev_c",] <- v.p.sev_sev * (1-p.sev_i) * (1-a.TP["sev_c","dth",])
a.TP["sev_c","mil_i",] <- v.p.sev_mil * p.sev_i * (1-a.TP["sev_c","dth",])
a.TP["sev_c","mod_i",] <- v.p.sev_mod * p.sev_i * (1-a.TP["sev_c","dth",])
a.TP["sev_c","sev_i",] <- v.p.sev_sev * p.sev_i * (1-a.TP["sev_c","dth",])
# TP matrix state: from mci institutionalized-setting
a.TP["mci_i","mci_i",] <- v.p.mci_mci * (1-a.TP["mci_i","dth",])
a.TP["mci_i","mil_i",] <- v.p.mci_mil * (1-a.TP["mci_i","dth",])
a.TP["mci_i","mod_i",] <- v.p.mci_mod * (1-a.TP["mci_i","dth",])
a.TP["mci_i","sev_i",] <- v.p.mci_sev * (1-a.TP["mci_i","dth",])
# TP matrix state: from mild institutionalized-setting
a.TP["mil_i","mci_i",] <- v.p.mil_mci * (1-a.TP["mil_i","dth",])
a.TP["mil_i","mil_i",] <- v.p.mil_mil * (1-a.TP["mil_i","dth",])
a.TP["mil_i","mod_i",] <- v.p.mil_mod * (1-a.TP["mil_i","dth",])
a.TP["mil_i","sev_i",] <- v.p.mil_sev * (1-a.TP["mil_i","dth",])
# TP matrix state: from moderate institutionalized-setting
a.TP["mod_i","mil_i",] <- v.p.mod_mil * (1-a.TP["mod_i","dth",])
a.TP["mod_i","mod_i",] <- v.p.mod_mod * (1-a.TP["mod_i","dth",])
a.TP["mod_i","sev_i",] <- v.p.mod_sev * (1-a.TP["mod_i","dth",])
# TP matrix state: from severe institutionalized-setting
a.TP["sev_i","mil_i",] <- v.p.sev_mil * (1-a.TP["sev_i","dth",])
a.TP["sev_i","mod_i",] <- v.p.sev_mod * (1-a.TP["sev_i","dth",])
a.TP["sev_i","sev_i",] <- v.p.sev_sev * (1-a.TP["sev_i","dth",])
# check TPs are within 0-1 range
if(any(a.TP<0 | a.TP>1)) stop("one or more transition probabilities are lower than 0 or higher than 1")
# check TPs sum to 1 for each cycle (STEP G2: some checks)
for(i in v.names_state) {
temp1 <- colSums(a.TP[i,,])
if(!isTRUE(all.equal(current = temp1, target = rep(1,n.cycle), tolerance = 1e-10))) stop(paste("TPs for",i,"do not add up to 1"))
}
# initialize state trace (STEP G3: initialize objects to store strategy outcomes)
m.trace <- matrix(data = NA, nrow = n.cycle, ncol = n.state, dimnames = list(NULL,v.names_state))
# initialize output table
m.out <- matrix(data = NA, nrow = n.cycle, ncol = 29, dimnames = list(NULL, c(colnames(m.trace),"qaly_pt","qaly_ic","cost_dx","cost_tx","cost_hc","cost_sc","cost_ic","mci","mil","mod","sev","commun","instit","ontx","ly","qaly","cost","nhb")))
# set starting state distribution (STEP G4: starting state)
m.trace[1,] <- m.trace1
# markov multiplication (STEP G5: markov multiplication by looping over cycles)
for(t in 1:(n.cycle-1)) {
m.trace[t+1,] <- m.trace[t,] %*% a.TP[,,t]
}
# primary economic outputs (STEP G6: multiply states with utility and cost estimates)
m.out[,colnames(m.trace)] <- m.trace
m.out[,"qaly_pt"] <- m.trace %*% c(u.mci_pt, u.mci_pt, u.mil_pt, u.mil_pt, u.mod_pt, u.sev_pt, u.mci_pt_i, u.mil_pt_i, u.mod_pt_i, u.sev_pt_i, 0) # must match order of states
m.out[,"qaly_ic"] <- m.trace %*% c(u.mci_ic, u.mci_ic, u.mil_ic, u.mil_ic, u.mod_ic, u.sev_ic, u.mci_ic_i, u.mil_ic_i, u.mod_ic_i, u.sev_ic_i, 0) # must match order of states
m.out[,"cost_dx"] <- 0
m.out[,"cost_tx"] <- m.trace %*% c(c.Tx , 0 , c.Tx , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0) # must match order of states
m.out[,"cost_hc"] <- m.trace %*% c(c.mci_hc, c.mci_hc, c.mil_hc, c.mil_hc, c.mod_hc, c.sev_hc, c.mci_hc_i, c.mil_hc_i, c.mod_hc_i, c.sev_hc_i, 0) # must match order of states
m.out[,"cost_sc"] <- m.trace %*% c(c.mci_sc, c.mci_sc, c.mil_sc, c.mil_sc, c.mod_sc, c.sev_sc, c.mci_sc_i, c.mil_sc_i, c.mod_sc_i, c.sev_sc_i, 0) # must match order of states
m.out[,"cost_ic"] <- m.trace %*% c(c.mci_ic, c.mci_ic, c.mil_ic, c.mil_ic, c.mod_ic, c.sev_ic, c.mci_ic_i, c.mil_ic_i, c.mod_ic_i, c.sev_ic_i, 0) # must match order of states
# half-cycle correction (STEP G7: apply half-cycle correction)
if(half_cycle_correction) {
for (j in colnames(m.out)) {
for (i in 1:(n.cycle-1)) {
m.out[i,j] <- (m.out[i,j] + m.out[i+1,j]) * 0.5
}
}
m.out <- m.out[-n.cycle,] # remove the last cycle
}
# add additional inputs to cycle 1
if(strat=="int") {
m.out[,"qaly_pt"][1] <- m.out[,"qaly_pt"][1] + u.Tx_start
m.out[,"cost_dx"][1] <- m.out[,"cost_dx"][1] + c.Tx_start
}
# define vector for discounting QALYs and costs (STEP G8: apply discounting)
n <- ifelse(test=half_cycle_correction, yes=2, no=1)
v.discount_EFFECT <- 1 / (( 1 + discount_EFFECT) ^ (0 : (n.cycle-n)))
v.discount_QALY <- 1 / (( 1 + discount_QALY) ^ (0 : (n.cycle-n)))
v.discount_COST <- 1 / (( 1 + discount_COST) ^ (0 : (n.cycle-n)))
# apply discounting
for(i in c(colnames(m.trace),"ly")) {
m.out[,i] <- m.out[,i]*v.discount_EFFECT
}
for(i in c("qaly_pt","qaly_ic")) {
m.out[,i] <- m.out[,i]*v.discount_QALY
}
for(i in c("cost_dx","cost_tx","cost_hc","cost_sc","cost_ic")) {
m.out[,i] <- m.out[,i]*v.discount_COST
}
# totals
m.out[,"mci"] <- rowSums(m.out[,c("mcion_c","mciof_c","mci_i")])
m.out[,"mil"] <- rowSums(m.out[,c("milon_c","milof_c","mil_i")])
m.out[,"mod"] <- rowSums(m.out[,c("mod_c","mod_i")])
m.out[,"sev"] <- rowSums(m.out[,c("sev_c","sev_i")])
m.out[,"commun"] <- rowSums(m.out[,c("mcion_c","mciof_c","milon_c","milof_c","mod_c","sev_c")])
m.out[,"instit"] <- rowSums(m.out[,c("mci_i","mil_i","mod_i","sev_i")])
m.out[,"ontx"] <- rowSums(m.out[,c("mcion_c","milon_c")])
m.out[,"qaly"] <- rowSums(m.out[,c("qaly_pt","qaly_ic")])
m.out[,"cost"] <- rowSums(m.out[,c("cost_dx","cost_tx","cost_hc","cost_sc","cost_ic")])
m.out[,"ly"] <- rowSums(m.out[,c("mci","mil","mod","sev")])
# calculate net health benefit
m.out[,"nhb"] <- m.out[,"qaly"] - (m.out[,"cost"] / wtp)
# store strategy-specific output (STEP G9: store outcomes to be wrapped up by the 'run scenario' function)
return(list(
a.TP = a.TP,
m.trace = m.trace,
m.out = m.out
))
}
)
}
######################################## 2.2. RUN SCENARIO (STEP A-I) ########################################
# run scenario (STEP A: function for running a scenario, mainly to loop over strategies)
f.run_scenario <- function(l.inputs, detailed=FALSE) {
with(as.list(l.inputs), { # the 'with' functions enables to call the items from the list without having to refer to the list each time (one can use 'age_start' instead l.inputs[["age_start"]])
# some validity checks on input estimates
# [to be developed]
# store counters (STEP B: prepare and initialize objects to store scenario and strategy outcomes)
n.state <- length(v.names_state) # number of states
n.strat <- length(v.names_strat) # number of strategies
# initialize output data frame (create an empty data frame to store outcomes of a scenario)
df.out <- data.frame(
strategy = v.names_strat,
QALY = numeric(n.strat),
COST = numeric(n.strat),
LY = numeric(n.strat),
NHB = numeric(n.strat),
row.names = v.names_strat,
stringsAsFactors = FALSE
)
# initialize output list (create empty list to store outcomes of each strategy)
l.out <- vector(mode = "list", length = 0)
# loop over strategies (STEP C: run each strategy in a loop)
for(strat in v.names_strat) {
# convert time-independent transitions to vector of transitions (STEP D: prepare inputs to be used in each strategy)
v.p.mci_mil <- rep(p.mci_mil, n.cycle)
v.p.mci_mod <- rep(p.mci_mod, n.cycle)
v.p.mci_sev <- rep(p.mci_sev, n.cycle)
v.p.mil_mci <- rep(p.mil_mci, n.cycle)
v.p.mil_mod <- rep(p.mil_mod, n.cycle)
v.p.mil_sev <- rep(p.mil_sev, n.cycle)
v.p.mod_mil <- rep(p.mod_mil, n.cycle)
v.p.mod_sev <- rep(p.mod_sev, n.cycle)
v.p.sev_mil <- rep(p.sev_mil, n.cycle)
v.p.sev_mod <- rep(p.sev_mod, n.cycle)
# probability of remaining in the same state (calculated as 1 minus transitions to other states; conditional on survival)
v.p.mci_mci <- 1 - v.p.mci_mil - v.p.mci_mod - v.p.mci_sev
v.p.mil_mil <- 1 - v.p.mil_mci - v.p.mil_mod - v.p.mil_sev
v.p.mod_mod <- 1 - v.p.mod_mil - v.p.mod_sev
v.p.sev_sev <- 1 - v.p.sev_mil - v.p.sev_mod
# copy for on treatment
v.p.mcion_mci <- v.p.mci_mci
v.p.mcion_mil <- v.p.mci_mil
v.p.mcion_mod <- v.p.mci_mod
v.p.mcion_sev <- v.p.mci_sev
v.p.milon_mci <- v.p.mil_mci
v.p.milon_mil <- v.p.mil_mil
v.p.milon_mod <- v.p.mil_mod
v.p.milon_sev <- v.p.mil_sev
# discontinuation
v.p.discontinuation <- rep(x=0, times=n.cycle) # initialize vector
v.p.discontinuation[1:(tx_discontinuation2_begin-1)] <- p.tx_discontinuation1 # discontinuation up to discontinuation2 start cycle
v.p.discontinuation[tx_discontinuation2_begin:n.cycle] <- p.tx_discontinuation2 # discontinuation at discontinuation2 start cycle onward
v.p.discontinuation[tx_duration:n.cycle] <- 1 # maximum treatment duration implemented as discontinuation
# death (subset mortality table to obtain age- and sex-specific mortality)
v.r.dth <- m.r.mortality[age_start:(age_start+n.cycle-1), sex]
# starting states
m.trace1 <- matrix(data=0, nrow=1, ncol=n.state, dimnames=list(NULL,v.names_state))
m.trace1[,"mciof_c"] <- p.starting_state_mci
m.trace1[,"milof_c"] <- 1-p.starting_state_mci
# strategy-specific inputs (STEP E: run preparations specific for the intervention strategy)
if(strat=="int") {
# waning
temp.waning <- (1-tx_waning)^(0:(n.cycle-1))
temp.rr.tx_mci_mil <- rr.tx_mci_mil^temp.waning
temp.rr.tx_mci_mod <- rr.tx_mci_mod^temp.waning
temp.rr.tx_mci_sev <- rr.tx_mci_sev^temp.waning
temp.rr.tx_mil_mod <- rr.tx_mil_mod^temp.waning
temp.rr.tx_mil_sev <- rr.tx_mil_sev^temp.waning
temp.waning_dis <- (1-tx_waning_dis)^(0:(n.cycle-1))
temp.rr.tx_mci_mil_dis <- rr.tx_mci_mil_dis^temp.waning_dis
temp.rr.tx_mci_mod_dis <- rr.tx_mci_mod_dis^temp.waning_dis
temp.rr.tx_mci_sev_dis <- rr.tx_mci_sev_dis^temp.waning_dis
temp.rr.tx_mil_mod_dis <- rr.tx_mil_mod_dis^temp.waning_dis
temp.rr.tx_mil_sev_dis <- rr.tx_mil_sev_dis^temp.waning_dis
# update transition probabilities treatment effect: during treatment
v.p.mcion_mil <- 1-exp(-(-log(1-p.mci_mil) * temp.rr.tx_mci_mil)) # convert probability to rate, then multiply with treatment relative risk, then convert to probability
v.p.mcion_mod <- 1-exp(-(-log(1-p.mci_mod) * temp.rr.tx_mci_mod)) # idem
v.p.mcion_sev <- 1-exp(-(-log(1-p.mci_sev) * temp.rr.tx_mci_sev)) # idem
v.p.milon_mod <- 1-exp(-(-log(1-p.mil_mod) * temp.rr.tx_mil_mod)) # idem
v.p.milon_sev <- 1-exp(-(-log(1-p.mil_sev) * temp.rr.tx_mil_sev)) # idem
# update transition probabilities treatment effect: after discontinuation
v.p.mci_mil <- 1-exp(-(-log(1-p.mci_mil) * temp.rr.tx_mci_mil_dis)) # convert probability to rate, then multiply with treatment relative risk, then convert to probability
v.p.mci_mod <- 1-exp(-(-log(1-p.mci_mod) * temp.rr.tx_mci_mod_dis)) # idem
v.p.mci_sev <- 1-exp(-(-log(1-p.mci_sev) * temp.rr.tx_mci_sev_dis)) # idem
v.p.mil_mod <- 1-exp(-(-log(1-p.mil_mod) * temp.rr.tx_mil_mod_dis)) # idem
v.p.mil_sev <- 1-exp(-(-log(1-p.mil_sev) * temp.rr.tx_mil_sev_dis)) # idem
# update transition probabilities of remaining in the same state
v.p.mcion_mci <- 1 - v.p.mcion_mil - v.p.mcion_mod - v.p.mcion_sev
v.p.milon_mil <- 1 - v.p.milon_mci - v.p.milon_mod - v.p.milon_sev
v.p.mci_mci <- 1 - v.p.mci_mil - v.p.mci_mod - v.p.mci_sev
v.p.mil_mil <- 1 - v.p.mil_mci - v.p.mil_mod - v.p.mil_sev
# starting states
m.trace1 <- matrix(data=0, nrow=1, ncol=n.state, dimnames=list(NULL,v.names_state))
m.trace1[,"mcion_c"] <- p.starting_state_mci
m.trace1[,"milon_c"] <- 1-p.starting_state_mci
}
# list inputs for running each strategy (STEP F: store newly created or updated inputs to be used for the function to run a single strategy)
l.inputs_strategy <- c(l.inputs, list(
strat = strat,
n.state = n.state,
n.strat = n.strat,
n.cycle = n.cycle,
v.p.mci_mil = v.p.mci_mil,
v.p.mci_mod = v.p.mci_mod,
v.p.mci_sev = v.p.mci_sev,
v.p.mil_mci = v.p.mil_mci,
v.p.mil_mod = v.p.mil_mod,
v.p.mil_sev = v.p.mil_sev,
v.p.mod_mil = v.p.mod_mil,
v.p.mod_sev = v.p.mod_sev,
v.p.sev_mil = v.p.sev_mil,
v.p.sev_mod = v.p.sev_mod,
v.p.mci_mci = v.p.mci_mci,
v.p.mil_mil = v.p.mil_mil,
v.p.mod_mod = v.p.mod_mod,
v.p.sev_sev = v.p.sev_sev,
v.p.mcion_mci = v.p.mcion_mci,
v.p.mcion_mil = v.p.mcion_mil,
v.p.mcion_mod = v.p.mcion_mod,
v.p.mcion_sev = v.p.mcion_sev,
v.p.milon_mci = v.p.milon_mci,
v.p.milon_mil = v.p.milon_mil,
v.p.milon_mod = v.p.milon_mod,
v.p.milon_sev = v.p.milon_sev,
v.p.discontinuation = v.p.discontinuation,
v.r.dth = v.r.dth,
m.trace1 = m.trace1
))
# run strategy (STEP G: run the strategy)
l.strat <- f.run_strategy(l.inputs_strategy)
# store strategy-specific output (STEP H store strategy results)
l.out[[strat]] <- l.strat
# store output (STEP I add strategy results to scenario outcomes)
m.out <- l.strat[["m.out"]] # extract cycle-specific outcomes
df.out[strat,"strategy"] <- strat # store strategy name
df.out[strat,"QALY"] <- sum(m.out[,"qaly"]) # calculate total QALYs and store them
df.out[strat,"COST"] <- sum(m.out[,"cost"]) # calculate total costs and store them
df.out[strat,"LY"] <- sum(m.out[,"ly"]) # calculate total live years and store them
df.out[strat,"NHB"] <- sum(m.out[,"nhb"]) # calculate total QALYs and store them
}
# return basic result
if(!detailed) return(df.out)
# return detailed result
if(detailed) {
return(list(
df.out = df.out,
l.out = l.out
))
}
}
)
}
######################################## 3. MODEL CALIBRATION ########################################
# n/a
######################################## 4. VALIDATION ########################################
# n/a
######################################## 5. ANALYSIS ########################################
######################################## 5.1. CROSS-VALIDATION: ICER ########################################
if(T) {
# run scenario
l.out_icer <- f.run_scenario(l.inputs = l.inputs_icer, detailed = TRUE)
# additional results
m.result_icer <- matrix(data = NA, nrow = ncol(l.out_icer$l.out$soc$m.out), ncol = 3, dimnames = list(colnames(l.out_icer$l.out$soc$m.out), c("soc","int","dif")))
m.result_icer[,"soc"] <- colSums(l.out_icer$l.out$soc$m.out)
m.result_icer[,"int"] <- colSums(l.out_icer$l.out$int$m.out)
m.result_icer[,"dif"] <- m.result_icer[,"int"] - m.result_icer[,"soc"]
# compare to publication
print(round(m.result_icer[c("ly","qaly","cost"),c("soc","int","dif")],2))
icer_icer <- calculate_icers(cost = l.out_icer[["df.out"]][,"COST"], effect = l.out_icer[["df.out"]][,"QALY"], strategies = l.out_icer[["df.out"]][,"strategy"])
print(icer_icer)
# proportion in state
l.inputs_icer_nohccdis <- l.inputs_icer # run model without half-cycle correction and discounted effects
l.inputs_icer_nohccdis[["discount_EFFECT"]] <- 0
l.inputs_icer_nohccdis[["half_cycle_correction"]] <- FALSE
l.out_icer_nohccdis <- f.run_scenario(l.inputs = l.inputs_icer_nohccdis, detailed = TRUE)
# write.table(x = round(l.out_icer_nohccdis$l.out$soc$m.out[1:11,c("mci","mil","mod","sev","dth")],2), file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
# write.table(x = round(l.out_icer_nohccdis$l.out$int$m.out[1:11,c("mci","mil","mod","sev","dth")],2), file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
# export results for IPECAD repository
# write.table(x = m.result_icer[c("cost_hc","cost_sc","cost_ic","cost_tx","qaly_pt","qaly_ic"),c("soc","int")], file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
l.inputs_icer_repository <- l.inputs_icer # run model without half-cycle correction and discounted effects
l.inputs_icer_repository[["half_cycle_correction"]] <- FALSE
l.inputs_icer_repository[["discount_EFFECT"]] <- 0
l.out_icer_repository <- f.run_scenario(l.inputs = l.inputs_icer_repository, detailed = TRUE)
# write.table(x = l.out_icer_repository$l.out$soc$m.out[1:26,c("mci","mil","mod","sev","dth")], file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
# write.table(x = l.out_icer_repository$l.out$int$m.out[1:26,c("mci","mil","mod","sev","dth")], file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
# standard tables/plots
if(T) {
# all outcomes
# str(l.out_icer) # show structure of output
# l.out_icer[["df.out"]]
# l.out_icer # all detailed output
# l.out_icer[["l.out"]] # strategy details
# l.out_icer[["l.out"]][["soc"]] # strategy 'soc' details
# l.out_icer[["l.out"]][["int"]] # strategy 'int' details
# l.out_icer[["l.out"]][["soc"]][["a.TP"]] # strategy 'soc' transition probability matrix
# l.out_icer[["l.out"]][["soc"]][["m.trace"]] # strategy 'soc' state trace
# l.out_icer[["l.out"]][["soc"]][["m.out"]] # strategy 'soc' outcomes per cycle
# l.out_icer[["l.out"]][["int"]][["a.TP"]] # idem for 'int'
# l.out_icer[["l.out"]][["int"]][["m.trace"]]
# l.out_icer[["l.out"]][["int"]][["m.out"]]
# table: summary
table.summary_data <- m.result_icer[c("mci","mil","mod","sev","ly","qaly","cost"),c("soc","int","dif")]
table.summary <- format(
table.summary_data,
digits=2,
scientific=FALSE,
big.mark=","
)
print(round(table.summary_data,2))
print(table.summary)
# plot: time in state
plot.timestate_data <- m.result_icer[c("mci","mil","mod","sev"),c("int","soc")]
# windows(width=7, height=4, pointsize=12)
par(mar=c(5, 4, 4, 1), xpd=TRUE)
barplot(
height = plot.timestate_data,
horiz = TRUE,
xaxt = "n",
xlim = c(0,ceiling(max(colSums(plot.timestate_data)))),
xlab = "time (years)",
ylab = "strategy",
col=c("green","yellow","orange","red"),
space = 0.2,
main = "mean time in state"
)
axis(side = 1, at = 0:ceiling(max(colSums(plot.timestate_data))))
text(x=c(0,cumsum(plot.timestate_data[1:3,"int"])), y=1, labels=round(plot.timestate_data[,"int"],1), pos=4)
text(x=c(0,cumsum(plot.timestate_data[1:3,"soc"])), y=2, labels=round(plot.timestate_data[,"soc"],1), pos=4)
text(x=c(0,cumsum(plot.timestate_data[1:3,"int"])), y=0.5, labels=c("MCI","mild","moderate","severe"), pos=4)
#legend(x="bottom", legend=c("mci","mil","mod","sev"), inset=c(0,-0.6), horiz=TRUE, fill=c("green","yellow","orange","red"))
# table: state trace
tableplot.statetracesoc_data <- cbind(
mci = rowSums(l.out_icer[["l.out"]][["soc"]][["m.trace"]][,c("mcion_c","mciof_c","mci_i")]),
mil = rowSums(l.out_icer[["l.out"]][["soc"]][["m.trace"]][,c("milon_c","milof_c","mil_i")]),
mod = rowSums(l.out_icer[["l.out"]][["soc"]][["m.trace"]][,c("mod_c","mod_i")]),
sev = rowSums(l.out_icer[["l.out"]][["soc"]][["m.trace"]][,c("sev_c","sev_i")]),
dth = l.out_icer[["l.out"]][["soc"]][["m.trace"]][,c("dth")]
)
tableplot.statetraceint_data <- cbind(
mci = rowSums(l.out_icer[["l.out"]][["int"]][["m.trace"]][,c("mcion_c","mciof_c","mci_i")]),
mil = rowSums(l.out_icer[["l.out"]][["int"]][["m.trace"]][,c("milon_c","milof_c","mil_i")]),
mod = rowSums(l.out_icer[["l.out"]][["int"]][["m.trace"]][,c("mod_c","mod_i")]),
sev = rowSums(l.out_icer[["l.out"]][["int"]][["m.trace"]][,c("sev_c","sev_i")]),
dth = l.out_icer[["l.out"]][["int"]][["m.trace"]][,c("dth")]
)
print(round(tableplot.statetracesoc_data[1:min(nrow(tableplot.statetracesoc_data),10),],2))
print(round(tableplot.statetraceint_data[1:min(nrow(tableplot.statetracesoc_data),10),],2))
# plot: state trace
v.age_range <- c(l.inputs_icer[["age_start"]]:(l.inputs_icer[["age_start"]]+l.inputs_icer[["n.cycle"]]-1)) # store age range
xx <- c(v.age_range, rev(v.age_range)) # prepare polygon x-values
yy_mci <- c(tableplot.statetracesoc_data[,"mci"], rev(tableplot.statetraceint_data[,"mci"])) # polygon y-values
yy_mil <- c(tableplot.statetracesoc_data[,"mil"], rev(tableplot.statetraceint_data[,"mil"])) # idem
yy_mod <- c(tableplot.statetracesoc_data[,"mod"], rev(tableplot.statetraceint_data[,"mod"])) # idem
yy_sev <- c(tableplot.statetracesoc_data[,"sev"], rev(tableplot.statetraceint_data[,"sev"])) # idem
yy_dth <- c(tableplot.statetracesoc_data[,"dth"], rev(tableplot.statetraceint_data[,"dth"])) # idem
# windows(width=7, height=7, pointsize=12)
par(mar=c(5, 4, 4, 1)+0.1, xpd=FALSE)
matplot(
x = v.age_range,
y = cbind(tableplot.statetracesoc_data,tableplot.statetraceint_data),
type = "n",
xlab = "age",
ylab = "proportion in state",
ylim = c(0,1),
main = "state trace"
)
polygon(xx, yy_mci, col = "gray95", border = FALSE)
polygon(xx, yy_mil, col = "gray95", border = FALSE)
polygon(xx, yy_mod, col = "gray95", border = FALSE)
polygon(xx, yy_sev, col = "gray95", border = FALSE)
polygon(xx, yy_dth, col = "gray95", border = FALSE)
matlines(
x = v.age_range,
y = tableplot.statetracesoc_data,
type = "l",
lty = 1,
col = c("green","yellow","orange","red","black")
)
matlines(
x = v.age_range,
y = tableplot.statetraceint_data,
type = "l",
lty = 2,
col = c("green","yellow","orange","red","black")
)
legend(x="topright", legend=c("mci","mil","mod","sev","dth"), col=c("green","yellow","orange","red","black"), lty=1, bg="white")
legend(x="right", legend=c("soc","int"), col="black", lty=c(1,2), bg="white")
# table: incremental cost-effectiveness ratio
print(as.data.frame(icer_icer))
# plot: incremental cost-effectiveness plane
par(mar=c(5, 4, 4, 1)+0.1, xpd=FALSE)
# windows(width=7, height=7, pointsize=12)
print(plot(icer_icer, label="all"))
# plot: cost difference by sector over time
m.cost_incr_pos <- m.cost_incr_neg <- l.out_icer[["l.out"]][["int"]][["m.out"]][,c("cost_dx","cost_tx","cost_hc","cost_sc","cost_ic")] - l.out_icer[["l.out"]][["soc"]][["m.out"]][,c("cost_dx","cost_tx","cost_hc","cost_sc","cost_ic")] # split positive and negative
m.cost_incr_pos[m.cost_incr_pos<0] <- 0
m.cost_incr_neg[m.cost_incr_neg>=0] <- 0
# windows(width=7, height=7, pointsize=12)
par(mar=c(5, 4, 4, 2)+0.1, xpd=FALSE)
barplot(
height = t(m.cost_incr_pos),
beside = F,
xlab = "time (years)",
ylab = "annual incremental costs",
ylim = c(
min(m.cost_incr_neg) + min(m.cost_incr_neg)*0.10,
max(m.cost_incr_pos) + max(m.cost_incr_pos)*0.10
),
col = rainbow(5),
names.arg = 1:nrow(m.cost_incr_pos),
main = "costs by sector over time"
)
barplot(
height = t(m.cost_incr_neg),
beside = F,
col = rainbow(5),
add = T
)
legend(x = "topright", legend = c("diagnostic","treatment","health","social","informal"), fill = rainbow(5))
}
}
######################################## 5.2. CROSS-VALIDATION: AD-ACE ########################################
if(T) {
# run scenario and results
l.out_adace <- f.run_scenario(l.inputs = l.inputs_adace, detailed = TRUE)
# additional results
m.result_adace <- matrix(data = NA, nrow = ncol(l.out_adace$l.out$soc$m.out), ncol = 3, dimnames = list(colnames(l.out_adace$l.out$soc$m.out), c("soc","int","dif")))
m.result_adace[,"soc"] <- colSums(l.out_adace$l.out$soc$m.out)
m.result_adace[,"int"] <- colSums(l.out_adace$l.out$int$m.out)
m.result_adace[,"dif"] <- m.result_adace[,"int"] - m.result_adace[,"soc"]
# compare to publication
print(round(m.result_adace[c("ly","qaly","cost"),c("soc","int","dif")],2))
icer_adace <- calculate_icers(cost = l.out_adace[["df.out"]][,"COST"], effect = l.out_adace[["df.out"]][,"QALY"], strategies = l.out_adace[["df.out"]][,"strategy"])
print(icer_adace)
# proportion in state
l.inputs_adace_nohccdis <- l.inputs_adace # run model without half-cycle correction and discounted effects
l.inputs_adace_nohccdis[["discount_EFFECT"]] <- 0
l.inputs_adace_nohccdis[["half_cycle_correction"]] <- FALSE
l.out_adace_nohccdis <- f.run_scenario(l.inputs = l.inputs_adace_nohccdis, detailed = TRUE)
# write.table(x = round(l.out_adace_nohccdis$l.out$soc$m.out[1:11,c("mci","mil","mod","sev","dth")],2), file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
# write.table(x = round(l.out_adace_nohccdis$l.out$int$m.out[1:11,c("mci","mil","mod","sev","dth")],2), file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
# export results for IPECAD repository
# write.table(x = m.result_adace[c("cost_hc","cost_sc","cost_ic","cost_tx","qaly_pt","qaly_ic"),c("soc","int")], file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
l.inputs_adace_repository <- l.inputs_adace # run model without half-cycle correction and discounted effects
l.inputs_adace_repository[["half_cycle_correction"]] <- FALSE
l.inputs_adace_repository[["discount_EFFECT"]] <- 0
l.out_adace_repository <- f.run_scenario(l.inputs = l.inputs_adace_repository, detailed = TRUE)
# write.table(x = l.out_adace_repository$l.out$soc$m.out[1:26,c("mci","mil","mod","sev","dth")], file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
# write.table(x = l.out_adace_repository$l.out$int$m.out[1:26,c("mci","mil","mod","sev","dth")], file = "clipboard", sep = "\t", row.names = FALSE, col.names = FALSE)
}
######################################## 5.3. UNCERTAINTY SCENARIOS ########################################
if(T) {
# base case
# icer (already defined)
# CDR-SB RR=23%
l.inputs_icer_2 <- l.inputs_icer
l.inputs_icer_2[["rr.tx_mci_mil"]] <- 1-0.23
l.inputs_icer_2[["rr.tx_mil_mod"]] <- 1-0.23
l.inputs_icer_2[["rr.tx_mil_sev"]] <- 1-0.23
# CDR-SB time shift (calibrate)
# see code chapter 'calibrate to time shift'
# MMSE progression (Vos & SveDem)
## source: [Vos, 2015: https://doi.org/10.1093/brain/awv029]
## option: Amyloid positive & neuronal loss undetermined
### Operationalized by diagnostic criteria NIA-AA categories: 'NIA-AA high AD' (Amyloid+, Injury+) and 'conflicting IAP' (Amyloid+, Injury-)
### corresponding 3-year cumulative incidence probability: 'high AD' = 59% (AD dementia; table 3) and 4% (non-AD dementia; mentioned in text), and 22% (AD dementia; table 3) and 4% (non-AD dementia; mentioned in text) with prevalence of 353 and 49 respectively (respectively)
### This results into a weighted 3-year cumulative incidence of (converting all 4 probabilities to rates before weighting and averaging):
temp.est2 <- 1-exp(- ( (-log(1-0.59) + -log(1-0.04))*353 + (-log(1-0.22) + -log(1-0.04))*49 ) / (353+49) )
## and corresponding 1-year probability of
temp.est2 <- 1-exp(- -log(1-temp.est2)/3)
temp.est2
## alternative option: Amyloid positive & neuronal loss positive
### Operationalized by diagnostic criteria NIA-AA categories: 'NIA-AA high AD' (Amyloid+, Injury+)
### corresponding 3-year cumulative incidence probability: 'high AD' = 59% (AD dementia; table 3) and 4% (non-AD dementia; mentioned in text)
### This results into a weighted 3-year cumulative incidence of:
temp.est1 <- 1-exp(- (-log(1-0.59) + -log(1-0.04)) )
## and corresponding 1-year probability of
temp.est1 <- 1-exp(- -log(1-temp.est1)/3)
temp.est1
l.inputs_icer_4 <- l.inputs_icer
l.inputs_icer_4[["p.mci_mil"]] <- round(temp.est2,3) # 0.248
l.inputs_icer_4[["p.mci_mod"]] <- 0
l.inputs_icer_4[["p.mci_sev"]] <- 0
l.inputs_icer_4[["p.mil_mci"]] <- 0
l.inputs_icer_4[["p.mil_mod"]] <- 0.293
l.inputs_icer_4[["p.mil_sev"]] <- 0.001
l.inputs_icer_4[["p.mod_mil"]] <- 0.087
l.inputs_icer_4[["p.mod_sev"]] <- 0.109
l.inputs_icer_4[["p.sev_mil"]] <- 0.000
l.inputs_icer_4[["p.sev_mod"]] <- 0.196
# Mortality (SveDem)
l.inputs_icer_5 <- l.inputs_icer
l.inputs_icer_5[["hr.mort_mci"]] <- 1
l.inputs_icer_5[["hr.mort_mil"]] <- 1.318 * 1.82
l.inputs_icer_5[["hr.mort_mod"]] <- 2.419 * 1.82
l.inputs_icer_5[["hr.mort_sev"]] <- 4.267 * 1.82
# MMSE progression and mortality (Vos & SveDem)
l.inputs_icer_6 <- l.inputs_icer_4
l.inputs_icer_6[["hr.mort_mci"]] <- 1
l.inputs_icer_6[["hr.mort_mil"]] <- 1.318 * 1.82
l.inputs_icer_6[["hr.mort_mod"]] <- 2.419 * 1.82
l.inputs_icer_6[["hr.mort_sev"]] <- 4.267 * 1.82
# A: continue treatment & no waning during treatment
# n/a: identical to base case
# B: continue treatment & waning during treatment
l.inputs_icer_B <- l.inputs_icer
0.69^(1-0.30)^5 # 30% waning reduces RR to 0.94 (compared to 0.69) after 5 years
l.inputs_icer_B[["tx_waning"]] <- 0.30
# C: stop treatment & no waning after treatment stop
l.inputs_icer_C <- l.inputs_icer
l.inputs_icer_C[["rr.tx_mci_mil_dis"]] <- l.inputs_icer_C[["rr.tx_mci_mil"]]
l.inputs_icer_C[["rr.tx_mil_mod_dis"]] <- l.inputs_icer_C[["rr.tx_mil_mod"]]
l.inputs_icer_C[["rr.tx_mil_sev_dis"]] <- l.inputs_icer_C[["rr.tx_mil_sev"]]
l.inputs_icer_C[["p.tx_discontinuation2"]] <- 1
l.inputs_icer_C[["tx_discontinuation2_begin"]] <- 2
# D: stop treatment & waning after treatment stop
l.inputs_icer_D <- l.inputs_icer_C
l.inputs_icer_D[["tx_waning_dis"]] <- 0.30
# E: stop treatment & no effect after treatment stop
l.inputs_icer_E <- l.inputs_icer
l.inputs_icer_E[["p.tx_discontinuation2"]] <- 1
l.inputs_icer_E[["tx_discontinuation2_begin"]] <- 2
# methodology: cycle lengths
# see code chapter 'cycle time'
# run scenarios
## initialize outcomes lists and tables
l.out_scenario <- list()
l.out_scenario_prep <- list()
m.table1 <- matrix(data = NA, nrow = 12, ncol = 7, dimnames = list(NULL,c("mcimil","ly","qaly","cost_dxtx","cost_care","nhb","icer")))
## run scenarios