-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRRAlc.R
1168 lines (762 loc) · 33.4 KB
/
RRAlc.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
#' Relative risks for alcohol related diseases
#'
#' Computes the relative risks for each alcohol related disease based on the published risk curves.
#'
#' Relative risks for partially attributable chronic come from published risk functions whose parameters have been
#' hard-coded within this function rather than being read from an external spreadsheet. For some conditions there are
#' separate risk functions for morbidity and mortality. For conditions that show a J-shaped risk function that
#' indicates protective effects of alcohol, there is an option to remove the protective effect by setting all
#' RR < 1 = 1.
#'
#' Relative risks for partially attributable acute are computed by the [tobalcepi::PArisk()] function called from within
#' this function. The characteristics of individual single occasion drinking are also calculated within this function
#' using [tobalcepi::AlcBinge_stapm()].
#'
#' Relative risks for wholly attributable chronic and wholly attributable acute conditions are calculated
#' based on the extent to which either weekly or daily consumption exceeds a pre-specified threshold. The risk
#' for wholly attributable acute conditions is calculated by the function [tobalcepi::WArisk_acute()]. We developed a new
#' method to model the absolute risk of wholly attributable acute conditions to suit the STAPM modelling.
#' This new method is based on the method used to model the risk of partially attributable acute conditions -
#' the shape of the risk function is determined by the individual variation in the total annual number of units that
#' are drunk above the male/female thresholds for single occasion binge drinking.
#'
#' @param data Data table of individual characteristics.
#' @param disease Character - the name of the disease for which the relative risks will be computed.
#' @param av_weekly_grams_per_day_var Character - the name of the variable containing each individual's
#' average weekly consumption of alcohol in grams of ethanol per day.
#' @param sex_var Character - the name of the variable containing individual sex.
#' @param age_var Character - the name of the variable containing individual age in single years.
#' @param mort_or_morb Character - for alcohol related diseases that have separate
#' relative risk curves for mortality and morbidity, should the curve corresponding to
#' mortality ("mort") or morbidity ("morb") be used.
#' @template alc-epi-args
#' @param getcurve Logical - do you just want to look at the risk function curve?
#' @param within_model Logical - is the function being used within a new-style STAPM simulation.
#' Defaults to TRUE.
#'
#' @return Returns a numeric vector of each individual's relative risks for the alcohol related disease specified by "disease".
#'
#' @importFrom data.table := setDT setnames fifelse
#'
#' @export
#'
#'
#' @examples
#'
#'\dontrun{
#'
#' # Draw disease specific risk functions
#'
#' # Example data
#' data <- data.table(
#' GPerDay = 0:100,
#' #peakday_grams = 0:100,
#' sex = "Female",
#' age = 30
#' )
#'
#' # Apply the function
#' test1 <- RRalc(
#' data,
#' disease = "Pharynx",
#' mort_or_morb = "mort"
#' )
#'
#' test2 <- RRalc(
#' data,
#' disease = "Ischaemic_heart_disease",
#' mort_or_morb = "morb"
#' )
#'
#' test3 <- RRalc(
#' data,
#' disease = "LiverCirrhosis",
#' mort_or_morb = "mort"
#' )
#'
#' # Plot the risk functions
#' plot(test1 ~ I(0:100), type = "l", ylim = c(0, 10), ylab = "rr",
#' main = "Females, age 30", xlab = "g per day")
#' lines(test2 ~ I(0:100), col = 2)
#' lines(test3 ~ I(0:100), col = 3)
#' legend("topleft",
#' c("Pharyngeal cancer", "Ischaemic heart disease morbidity", "Liver Cirrhosis mortality"),
#' lty = 1, col = 1:3)
#'}
RRalc <- function(
data,
disease = "Pharynx",
av_weekly_grams_per_day_var = "GPerDay",
sex_var = "sex",
age_var = "age",
mort_or_morb = c("mort", "morb"),
alc_protective = TRUE,
alc_wholly_chronic_thresholds = c(2, 2),
alc_wholly_acute_thresholds = c(3, 4),
grams_ethanol_per_unit = 8,
getcurve = FALSE,
within_model = TRUE
) {
#data_RRalc <- copy(data)
data_RRalc <- data
n <- NROW(data_RRalc)
x <- data_RRalc[ , get(av_weekly_grams_per_day_var)]
#p <- data[ , get(peak_grams_per_day_var)] # old code when used peakday directly from HSE
sex <- data_RRalc[ , get(sex_var)]
age <- data_RRalc[ , get(age_var)]
# Convert age in single years into categories
age <- c("<16", "16-17", "18-24", "25-34", "35-49", "50-64", "65-74", "75-89", "90+")[
findInterval(age, c(-1, 16, 18, 25, 35, 50, 65, 75, 90))]
# Create the vector of relative risks to be returned
# Initially set everyone's value to 1
risk_indiv <- rep(1, n)
################################################################################
# Partial chronic--------
if(!isTRUE(getcurve)) {
# Calculate average amount drunk per drinking occasion
p <- grams_ethanol_per_unit * data_RRalc[ , mean_sod]
}
###########
# Cancers #
###########
# Cancer of the oral cavity and pharynx----
# BAGNARDI, V., ROTA, M., BOTTERI, E. et al. (2015) Alcohol consumption and site-specific cancer risk: a comprehensive dose-response meta-analysis, British Journal of Cancer, 112, 580-593
if(disease %fin% c("Pharynx", "Oral_cavity", "Pharynx_and_Oral_cavity", "Oropharyngeal")) {
b1 <- 0.02474
b2 <- 0.00004
risk_indiv <- exp(b1 * x - b2 * (x^2))
}
# Cancer of the oesophagus----
# BAGNARDI, V., ROTA, M., BOTTERI, E. et al. (2015) Alcohol consumption and site-specific cancer risk: a comprehensive dose-response meta-analysis, British Journal of Cancer, 112, 580-593
if(disease %fin% c("Oesophagus", "Oesophageal", "Oesophageal_SCC")) {
b1 <- 0.05593
b2 <- 0.00789
risk_indiv <- exp(b1 * x - b2 * x * log(x))
}
# Cancer of the colon and rectum----
# BAGNARDI, V., ROTA, M., BOTTERI, E. et al. (2015) Alcohol consumption and site-specific cancer risk: a comprehensive dose-response meta-analysis, British Journal of Cancer, 112, 580-593
if(disease == "Colorectal") {
b1 <- 0.006279
risk_indiv <- exp(b1 * x)
}
# Cancer of the liver and intrahepatic bile ducts----
# Chuang et al 2015
if(disease == "Liver") {
b1 <- 0.4100701
y <- (x + 12) / 100
b2 <- 0.6728571429
b3 <- 0.6101417
b4 <- 0.4527367347
b5 <- 0.4939596
risk_indiv <- exp(b1 * (y - b2) + b3 * ((y^2) - b4) + b5)
}
# Cancer of the pancreas----
# BAGNARDI, V., ROTA, M., BOTTERI, E. et al. (2015) Alcohol consumption and site-specific cancer risk: a comprehensive dose-response meta-analysis, British Journal of Cancer, 112, 580-593
if(disease %fin% c("Pancreas", "Pancreatic")) {
b1 <- 0.002089
risk_indiv <- exp(b1 * x)
}
# Cancer of the larynx----
# BAGNARDI, V., ROTA, M., BOTTERI, E. et al. (2015) Alcohol consumption and site-specific cancer risk: a comprehensive dose-response meta-analysis, British Journal of Cancer, 112, 580-593
if(disease %fin% c("Larynx", "Laryngeal")) {
b1 <- 0.01462
b2 <- 0.00002
risk_indiv <- exp(b1 * x - b2 * (x^2))
}
# Cancer of the breast----
# BAGNARDI, V., ROTA, M., BOTTERI, E. et al. (2015) Alcohol consumption and site-specific cancer risk: a comprehensive dose-response meta-analysis, British Journal of Cancer, 112, 580-593
if(disease == "Breast") {
b1 <- 0.01018
risk_indiv <- exp(b1 * x)
risk_indiv[sex == "Male"] <- 1
}
##################
# Cardiovascular #
##################
# Hypertensive heart disease----
# Roerecke et al. (in press)
if(disease == "HypertensiveHeartDisease") {
# Male
m1 <- 0.0150537
m2 <- 0.0156155
rr.ma <- exp(m1 * x - m2 * (x^3) / (75^2))
rr.mb <- exp(m1 * x - m2 * (((x^3) - ((x - 21)^3 * 75) / 54) / (75^2)))
rr.mc <- exp(m1 * x - m2 * ((x^3) - ((x - 21)^3 * 75 - (x - 75)^3 * 21) / 54) / (75^2))
rr.m <- fifelse(x < 21, rr.ma, fifelse(x >= 21 & x < 75, rr.mb, rr.mc))
# Female
f1 <- 0
f2 <- 0.0154196
f3 <- 0.0217586
f4 <- 0.9649937
rr.fa <- exp(f1)
rr.fb <- exp(-f2 * x + f3 * (x^3 - ((x - 10)^3 * 20 - (x - 20)^3 * 10) / 10) / 20^2)
rr.fc <- exp(f4)
rr.f <- fifelse(x < 18.9517, rr.fa, fifelse(x >= 18.9517 & x < 75, rr.fb, rr.fc))
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
}
# Ischaemic heart disease----
if(tolower(disease) %fin% c("ischaemic_heart_disease", "ischaemic_heart_disease_morb")) {
# Mortality
# REHM, J., SHIELD, K. D., ROERECKE, M. & GMEL, G. (2016) Modelling the impact of alcohol consumption on cardiovascular disease mortality for comparative risk assessments: an overview BMC Public Health, 16, 363
if(mort_or_morb == "mort") {
y <- (x + 0.0099999997764826) / 100
b1 <- 1.111874 # 16-34
b2 <- 1.035623 # 35-64
b3 <- 0.757104 # 65+
# Male
m1 <- 0.4870068
m2 <- 1.550984
m3 <- 0
m4 <- 0.012
# 16-34
rr.ma1 <- exp(b1 * (-m1 * sqrt(y) + m2 * y^3))
rr.mb1 <- exp(m3)
rr.mc1 <- exp(m4 * (x - 100))
rr.m1 <- fifelse(x <= 60, rr.ma1, fifelse(x > 60 & x < 100, rr.mb1, rr.mc1))
# 35-64
rr.ma2 <- exp(b2 * (-m1 * sqrt(y) + m2 * y^3))
rr.mb2 <- exp(m3)
rr.mc2 <- exp(m4 * (x - 100))
rr.m2 <- fifelse(x <= 60, rr.ma2, fifelse(x > 60 & x < 100, rr.mb2, rr.mc2))
# 65+
rr.ma3 <- exp(b3 * (-m1 * sqrt(y) + m2 * y^3))
rr.mb3 <- exp(m3)
rr.mc3 <- exp(m4 * (x - 100))
rr.m3 <- fifelse(x <= 60, rr.ma3, fifelse(x > 60 & x < 100, rr.mb3, rr.mc3))
rr.m <- fifelse(age %fin% c("<16", "16-17", "18-24", "25-34"), rr.m1,
fifelse(age %fin% c("35-49", "50-64"), rr.m2,
fifelse(age %fin% c("65-74", "75-89"), rr.m3, NA_real_)))
# Female
f1 <- 1.832441
f2 <- 1.538557
f3 <- 0.01
f4 <- 0.0093
f5 <- 0.0068
f6 <- 30.3814
# 16-34
rr.fa1 <- exp(b1 * (f1 * y + f2 * y * log(y)))
rr.fb1 <- exp(f3 * (x - f6))
rr.f1 <- fifelse(x < f6, rr.fa1, rr.fb1)
# 35-64
rr.fa2 <- exp(b2 * (f1 * y + f2 * y * log(y)))
rr.fb2 <- exp(f4 * (x - f6))
rr.f2 <- fifelse(x < f6, rr.fa2, rr.fb2)
# 65+
rr.fa3 <- exp(b3 * (f1 * y + f2 * y * log(y)))
rr.fb3 <- exp(f5 * (x - f6))
rr.f3 <- fifelse(x < f6, rr.fa3, rr.fb3)
rr.f <- fifelse(age %fin% c("<16", "16-17", "18-24", "25-34"), rr.f1,
fifelse(age %fin% c("35-49", "50-64"), rr.f2,
fifelse(age %fin% c("65-74", "75-89"), rr.f3, NA_real_)))
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
if(!isTRUE(getcurve)) {
# remove protective effect for people who binge drink > 60 g/day
risk_indiv[risk_indiv < 1 & p > 60] <- 1
}
}
# Morbidity
# ROERECKE, M., & REHM, J. (2012). The cardioprotective association of average alcohol consumption and ischaemic heart disease: a systematic review and meta‐analysis. Addiction, 107(7), 1246-1260.
# All protective effects removed for binge drinkers (>60g/day)
# ROERECKE, M., & REHM, J. (2010). Irregular heavy drinking occasions and risk of ischemic heart disease: a systematic review and meta-analysis. American journal of epidemiology, 171(6), 633-644
if(mort_or_morb == "morb") {
# Male
m1 <- 0.1178113
m2 <- 0.0189
rr.ma <- exp(-m1 * sqrt(x) + m2 * sqrt(x) * log(x))
rr.mb <- exp(0)
rr.m <- fifelse(x < 60, rr.ma, rr.mb)
# Female
f1 <- 0.296842
f2 <- 0.0392805
rr.f <- exp(-f1 * sqrt(x) + f2 * x)
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
if(!isTRUE(getcurve)) {
# remove protective effect for people who binge drink > 60 g/day
risk_indiv[risk_indiv < 1 & p > 60] <- 1
}
}
if(!isTRUE(alc_protective)) {
risk_indiv[risk_indiv < 1] <- 1
}
}
# Cardiac arrhythmias----
# SAMOKHVALOV A. V., IRVING H. M., REHM J. Alcohol as a risk factor for atrial fibrillation: a systematic review and meta-analysis. Eur J Cardiovasc Prev Rehabil 2010; 17: 706–712
if(disease == "Cardiac_Arrhythmias") {
b1 <- 0.0575183
y <- (x + 0.0499992370605469) / 10
risk_indiv <- exp(b1 * y)
}
# Haemorrhagic and other non-ischaemic stroke----
# PATRA, J., TAYLOR, B., IRVING, H. et al. (2010) Alcohol consumption and the risk of morbidity and mortality for different stroke types--a systematic review and meta-analysis, BMC Public Health, 10, 258
if(tolower(disease) %fin% c("haemorrhagic_stroke", "haemorrhagic_stroke_morb")) {
# Mortality
if(mort_or_morb == "mort") {
# Male
m1 <- 1.006943
m2 <- 0.6898937
m3 <- 0.0028572082519531
rr.ma <- exp(log(1 - x * (1 - m1)))
rr.mb <- exp(m2 * ((x + m3) / 100))
rr.m <- fifelse(x <= 1, rr.ma, rr.mb)
# Female
f1 <- 1.014815
f2 <- 1.466406
f3 <- 0.0028572082519531
rr.fa <- exp(log(1 - x * (1 - f1)))
rr.fb <- exp(f2 * ((x + f3) / 100))
rr.f <- fifelse(x <= 1, rr.fa, rr.fb)
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
}
# Morbidity
if(mort_or_morb == "morb") {
# Male
m1 <- 0.007695021
rr.m <- exp(x * m1)
# Female
f1 <- 0.340861
f2 <- 0.0944208
rr.f <- exp(-f1 * sqrt(x) + f2 * sqrt(x) * log(x))
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
}
if(!isTRUE(alc_protective)) {
risk_indiv[risk_indiv < 1] <- 1
}
}
# Ischaemic stroke----
if(tolower(disease) %fin% c("ischaemic_stroke", "ischaemic_stroke_morb")) {
# Mortality
# REHM, J., SHIELD, K. D., ROERECKE, M. & GMEL, G. (2016) Modelling the impact of alcohol consumption on cardiovascular disease mortality for comparative risk assessments: an overview BMC Public Health, 16, 363
if(mort_or_morb == "mort") {
a1 <- 1.111874
a2 <- 1.035623
a3 <- 0.757104
m1 <- 0.4030081
m2 <- 0.3877538
f1 <- 2.48768
f2 <- 3.708724
e1 <- 0.03521
e2 <- 0.03279
e3 <- 0.02397
e4 <- 0.37987
e5 <- 0.35382
e6 <- 0.25866
y <- (x + 0.0028572082519531) / 100
# Male
# 16-34
rr.ma1 <- 1 - x * (1 - exp(-e1))
rr.mb1 <- exp(a1 * (m1 * sqrt(y) + m2 * sqrt(y) * log(y)))
rr.m1 <- fifelse(x <= 1, rr.ma1, rr.mb1)
# 35-64
rr.ma2 <- 1 - x * (1 - exp(-e2))
rr.mb2 <- exp(a2 * (m1 * sqrt(y) + m2 * sqrt(y) * log(y)))
rr.m2 <- fifelse(x <= 1, rr.ma2, rr.mb2)
# 65+
rr.ma3 <- 1 - x * (1 - exp(-e3))
rr.mb3 <- exp(a3 * (m1 * sqrt(y) + m2 * sqrt(y) * log(y)))
rr.m3 <- fifelse(x <= 1, rr.ma3, rr.mb3)
rr.m <- fifelse(age %fin% c("<16", "16-17", "18-24", "25-34"), rr.m1,
fifelse(age %fin% c("35-49", "50-64"), rr.m2,
fifelse(age %fin% c("65-74", "75-89"), rr.m3, NA_real_)))
# Female
# 16-34
rr.fa1 <- 1 - x * (1 - exp(-e4))
rr.fb1 <- exp(a1 * (-f1 * sqrt(y) + f2 * y))
rr.f1 <- fifelse(x <= 1, rr.fa1, rr.fb1)
# 35-64
rr.fa2 <- 1 - x * (1 - exp(-e5))
rr.fb2 <- exp(a2 * (-f1 * sqrt(y) + f2 * y))
rr.f2 <- fifelse(x <= 1, rr.fa2, rr.fb2)
# Female, 65+
rr.fa3 <- 1 - x * (1 - exp(-e6))
rr.fb3 <- exp(a3 * (-f1 * sqrt(y) + f2 * y))
rr.f3 <- fifelse(x <= 1, rr.fa3, rr.fb3)
rr.f <- fifelse(age %fin% c("<16", "16-17", "18-24", "25-34"), rr.f1,
fifelse(age %fin% c("35-49", "50-64"), rr.f2,
fifelse(age %fin% c("65-74", "75-89"), rr.f3, NA_real_)))
if(!isTRUE(getcurve)) {
# remove protective effect for people who binge drink > 60 g/day
risk_indiv[risk_indiv < 1 & p > 60] <- 1
}
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
}
# Morbidity
# PATRA, J., TAYLOR, B., IRVING, H. et al. (2010) Alcohol consumption and the risk of morbidity and mortality for different stroke types--a systematic review and meta-analysis, BMC Public Health, 10, 258
# All protective effects removed for binge drinkers (>60g/day)
# REHM, J., SHIELD, K. D., ROERECKE, M. & GMEL, G. (2016) Modelling the impact of alcohol consumption on cardiovascular disease mortality for comparative risk assessments: an overview BMC Public Health, 16, 363
if(mort_or_morb == "morb") {
# Male
m1 <- 0.132894
m2 <- 0.03677422
rr.m <- exp(-m1 * sqrt(x) + m2 * sqrt(x) * log(x))
# Female
f1 <- 0.114287
f2 <- 0.01680936
rr.f <- exp(-f1 * sqrt(x) + f2 * x)
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
if(!isTRUE(getcurve)) {
# remove protective effect for people who binge drink > 60 g/day
risk_indiv[risk_indiv < 1 & p > 60] <- 1
}
}
if(!isTRUE(alc_protective)) {
risk_indiv[risk_indiv < 1] <- 1
}
}
#############
# Digestive #
#############
# Fibrosis and cirrhosis of the liver----
# REHM, J., TAYLOR, B., MOHAPATRA, S. et al. (2010) Alcohol as a risk factor for liver cirrhosis: a systematic review and meta-analysis, Drug and Alcohol Review, 29, 437-45
if(tolower(disease) %fin% c("livercirrhosis", "livercirrhosis_morb")) {
# Mortality
if(mort_or_morb == "mort") {
y <- (x + 0.1699981689453125) / 100
# Male
m1 <- 1.033224
m2 <- 2.793524
rr.ma <- exp(log(1 + x * (m1 - 1)))
rr.mb <- exp(m2 * y)
rr.m <- fifelse(x <= 1, rr.ma, rr.mb)
# Female
f1 <- 1.421569
f2 <- 3.252035
rr.fa <- exp(log(1 + x * (f1 - 1)))
rr.fb <- exp(f2 * sqrt(y))
rr.f <- fifelse(x <= 1, rr.fa, rr.fb)
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
}
# Morbidity
if(mort_or_morb == "morb") {
# Male
m1 <- 0.01687111
rr.m <- exp(m1 * x)
# Female
f1 <- 0.2351821
rr.f <- exp(f1 * sqrt(x))
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
}
}
# Acute pancreatitis----
# SAMOKHVALOV, A. V., REHM, J. & ROERECKE, M. (2015) Alcohol consumption as a risk factor for acute and chronic pancreatitis: a systematic review and a series of meta-analyses, EBioMedicine, 2, 1996-2002
if(disease == "Acute_Pancreatitis") {
# Male
m1 <- 0.013
rr.m <- exp(m1 * x)
# Female
f1 <- 0.0272886
f2 <- 0.0611466
f3 <- 2.327965
rr.f1 <- exp(-f1 * x)
rr.f2 <- exp(-f1 * x + f2 * ((x - 3)^3) / ((40 - 3)^2))
rr.f3 <- exp(-f1 * x + f2 * ( ((x - 3)^3) - ( ( ((x - 15)^3) * (40 - 3) ) / (40 - 15) ) ) / ((40 - 3)^2) )
rr.f4 <- exp(-f1 * x + f2 * ( ((x - 3)^3) - ( ( ((x - 15)^3) * (40 - 3) - ((x - 40)^3) * (15 - 3) ) / (40 - 15) ) ) / ((40 - 3)^2) )
rr.f5 <- exp(f3)
rr.f <- fifelse(x < 3, rr.f1,
fifelse(x >= 3 & x < 15, rr.f2,
fifelse(x >= 15 & x < 40, rr.f3,
fifelse(x >= 40 & x < 108, rr.f4,
fifelse(x >= 108, rr.f5, NA_real_)))))
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
if(!isTRUE(alc_protective)) {
risk_indiv[risk_indiv < 1] <- 1
}
}
# Chronic pancreatitis----
# SAMOKHVALOV, A. V., REHM, J. & ROERECKE, M. (2015) Alcohol consumption as a risk factor for acute and chronic pancreatitis: a systematic review and a series of meta-analyses, EBioMedicine, 2, 1996-2002
if(disease == "Chronic_Pancreatitis") {
risk_indiv <- exp(0.018 * x)
}
# Acute and Chronic pancreatitis----
# Irving et al 2009
# this is the old version of the pancreatitis risk function
# in the newer version of the model it has been replaced by separate risk functions for acute and chronic
# included here as needed for alc costs to pc work that was based on the old disease list
# that grouped acute and chronic together
if(disease == "Acute_and_Chronic_Pancreatitis") {
risk_indiv <- exp(1.259e-5 + x * 8.67933e-5 + (x^2) * 0.00015)
}
#############
# Endocrine #
#############
# Type II Diabetes----
# KNOTT, C., BELL, S., & BRITTON, A. (2015). Alcohol consumption and the risk of type 2 diabetes: a systematic review and dose-response meta-analysis of more than 1.9 million individuals from 38 observational studies. Diabetes care, 38(9), 1804-1812.
if(disease == "Diabetes") {
# Male
m1 <- 0.00001763703
m2 <- 0.0000000728256
rr.m <- exp(m1 * (x^2) - m2 * (x^3))
# Female
f1 <- 0.1313991
f2 <- 0.01014239
rr.f <- exp(-f1 * sqrt(x) + f2 * x)
# Combine
risk_indiv <- fifelse(sex == "Male", rr.m, fifelse(sex == "Female", rr.f, NA_real_))
if(!isTRUE(alc_protective)) {
risk_indiv[risk_indiv < 1] <- 1
}
}
##################
# Nervous system #
##################
# Epilepsy----
# SAMOKHVALOV, A. V., IRVING, H., MOHAPATRA, S. & REHM, J. (2010) Alcohol consumption, unprovoked seizures and epilepsy: a systematic review and meta-analysis, Epilepsia, 51, 1177-1184
if(disease == "Epilepsy") {
risk_indiv <- exp(1.22861 * (x + 0.5) / 100)
}
###############
# Respiratory #
###############
# Tuberculosis----
# IMTIAZ, S., SHIELD, K. D., ROERECKE, M., SAMOKHVALOV, A.V., LONNROTH, K., REHM, J. (2017) Alcohol consumption as a risk factor fortuberculosis: meta-analyses and burden of disease. European Respiratory Journal, 50(1), 1700216
if(disease == "Tuberculosis") {
risk_indiv <- exp(0.0179695 * x)
}
# Lower respiratory tract infections / Pneumonia----
# SAMOKHVALOV, A. V., IRVING, H. M. & REHM, J. (2010) Alcohol consumption as a risk factor for pneumonia: systematic review and meta-analysis, Epidemiology and Infection, 138, 1789-1795
if(disease %fin% c("Pneumonia", "Influenza_clinically_diagnosed", "Influenza_microbiologically_confirmed", "Lower_respiratory_tract_infections")) {
risk_indiv <- exp(0.4764038 * (x + 0.0399999618530273) / 100)
}
# Just to be sure - and fix errors due to log(0) = -Inf
risk_indiv[x == 0] <- 1
################################################################################
# Partial acute-------
# Transport injuries----
if(disease == "Transport_injuries") {
# tictoc::tic()
#
# SODMean <- as.list(data_RRalc[ , mean_sod])
# SODSDV <- as.list(data_RRalc[ , occ_sd])
# SODFreq <- as.list(data_RRalc[ , drink_freq])
# Weight <- as.list(data_RRalc[ , weight])
# Widmark_r <- as.list(data_RRalc[ , rwatson])
#
# l <- list(SODMean, SODSDV, SODFreq, Weight, Widmark_r)
#
# purrr::pmap(l, PArisk,
# cause = "Transport",
# grams_ethanol_per_unit = grams_ethanol_per_unit)
#
# tictoc::toc()
#tictoc::tic()
# data_RRalc[ , rr := sapply(1:n, function(z) {
#
# tobalcepi::PArisk(
# SODMean = mean_sod[z],
# SODSDV = occ_sd[z],
# SODFreq = drink_freq[z],
# Weight = weight[z],
# Widmark_r = rwatson[z],
# cause = "Transport",
# grams_ethanol_per_unit = grams_ethanol_per_unit
# )
# })]
data_RRalc[ , rr := 1]
data_RRalc[GPerDay > 0, rr :=
tobalcepi::PArisk(
interval_prob_vec = interval_prob_vec,
SODFreq = drink_freq,
Weight = weight,
Widmark_r = rwatson,
cause = "Transport",
grams_ethanol_per_unit = grams_ethanol_per_unit
),
by = c("sex", "imd_quintile")]
# interval_prob_vec = data_RRalc[GPerDay > 0, interval_prob_vec]
# SODFreq = data_RRalc[GPerDay > 0, drink_freq]
# Weight = data_RRalc[GPerDay > 0, weight]
# Widmark_r = data_RRalc[GPerDay > 0, rwatson]
# cause = "Transport"
# grams_ethanol_per_unit = grams_ethanol_per_unit
#tictoc::toc()
risk_indiv <- data_RRalc[ , rr]
data_RRalc[ , rr := NULL]
}
# Fall injuries----
if(disease == "Fall_injuries") {
# data_RRalc[ , rr := sapply(1:n, function(z) {
# tobalcepi::PArisk(
# SODMean = mean_sod[z],
# SODSDV = occ_sd[z],
# SODFreq = drink_freq[z],
# Weight = weight[z],
# Widmark_r = rwatson[z],
# cause = "Fall",
# grams_ethanol_per_unit = grams_ethanol_per_unit
# )
# })]
data_RRalc[ , rr := 1]
# tobalcepi::PArisk(
# SODMean = data_RRalc[GPerDay > 0, mean_sod],
# SODSDV = data_RRalc[GPerDay > 0, occ_sd],
# SODFreq = data_RRalc[GPerDay > 0, drink_freq],
# Weight = data_RRalc[GPerDay > 0, weight],
# Widmark_r = data_RRalc[GPerDay > 0, rwatson],
# cause = "Fall",
# grams_ethanol_per_unit = grams_ethanol_per_unit
# )
data_RRalc[GPerDay > 0, rr :=
tobalcepi::PArisk(
interval_prob_vec = interval_prob_vec,
SODFreq = drink_freq,
Weight = weight,
Widmark_r = rwatson,
cause = "Fall",
grams_ethanol_per_unit = grams_ethanol_per_unit
),
by = c("sex", "imd_quintile")]
#]# , by = seq_len(NROW(data_RRalc[GPerDay > 0]))]
risk_indiv <- data_RRalc[ , rr]
data_RRalc[ , rr := NULL]
}
# Violence----
if(disease %fin% c("Assault", "Other_intentional_injuries")) {
# data_RRalc[ , rr := sapply(1:n, function(z) {
# tobalcepi::PArisk(
# SODMean = mean_sod[z],
# SODSDV = occ_sd[z],
# SODFreq = drink_freq[z],
# Weight = weight[z],
# Widmark_r = rwatson[z],
# cause = "Violence",
# grams_ethanol_per_unit = grams_ethanol_per_unit
# )
# })]
data_RRalc[ , rr := 1]
data_RRalc[GPerDay > 0, rr :=
tobalcepi::PArisk(
interval_prob_vec = interval_prob_vec,
SODFreq = drink_freq,
Weight = weight,
Widmark_r = rwatson,
cause = "Violence",
grams_ethanol_per_unit = grams_ethanol_per_unit
),
by = c("sex", "imd_quintile")]
#]#, by = seq_len(NROW(data_RRalc[GPerDay > 0]))]
risk_indiv <- data_RRalc[ , rr]
data_RRalc[ , rr := NULL]
}
# Other----
if(disease %fin% c("Mechanical_forces", "Drowning", "Other_unintentional_injuries", "intentional_self_harm", "Accidental_poisoning", "Fire_injuries")) {