-
Notifications
You must be signed in to change notification settings - Fork 2
/
Antropometría - edad biológica.R
2719 lines (2281 loc) · 182 KB
/
Antropometría - edad biológica.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
# AnthropoAge, a novel approach to integrate body composition into the estimation of biological age
# Data Analysis: Carlos A. Fermin-Martinez, Alejandro Marquez-Salinas & Omar Yaxmehen Bello-Chavolla
# Latest version of Analysis October 10th, 2022
# For any question regarding analysis contact Omar Yaxmehen Bello-Chavolla at oyaxbell@yahoo.com.mx
####---- Database management ----####
pacman::p_load(haven, tidyverse, ggpubr, lmtest, nortest, gtools, data.table, caret, glmnet, survival, flextable, blandr, BlandAltmanLeh, corrplot,
rms, bestNormalize, flexsurv, pROC, timeROC, fmsb, factoextra, gridExtra, nhanesA, wesanderson,forestmodel, ggedit,dummy,
FactoMineR, fpc, NbClust, ggimage, glmnet, ggsci, survminer, cluster, ggplotify, UpSetR, nortest, viridis, officer, magrittr)
#Extra functions
conc95 <- function(x){
y <- (summary(x)$concordance[2])*1.96
c <- summary(x)$concordance[1]
c_low <- c-y; c_up <- c+y
`names<-`(c(c,c_low,c_up),c("Concordance","Lower 95-CI","Upper 95-CI"))}
hr95 <- function(x){
a <- summary(x)$conf.int[1,1]
a_low <- summary(x)$conf.int[1,3]
a_up <- summary(x)$conf.int[1,4]
`names<-`(c(a,a_low,a_up),c("HR","Lower 95-CI","Upper 95-CI"))}
ci_quick<-function(x){
a=round(x,3)
paste0("HR=",a[1]," (",a[2],"-",a[3],")")}
p_aster <- function(x){
y=x<c(0.05,0.01,0.001)
z=sum(y)
if(z==3){"***"}
else if(z==2){"**"}
else if(z==1){"*"}
else if(z==0){""}}
#Please save as WINDOWS-1252
#setwd("C:/Users/investigacion/OneDrive - UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO/AnthropoAge")
#setwd("~/OneDrive - UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO/AnthropoAge")
#setwd("~/UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO/ALEJANDRO MARQUEZ SALINAS - Antropometría")
#setwd("C:/Users/facmed/UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO/ALEJANDRO MARQUEZ SALINAS - Antropometría")
#setwd("C:/Users/facmed/OneDrive - UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO/Antropometría")
setwd("/Users/carlosfermin/OneDrive - UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO/Antropometría")
options(warn = 0)
### Loading databases ###
#NHANES-III
NHANES3<-fread("nhanes3.csv", na = c("", "N/A", "NA","na", "#N/A", "88888", "8888", "888888", "888","5555","999","9999", "99999", "999999", "9998"))
mortalidad3<-fread("nhanes3_mort.csv"); mortalidad3$SEQN<-mortalidad3$seqn
#NHANES-IV
NHANES<-fread("nhanes4_dxa.csv",na = c("", "N/A", "NA","na", "#N/A", "88888", "8888", "888888", "888","5555","999","9999", "99999", "999999"))
mortalidad<-fread("nhanes_mortalidad.csv"); mortalidad$SEQN<-mortalidad$seqn
source("functions_predict.R")
### NHANES-III management ###
NHANES0 <- NHANES3 %>% filter(HSAGEIR.x>=20)%>%
mutate("BMI"=BMPBMI, "Thigh_circumference"=BMPTHICI, "Arm_circumference"=BMPARMC, "Weight"= BMPWT,
"Height"=BMPHT, "Waist"=BMPWAIST, "Triceps_skinfold"=BMPTRI, "Subscapular_skinfold"=BMPSUB,
"Leg_length"=BMPLEG, "Arm_length"=BMPARML, "ICE"=BMPWAIST/BMPHT, "Diabetes"=HAD1,
"Hypertension"=HAE2, "Asthma"=HAC1E, "Arthritis"=HAC1A, "Heart_failure"=HAC1C,
"Heart_attack"=HAF10, "Stroke"=HAC1D, "Emphysema"=HAC1G, "Bronchitis"=HAC1F, "Malignancy"=HAC1O,
"Sex"=factor(HSSEX.x, levels= c(1,2),labels= c("Men", "Women")), "Age"=HSAGEIR.x, "Ethnicity"=DMARETHN.x)
#Race/Ethnicity: 1=White, 2=Black, 3=Mexican-American, 4=Other
#PhenoAge
NHANES0$PhenoAge = 141.5 + ((log(-0.00553*log(1-(1-exp((-1.51714*exp(-19.907-0.0336*NHANES0$AMP+0.0095*NHANES0$CEPSI + 0.1953*NHANES0$G1PSI+
0.0954*log(NHANES0$CRP)-0.0120*NHANES0$LMPPCNT+0.0268*NHANES0$MVPSI+
0.3306*NHANES0$RWP+0.00188*NHANES0$AP+0.0554*NHANES0$WCP+
0.0804*NHANES0$HSAGEIR.x))/(0.0076927)))))))/(0.09165)
#Cause-specific mortality
NHANES0 <- merge(NHANES0,mortalidad3,by="SEQN")
NHANES0$ucod_leading[is.na(NHANES0$ucod_leading)] <- 11
d1<-dummy::dummy(NHANES0 %>% transmute(as.factor(ucod_leading)))
colnames(d1)<-c("Heart_diseases","Malignant_neoplasms","Chronic_lower_respiratory_diseases","Accidents",
"Cerebrovascular_diseases","Alzheimer_disease","Diabetes_mellitus","Influenza_or_pneumonia",
"Nephone_diseases","Other_causes","Alive"); NHANES0<-cbind(NHANES0, d1)
nhanes0<-NHANES0 %>% dplyr::select(SEQN, Age, Sex, Ethnicity, mortstat,permth_int,PhenoAge,BMI, Thigh_circumference, Arm_circumference,
Triceps_skinfold,Subscapular_skinfold,Leg_length, Arm_length, Waist, Height, Weight, ICE,
"Heart_diseases","Malignant_neoplasms","Chronic_lower_respiratory_diseases","Accidents",
"Cerebrovascular_diseases","Alzheimer_disease","Diabetes_mellitus","Influenza_or_pneumonia",
"Nephone_diseases","Other_causes","Alive", Diabetes, Hypertension, Asthma, Arthritis, Heart_failure,
Heart_attack, Stroke, Emphysema, Bronchitis, Malignancy); nhanes0$id <- rep(1,nrow(nhanes0))
### NHANES-IV management ###
NHANES1 <- NHANES %>% filter(RIDAGEYR>=20) %>%
mutate("DXDTOFAT_N" = (DXDTOFAT/1000)/((BMXWT/100)^2), "DXXTRFAT_N" = (DXXTRFAT/1000)/((BMXWT/100)^2), "DXXHEFAT_N" = (DXXHEFAT/1000)/((BMXWT/100)^2),
"DXXLAFAT_N" = (DXXLAFAT/1000)/((BMXWT/100)^2), "DXXRAFAT_N" = (DXXRAFAT/1000)/((BMXWT/100)^2), "DXXLLFAT_N" = (DXXLLFAT/1000)/((BMXWT/100)^2),
"DXXRLFAT_N" = (DXXRLFAT/1000)/((BMXWT/100)^2), "DXXTRFAT_DXDTOFAT" = (DXXTRFAT)/(DXDTOFAT), "Weight" = BMXWT, "Waist" = BMXWAIST, "Height" = BMXHT,
"BMI" = BMXBMI, "Calf_circumference" = BMXCALF, "Arm_circumference" = BMXARMC, "Thigh_circumference" = BMXTHICR, "Triceps_skinfold" = BMXTRI,
"Subscapular_skinfold" = BMXSUB, "Leg_length" = BMXLEG, "ICE" = BMXWAIST/BMXHT, "Arm_length"= BMXARML, "METSIR" = (log(Glucose*2+TG)*BMXBMI)/log(HDL),
"EXTSUP_FAT" = DXXLAFAT_N + DXXRAFAT_N, "EXTINF_FAT" = DXXLLFAT_N + DXXRLFAT_N, "DXDHELE_N" = (DXDHELE/1000), "DXDLALE_M" = (DXDLALE/1000), "DXDRALE_N" = (DXDRALE/1000),
"DXDRLLE_N" = (DXDRLLE/1000), "DXDLALE_N" = (DXDLALE/1000), "DXDLLLE_N" = (DXDLLLE/1000), "DXDTOLE_N" = (DXDTOLE/1000), "DXDTRLE_N" = (DXDTRLE/1000)) %>%
mutate("METS_VF" = 4.466 + 0.011*(log(METSIR)^3)+ 3.239*(log(ICE)^3)-0.319*(2-RIAGENDR) + 0.594*(log(RIDAGEYR)), "EXTSUP_FAT_N" = (EXTSUP_FAT/1000)/((Height/100)^2),
"EXTINF_FAT_N" = (EXTINF_FAT/1000)/((Height/100)^2), "EXTSUP_FAT_DXDTOFAT" = (EXTSUP_FAT/1000)/(DXDTOFAT/1000), "EXTINF_FAT_DXDTOFAT" = (EXTINF_FAT/1000)/(DXDTOFAT/1000)) %>%
mutate("Sex"=factor(RIAGENDR, levels= c(1,2),labels= c("Men", "Women")), "Age"=RIDAGEYR, "Diabetes"=DIQ010, "Hypertension"=BPQ020, "Asthma"=MCQ010,
"Arthritis"=MCQ160A, "Heart_failure"=MCQ160B, "Heart_attack"=MCQ160E, "Stroke"=MCQ160F, "Emphysema"=MCQ160G, "Bronchitis"=MCQ160K, "Malignancy"=MCQ220)
#Recode race/ethnicity
NHANES1$Ethnicity[NHANES1$RIDRETH1==5] <- 4
NHANES1$Ethnicity[NHANES1$RIDRETH1==1] <- 3; NHANES1$Ethnicity[NHANES1$RIDRETH1==2] <- 4
NHANES1$Ethnicity[NHANES1$RIDRETH1==3] <- 1; NHANES1$Ethnicity[NHANES1$RIDRETH1==4] <- 2
#PhenoAge
NHANES1$PhenoAge <- 141.5 + (((log(-0.00553* log(1-(1-exp((-1.51714*exp(-19.907 - 0.0336*NHANES1$Albumin + 0.0095*(NHANES1$Creatinine*88.4) +
0.1953*(NHANES1$Glucose*0.0555) + 0.0954*log(NHANES1$CRP) -
0.0120*NHANES1$LymphP + 0.0268*NHANES1$MCV + 0.3306*NHANES1$RDW +
0.00188*NHANES1$ALP + 0.0554*NHANES1$WBC +
0.0804*NHANES1$Age))/(0.0076927)))))))/(0.09165))
#Cause-specific mortality
NHANES1 <- merge(NHANES1,mortalidad,by="SEQN")
NHANES1$ucod_leading[is.na(NHANES1$ucod_leading)] <- 11
d1<-dummy::dummy(NHANES1 %>% transmute(as.factor(ucod_leading)))
colnames(d1)<-c("Heart_diseases","Malignant_neoplasms","Chronic_lower_respiratory_diseases","Accidents",
"Cerebrovascular_diseases","Alzheimer_disease","Diabetes_mellitus","Influenza_or_pneumonia",
"Nephone_diseases","Other_causes","Alive"); NHANES1<-cbind(NHANES1,d1)
nhanes1<-NHANES1 %>% dplyr::select(SEQN, Age, Sex, Ethnicity, mortstat,permth_int,PhenoAge,BMI, Thigh_circumference, Arm_circumference,
Triceps_skinfold,Subscapular_skinfold,Leg_length, Arm_length, Waist, Height, Weight, ICE,
"Heart_diseases","Malignant_neoplasms","Chronic_lower_respiratory_diseases","Accidents",
"Cerebrovascular_diseases","Alzheimer_disease","Diabetes_mellitus","Influenza_or_pneumonia",
"Nephone_diseases","Other_causes","Alive", Diabetes, Hypertension, Asthma, Arthritis, Heart_failure,
Heart_attack, Stroke, Emphysema, Bronchitis, Malignancy); nhanes1$id<-rep(2, nrow(nhanes1))
### NHANES III and IV ###
nhanes0 <- nhanes0 %>% filter(!duplicated(SEQN)); nhanes1 <- nhanes1 %>% filter(!duplicated(SEQN))
nhanes <- rbind(nhanes0, nhanes1)
#Comorbidities
nhanes$Diabetes<-ifelse(nhanes$Diabetes==1, 1, 0); nhanes$Asthma<-ifelse(nhanes$Asthma==1, 1, 0)
nhanes$Arthritis<-ifelse(nhanes$Arthritis==1, 1, 0); nhanes$Heart_failure<-ifelse(nhanes$Heart_failure==1, 1, 0)
nhanes$Heart_attack<-ifelse(nhanes$Heart_attack==1, 1, 0); nhanes$Emphysema<-ifelse(nhanes$Emphysema==1, 1, 0)
nhanes$Bronchitis<-ifelse(nhanes$Bronchitis==1, 1, 0); nhanes$Malignancy<-ifelse(nhanes$Malignancy==1, 1, 0)
nhanes$Stroke<-ifelse(nhanes$Stroke==1, 1, 0); nhanes$Hypertension<-ifelse(nhanes$Hypertension==1, 1, 0)
#Number of comorbidities
nhanes$num_comorb<-nhanes$Diabetes+nhanes$Asthma+nhanes$Arthritis+nhanes$Heart_failure+nhanes$Heart_attack+nhanes$Emphysema+nhanes$Bronchitis+nhanes$Malignancy+nhanes$Stroke+nhanes$Hypertension
#Race/Ethnicity
nhanes$Ethnicity<-factor(nhanes$Ethnicity, labels = c("White", "Black", "Mexican-American", "Other"))
####---- Missing values management ----####
#Step 1: Remove duplicated subjects
nrow(nhanes); table(nhanes$id)
nhanes_0<-nhanes %>% filter(!duplicated(SEQN))
nrow(nhanes_0); table(nhanes_0$id) #n=23651; 13866 from NHANES-III, 9785 from NHANES-IV
#Step 2: Remove missing values from ALL variables except PhenoAge
nhanes0<-nhanes_0[,-c(7)] %>% drop_na()
nhanes0<-(merge(nhanes0,nhanes_0[,c(1,7)],by = "SEQN"))
#Step 3: Replace all infinite values from PhenoAge with NA
nhanes0$PhenoAge[is.infinite(nhanes0$PhenoAge)]<-NA
nrow(nhanes0); table(nhanes0$id) #n=18794; 11774 from NHANES-III, 7020 from NHANES-IV
#IF we removed PhenoAge missing values
nrow(nhanes0 %>% na.omit); table((nhanes0 %>% na.omit)$id) #n=17450; 10823 from NHANES-III, 6627 from NHANES-IV
#Step 4: Divide database according to sex
nhanes_men<-nhanes0 %>% filter(Sex=="Men"); nhanes_women<-nhanes0 %>% filter(Sex=="Women")
nrow(nhanes_men); table(nhanes_men$id) #9289 men; 5728 from NHANES-III, 3561 from NHANES-IV
nrow(nhanes_women); table(nhanes_women$id) #9505 women; 6046 from NHANES-III, 3459 from NHANES-IV
####---- Variable transformations ----####
#Transformed anthropometric measures
nhanes0$tr_weight<-log(nhanes0$Weight)
nhanes0$tr_imc<-log(nhanes0$BMI)
nhanes0$tr_ice<-nhanes0$ICE**(1/3)
nhanes0$tr_subs<-(nhanes0$Subscapular_skinfold)**(1/3)
nhanes0$tr_tric<-(nhanes0$Triceps_skinfold)**(1/3)
nhanes0$tr_height<-(nhanes0$Height)**(1/3)
nhanes0$tr_leg<-nhanes0$Leg_length #No transformation
nhanes0$tr_arm<-log(nhanes0$Arm_length)
nhanes0$tr_thigh<-log(nhanes0$Thigh_circumference)
nhanes0$tr_armc<-sqrt(nhanes0$Arm_circumference)
#Supplementary figure 1
ttab_s <- nhanes0 %>% select(
Weight, BMI, ICE, Subscapular_skinfold, Triceps_skinfold, Height, Leg_length, Arm_length, Thigh_circumference, Arm_circumference) %>%
apply(2,ad.test) %>% sapply(extract, "statistic") %>% as.numeric %>% cbind(nhanes0 %>% select(
tr_weight, tr_imc, tr_ice, tr_subs, tr_tric, tr_height, tr_leg, tr_arm, tr_thigh, tr_armc) %>% apply(2,ad.test) %>%
sapply(extract, "statistic") %>% as.numeric()) %>% apply(2,round,3); options(scipen = -1000); ttab_pA <- nhanes0 %>% select(
Weight, BMI, ICE, Subscapular_skinfold, Triceps_skinfold, Height, Leg_length, Arm_length, Thigh_circumference, Arm_circumference) %>%
apply(2,ad.test) %>% sapply(extract, "p.value") %>% as.character() %>% strsplit(split="e-") %>%
sapply(as.numeric) %>% round(3); options(scipen = 1000); ttab_pA <- paste0(ttab_pA[1,], "e-", ttab_pA[2,]); options(
scipen = -1000); ttab_pB <- nhanes0 %>% select(
tr_weight, tr_imc, tr_ice, tr_subs, tr_tric, tr_height, tr_leg, tr_arm, tr_thigh, tr_armc) %>%
apply(2,ad.test) %>% sapply(extract, "p.value") %>% as.character() %>% strsplit(split="e-") %>%
sapply(as.numeric) %>% round(3); options(scipen = 1000); ttab_pB <- paste0(ttab_pB[1,], "e-", ttab_pB[2,]); ttab_n <- c(
"Weight (kg)", "Body Mass Index (kg/m2)", "Waist-to-Height ratio", "Subscapular skinfold (cm)", "Triceps skinfold (cm)",
"Height (cm)", "Leg length (cm)", "Arm length (cm)", "Thigh circumference (cm)", "Arm circumference (cm)"); ttab_t <-c(
"Logarithmic", "Logarithmic", "Cubic root", "Cubic root", "Cubic root", "Cubic root", "None", "Logarithmic", "Logarithmic", "Square root"
); tr_tab <- data.frame(ttab_n, round((ttab_s[,1]), 3), ttab_pA, ttab_t, round((ttab_s[,2]), 3), ttab_pB) %>% `colnames<-`(c(
"Variable", "A-statistic (prior)", "p-value (prior)", "Transformation", "A-statistic (transformed)", "p-value (transformed)")
); supptab2<-align(flextable(tr_tab,cwidth = c(2,1.5,1.5,2,1)),align = "center",part = "all"); options(scipen = 10)
suppFZ <- ggarrange(nrow=2, ncol=5, common.legend = T, legend = "bottom",
(ggplot(nhanes0, aes(x=tr_weight, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Weight (log)")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top")),
(ggplot(nhanes0, aes(x=tr_imc, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Body Mass Index (log)")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top")),
(ggplot(nhanes0, aes(x=tr_ice, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Waist-to-Height ratio (cubic root)")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top")),
(ggplot(nhanes0, aes(x=tr_subs, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Subscapular skinfold (cubic root)")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top")),
(ggplot(nhanes0, aes(x=tr_tric, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Triceps skinfold (cubic root)")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top")),
(ggplot(nhanes0, aes(x=tr_height, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Height (cubic root)")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top")),
(ggplot(nhanes0, aes(x=tr_leg, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Leg length")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top")),
(ggplot(nhanes0, aes(x=tr_arm, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Arm length (log)")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top")),
(ggplot(nhanes0, aes(x=tr_thigh, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Thigh circumference (log)")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top")),
(ggplot(nhanes0, aes(x=tr_armc, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+
theme_pubclean()+xlab("Arm circumference (square root)")+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "top"))) %>%
annotate_figure(top = text_grob("Distribution of transformed anthropometric measurements", face = "bold", size = 20)) %>%
ggarrange(" ", ncol=1, nrow=2, heights = c(1,0.5)) + annotation_custom(tableGrob(
tr_tab, rows=NULL, theme=ttheme_minimal(base_size = 13, padding = unit(c(23, 3.5), "mm"))), xmin=0, xmax=1, ymin=0.12, ymax=0.22)
ggsave(suppFZ,filename = "SuppFig1.jpg", width = 38.1, height = 23.8, units=c("cm"), dpi = 300, limitsize = FALSE)
####---- Descriptive statistics ----####
## Flowchart diagram
#Overall NHANES population
N1 <- NHANES3 %>% filter(!duplicated(SEQN)) %>% nrow + NHANES %>% filter(!duplicated(SEQN)) %>% nrow; N1
N1.III <- NHANES3 %>% filter(!duplicated(SEQN)) %>% nrow; N1.III; N1.IV <- NHANES %>% filter(!duplicated(SEQN)) %>% nrow; N1.IV
#Filtered by age >=20 years
NHANES3 %>% filter(!duplicated(SEQN) & HSAGEIR.x>=20) %>% nrow + NHANES %>% filter(!duplicated(SEQN) & RIDAGEYR>=20) %>% nrow
NHANES3 %>% filter(!duplicated(SEQN) & HSAGEIR.x>=20) %>% nrow; NHANES %>% filter(!duplicated(SEQN) & RIDAGEYR>=20) %>% nrow
#After removing missing data from anthropometric and mortality data
nrow(nhanes0); table(nhanes0$id)
#After removing missing data from laboratory data and PhenoAge
nrow(nhanes0 %>% na.omit); table(nhanes0 %>% na.omit %>% select(id))
#Anthropometry: Men vs Women
((nhanes0[,c(7:17)]) %>% apply(2,function(x){wilcox.test(x~nhanes0$Sex)}) %>% sapply(extract,"p.value") %>%
as.numeric %>% `names<-`(names(nhanes0[,c(7:17)])))[c(10,8,7,11,2,9,12,6:3)-1]
##Supplementary table 2
# Sex
Male0 <- table(nhanes0$Sex)[2]
pMale0 <- round(((table(nhanes0$Sex)%>%prop.table())[2])*100,1)
Male1 <- table((nhanes0%>% filter(id==1))$Sex)[2]
pMale1 <- round(((table((nhanes0%>% filter(id==1))$Sex)%>%prop.table())[2])*100,1)
Male2 <- table((nhanes0%>% filter(id==2))$Sex)[2]
pMale2 <- round(((table((nhanes0%>% filter(id==2))$Sex)%>%prop.table())[2])*100,1)
p1 <- format.pval(prop.test(x=c(Male1,Male2), n=c(nrow((nhanes0%>% filter(id==1))),nrow((nhanes0%>% filter(id==2)))))$p.value, eps = .001, digits = 3)
# Age
Age0 <- round(summary(nhanes0$Age)[3],2)
Age0.1 <- round(summary(nhanes0$Age)[2],2)
Age0.3 <- round(summary(nhanes0$Age)[5],2)
Age1 <- round(summary((nhanes0%>% filter(id==1))$Age)[3],2)
Age1.1 <- round(summary((nhanes0%>% filter(id==1))$Age)[2],2)
Age1.3 <- round(summary((nhanes0%>% filter(id==1))$Age)[5],2)
Age2 <- round(summary((nhanes0%>% filter(id==2))$Age)[3],2)
Age2.1 <- round(summary((nhanes0%>% filter(id==2))$Age)[2],2)
Age2.3 <- round(summary((nhanes0%>% filter(id==2))$Age)[5],2)
p2 <- format.pval(wilcox.test(nhanes0$Age~nhanes0$id)$p.value, eps = .001, digits = 3)
#Ethnicity
#White
WEth0 <- table(nhanes0$Ethnicity)[1]
WpEth0 <- round(((table(nhanes0$Ethnicity)%>%prop.table())[1])*100,1)
WEth1 <- table((nhanes0%>% filter(id==1))$Ethnicity)[1]
WpEth1 <- round(((table((nhanes0%>% filter(id==1))$Ethnicity)%>%prop.table())[1])*100,1)
WEth2 <- table((nhanes0%>% filter(id==2))$Ethnicity)[1]
WpEth2 <- round(((table((nhanes0%>% filter(id==2))$Ethnicity)%>%prop.table())[1])*100,1)
#Black
BEth0 <- table(nhanes0$Ethnicity)[2]
BpEth0 <- round(((table(nhanes0$Ethnicity)%>%prop.table())[2])*100,1)
BEth1 <- table((nhanes0%>% filter(id==1))$Ethnicity)[2]
BpEth1 <- round(((table((nhanes0%>% filter(id==1))$Ethnicity)%>%prop.table())[2])*100,1)
BEth2 <- table((nhanes0%>% filter(id==2))$Ethnicity)[2]
BpEth2 <- round(((table((nhanes0%>% filter(id==2))$Ethnicity)%>%prop.table())[2])*100,1)
#Mexican-American
MEth0 <- table(nhanes0$Ethnicity)[3]
MpEth0 <- round(((table(nhanes0$Ethnicity)%>%prop.table())[3])*100,1)
MEth1 <- table((nhanes0%>% filter(id==1))$Ethnicity)[3]
MpEth1 <- round(((table((nhanes0%>% filter(id==1))$Ethnicity)%>%prop.table())[3])*100,1)
MEth2 <- table((nhanes0%>% filter(id==2))$Ethnicity)[3]
MpEth2 <- round(((table((nhanes0%>% filter(id==2))$Ethnicity)%>%prop.table())[3])*100,1)
pEthn <- ((with(nhanes0, table(Ethnicity,id)) %>% prop.test)$p.value) %>%
format.pval(eps = .001, digits = 3)
# PhenoAge
PhenoAge0 <- round(summary(nhanes0$PhenoAge)[3],2)
PhenoAge0.1 <- round(summary(nhanes0$PhenoAge)[2],2)
PhenoAge0.3 <- round(summary(nhanes0$PhenoAge)[5],2)
PhenoAge1 <- round(summary((nhanes0%>% filter(id==1))$PhenoAge)[3],2)
PhenoAge1.1 <- round(summary((nhanes0%>% filter(id==1))$PhenoAge)[2],2)
PhenoAge1.3 <- round(summary((nhanes0%>% filter(id==1))$PhenoAge)[5],2)
PhenoAge2 <- round(summary((nhanes0%>% filter(id==2))$PhenoAge)[3],2)
PhenoAge2.1 <- round(summary((nhanes0%>% filter(id==2))$PhenoAge)[2],2)
PhenoAge2.3 <- round(summary((nhanes0%>% filter(id==2))$PhenoAge)[5],2)
p3 <- format.pval(wilcox.test(nhanes0$PhenoAge~nhanes0$id)$p.value, eps = .001, digits = 3)
# >= 1 comorb
nhanes0$comorb<-ifelse(nhanes0$num_comorb>=1, 1, 0)
Comorb0 <- table(nhanes0$comorb)[2]
pComorb0 <- round(((table(nhanes0$comorb)%>%prop.table())[2])*100,1)
Comorb1 <- table((nhanes0%>% filter(id==1))$comorb)[2]
pComorb1 <- round(((table((nhanes0%>% filter(id==1))$comorb)%>%prop.table())[2])*100,1)
Comorb2 <- table((nhanes0%>% filter(id==2))$comorb)[2]
pComorb2 <- round(((table((nhanes0%>% filter(id==2))$comorb)%>%prop.table())[2])*100,1)
p4 <- format.pval(prop.test(x=c(Comorb1,Comorb2), n=c(nrow((nhanes0%>% filter(id==1))),nrow((nhanes0%>% filter(id==2)))))$p.value, eps = .001, digits = 3)
# Comorb list
nhanestab3 <- nhanes0 %>% filter(id==1); nhanestab4 <- nhanes0 %>% filter(id==2)
comorb_list0 <- paste0(
(nhanes0[,c(29:38)] %>% apply(2,sum)) %>% sort(decreasing = T), " (",
((((nhanes0[,c(29:38)] %>% apply(2,sum)) / nrow(nhanes0)) %>% sort(decreasing = T) %>% round(3)) * 100), ")")
comorb_list1 <- paste0(
(nhanestab3[,c(29:38)] %>% apply(2,sum)) %>% sort(decreasing = T), " (",
((((nhanestab3[,c(29:38)] %>% apply(2,sum)) / nrow(nhanestab3)) %>% sort(decreasing = T) %>% round(3)) * 100), ")")
comorb_list2 <- paste0(
(nhanestab4[,c(29:38)] %>% apply(2,sum)) %>% sort(decreasing = T), " (",
((((nhanestab4[,c(29:38)] %>% apply(2,sum)) / nrow(nhanestab4)) %>% sort(decreasing = T) %>% round(3)) * 100), ")")
p_comlist <- nhanes0[,c(29:38)] %>% lapply(table, nhanes0$id) %>% lapply(prop.test) %>%
sapply(extract, "p.value") %>% as.numeric %>% format.pval(eps = .001, digits = 3)
# Mortality
Mort0 <- table(nhanes0$mortstat)[2]
pMort0 <- round(((table(nhanes0$mortstat)%>%prop.table())[2])*100,1)
Mort1 <- table((nhanes0%>% filter(id==1))$mortstat)[2]
pMort1 <- round(((table((nhanes0%>% filter(id==1))$mortstat)%>%prop.table())[2])*100,1)
Mort2 <- table((nhanes0%>% filter(id==2))$mortstat)[2]
pMort2 <- round(((table((nhanes0%>% filter(id==2))$mortstat)%>%prop.table())[2])*100,1)
p5 <- format.pval(prop.test(x=c(Mort1,Mort2), n=c(nrow((nhanes0%>% filter(id==1))),nrow((nhanes0%>% filter(id==2)))))$p.value, eps = .001, digits = 3)
#Follow-up time
fut0 <- round(summary(nhanes0$permth_int)[3],2)
fut0.1 <- round(summary(nhanes0$permth_int)[2],2)
fut0.3 <- round(summary(nhanes0$permth_int)[5],2)
fut1 <- round(summary((nhanes0%>% filter(id==1))$permth_int)[3],2)
fut1.1 <- round(summary((nhanes0%>% filter(id==1))$permth_int)[2],2)
fut1.3 <- round(summary((nhanes0%>% filter(id==1))$permth_int)[5],2)
fut2 <- round(summary((nhanes0%>% filter(id==2))$permth_int)[3],2)
fut2.1 <- round(summary((nhanes0%>% filter(id==2))$permth_int)[2],2)
fut2.3 <- round(summary((nhanes0%>% filter(id==2))$permth_int)[5],2)
p6<- format.pval(wilcox.test(nhanes0$permth_int~nhanes0$id)$p.value, eps = .001, digits = 3)
## Anthropometric measurements ##
#Height Women
hei_w0 <- round(summary(nhanes_women$Height)[3],2)
hei_w0.1 <- round(summary(nhanes_women$Height)[2],2)
hei_w0.3 <- round(summary(nhanes_women$Height)[5],2)
hei_w1 <- round(summary((nhanes_women%>% filter(id==1))$Height)[3],2)
hei_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$Height)[2],2)
hei_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$Height)[5],2)
hei_w2 <- round(summary((nhanes_women%>% filter(id==2))$Height)[3],2)
hei_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$Height)[2],2)
hei_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$Height)[5],2)
p_hei1<- format.pval(wilcox.test(nhanes_women$Height~nhanes_women$id)$p.value, eps = .001, digits = 3)
#Height Men
hei_m0 <- round(summary(nhanes_men$Height)[3],2)
hei_m0.1 <- round(summary(nhanes_men$Height)[2],2)
hei_m0.3 <- round(summary(nhanes_men$Height)[5],2)
hei_m1 <- round(summary((nhanes_men%>% filter(id==1))$Height)[3],2)
hei_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$Height)[2],2)
hei_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$Height)[5],2)
hei_m2 <- round(summary((nhanes_men%>% filter(id==2))$Height)[3],2)
hei_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$Height)[2],2)
hei_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$Height)[5],2)
p_hei2<- format.pval(wilcox.test(nhanes_men$Height~nhanes_men$id)$p.value, eps = .001, digits = 3)
#Arm Length Women
arml_w0 <- round(summary(nhanes_women$Arm_length)[3],2)
arml_w0.1 <- round(summary(nhanes_women$Arm_length)[2],2)
arml_w0.3 <- round(summary(nhanes_women$Arm_length)[5],2)
arml_w1 <- round(summary((nhanes_women%>% filter(id==1))$Arm_length)[3],2)
arml_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$Arm_length)[2],2)
arml_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$Arm_length)[5],2)
arml_w2 <- round(summary((nhanes_women%>% filter(id==2))$Arm_length)[3],2)
arml_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$Arm_length)[2],2)
arml_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$Arm_length)[5],2)
p15<- format.pval(wilcox.test(nhanes_women$Arm_length~nhanes_women$id)$p.value, eps = .001, digits = 3)
#Arm Length Men
arml_m0 <- round(summary(nhanes_men$Arm_length)[3],2)
arml_m0.1 <- round(summary(nhanes_men$Arm_length)[2],2)
arml_m0.3 <- round(summary(nhanes_men$Arm_length)[5],2)
arml_m1 <- round(summary((nhanes_men%>% filter(id==1))$Arm_length)[3],2)
arml_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$Arm_length)[2],2)
arml_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$Arm_length)[5],2)
arml_m2 <- round(summary((nhanes_men%>% filter(id==2))$Arm_length)[3],2)
arml_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$Arm_length)[2],2)
arml_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$Arm_length)[5],2)
p16<- format.pval(wilcox.test(nhanes_men$Arm_length~nhanes_men$id)$p.value, eps = .001, digits = 3)
#Leg length Women
leg_w0 <- round(summary(nhanes_women$Leg_length)[3],2)
leg_w0.1 <- round(summary(nhanes_women$Leg_length)[2],2)
leg_w0.3 <- round(summary(nhanes_women$Leg_length)[5],2)
leg_w1 <- round(summary((nhanes_women%>% filter(id==1))$Leg_length)[3],2)
leg_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$Leg_length)[2],2)
leg_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$Leg_length)[5],2)
leg_w2 <- round(summary((nhanes_women%>% filter(id==2))$Leg_length)[3],2)
leg_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$Leg_length)[2],2)
leg_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$Leg_length)[5],2)
p_leg1<- format.pval(wilcox.test(nhanes_women$Leg_length~nhanes_women$id)$p.value, eps = .001, digits = 3)
#Leg length Men
leg_m0 <- round(summary(nhanes_men$Leg_length)[3],2)
leg_m0.1 <- round(summary(nhanes_men$Leg_length)[2],2)
leg_m0.3 <- round(summary(nhanes_men$Leg_length)[5],2)
leg_m1 <- round(summary((nhanes_men%>% filter(id==1))$Leg_length)[3],2)
leg_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$Leg_length)[2],2)
leg_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$Leg_length)[5],2)
leg_m2 <- round(summary((nhanes_men%>% filter(id==2))$Leg_length)[3],2)
leg_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$Leg_length)[2],2)
leg_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$Leg_length)[5],2)
p_leg2<- format.pval(wilcox.test(nhanes_men$Leg_length~nhanes_men$id)$p.value, eps = .001, digits = 3)
#Weight Women
wei_w0 <- round(summary(nhanes_women$Weight)[3],2)
wei_w0.1 <- round(summary(nhanes_women$Weight)[2],2)
wei_w0.3 <- round(summary(nhanes_women$Weight)[5],2)
wei_w1 <- round(summary((nhanes_women%>% filter(id==1))$Weight)[3],2)
wei_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$Weight)[2],2)
wei_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$Weight)[5],2)
wei_w2 <- round(summary((nhanes_women%>% filter(id==2))$Weight)[3],2)
wei_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$Weight)[2],2)
wei_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$Weight)[5],2)
p_wei1<- format.pval(wilcox.test(nhanes_women$Weight~nhanes_women$id)$p.value, eps = .001, digits = 3)
#Weight Men
wei_m0 <- round(summary(nhanes_men$Weight)[3],2)
wei_m0.1 <- round(summary(nhanes_men$Weight)[2],2)
wei_m0.3 <- round(summary(nhanes_men$Weight)[5],2)
wei_m1 <- round(summary((nhanes_men%>% filter(id==1))$Weight)[3],2)
wei_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$Weight)[2],2)
wei_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$Weight)[5],2)
wei_m2 <- round(summary((nhanes_men%>% filter(id==2))$Weight)[3],2)
wei_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$Weight)[2],2)
wei_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$Weight)[5],2)
p_wei2<- format.pval(wilcox.test(nhanes_men$Weight~nhanes_men$id)$p.value, eps = .001, digits = 3)
#BMI Women
bmi_w0 <- round(summary(nhanes_women$BMI)[3],2)
bmi_w0.1 <- round(summary(nhanes_women$BMI)[2],2)
bmi_w0.3 <- round(summary(nhanes_women$BMI)[5],2)
bmi_w1 <- round(summary((nhanes_women%>% filter(id==1))$BMI)[3],2)
bmi_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$BMI)[2],2)
bmi_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$BMI)[5],2)
bmi_w2 <- round(summary((nhanes_women%>% filter(id==2))$BMI)[3],2)
bmi_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$BMI)[2],2)
bmi_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$BMI)[5],2)
p7<- format.pval(wilcox.test(nhanes_women$BMI~nhanes_women$id)$p.value, eps = .001, digits = 3)
#BMI Men
bmi_m0 <- round(summary(nhanes_men$BMI)[3],2)
bmi_m0.1 <- round(summary(nhanes_men$BMI)[2],2)
bmi_m0.3 <- round(summary(nhanes_men$BMI)[5],2)
bmi_m1 <- round(summary((nhanes_men%>% filter(id==1))$BMI)[3],2)
bmi_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$BMI)[2],2)
bmi_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$BMI)[5],2)
bmi_m2 <- round(summary((nhanes_men%>% filter(id==2))$BMI)[3],2)
bmi_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$BMI)[2],2)
bmi_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$BMI)[5],2)
p8<- format.pval(wilcox.test(nhanes_men$BMI~nhanes_men$id)$p.value, eps = .001, digits = 3)
#Waist Women
cin_w0 <- round(summary(nhanes_women$Waist)[3],2)
cin_w0.1 <- round(summary(nhanes_women$Waist)[2],2)
cin_w0.3 <- round(summary(nhanes_women$Waist)[5],2)
cin_w1 <- round(summary((nhanes_women%>% filter(id==1))$Waist)[3],2)
cin_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$Waist)[2],2)
cin_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$Waist)[5],2)
cin_w2 <- round(summary((nhanes_women%>% filter(id==2))$Waist)[3],2)
cin_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$Waist)[2],2)
cin_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$Waist)[5],2)
p_cin1<- format.pval(wilcox.test(nhanes_women$Waist~nhanes_women$id)$p.value, eps = .001, digits = 3)
#Waist Men
cin_m0 <- round(summary(nhanes_men$Waist)[3],2)
cin_m0.1 <- round(summary(nhanes_men$Waist)[2],2)
cin_m0.3 <- round(summary(nhanes_men$Waist)[5],2)
cin_m1 <- round(summary((nhanes_men%>% filter(id==1))$Waist)[3],2)
cin_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$Waist)[2],2)
cin_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$Waist)[5],2)
cin_m2 <- round(summary((nhanes_men%>% filter(id==2))$Waist)[3],2)
cin_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$Waist)[2],2)
cin_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$Waist)[5],2)
p_cin2<- format.pval(wilcox.test(nhanes_men$Waist~nhanes_men$id)$p.value, eps = .001, digits = 3)
#ICE Women
ice_w0 <- round(summary(nhanes_women$ICE)[3],2)
ice_w0.1 <- round(summary(nhanes_women$ICE)[2],2)
ice_w0.3 <- round(summary(nhanes_women$ICE)[5],2)
ice_w1 <- round(summary((nhanes_women%>% filter(id==1))$ICE)[3],2)
ice_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$ICE)[2],2)
ice_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$ICE)[5],2)
ice_w2 <- round(summary((nhanes_women%>% filter(id==2))$ICE)[3],2)
ice_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$ICE)[2],2)
ice_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$ICE)[5],2)
p9<- format.pval(wilcox.test(nhanes_women$ICE~nhanes_women$id)$p.value, eps = .001, digits = 3)
#ICE Men
ice_m0 <- round(summary(nhanes_men$ICE)[3],2)
ice_m0.1 <- round(summary(nhanes_men$ICE)[2],2)
ice_m0.3 <- round(summary(nhanes_men$ICE)[5],2)
ice_m1 <- round(summary((nhanes_men%>% filter(id==1))$ICE)[3],2)
ice_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$ICE)[2],2)
ice_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$ICE)[5],2)
ice_m2 <- round(summary((nhanes_men%>% filter(id==2))$ICE)[3],2)
ice_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$ICE)[2],2)
ice_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$ICE)[5],2)
p10<- format.pval(wilcox.test(nhanes_men$ICE~nhanes_men$id)$p.value, eps = .001, digits = 3)
#Subscapular skinfold Women
subs_w0 <- round(summary(nhanes_women$Subscapular_skinfold)[3],2)
subs_w0.1 <- round(summary(nhanes_women$Subscapular_skinfold)[2],2)
subs_w0.3 <- round(summary(nhanes_women$Subscapular_skinfold)[5],2)
subs_w1 <- round(summary((nhanes_women%>% filter(id==1))$Subscapular_skinfold)[3],2)
subs_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$Subscapular_skinfold)[2],2)
subs_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$Subscapular_skinfold)[5],2)
subs_w2 <- round(summary((nhanes_women%>% filter(id==2))$Subscapular_skinfold)[3],2)
subs_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$Subscapular_skinfold)[2],2)
subs_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$Subscapular_skinfold)[5],2)
p19<- format.pval(wilcox.test(nhanes_women$Subscapular_skinfold~nhanes_women$id)$p.value, eps = .001, digits = 3)
#Subscapular skinfold Men
subs_m0 <- round(summary(nhanes_men$Subscapular_skinfold)[3],2)
subs_m0.1 <- round(summary(nhanes_men$Subscapular_skinfold)[2],2)
subs_m0.3 <- round(summary(nhanes_men$Subscapular_skinfold)[5],2)
subs_m1 <- round(summary((nhanes_men%>% filter(id==1))$Subscapular_skinfold)[3],2)
subs_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$Subscapular_skinfold)[2],2)
subs_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$Subscapular_skinfold)[5],2)
subs_m2 <- round(summary((nhanes_men%>% filter(id==2))$Subscapular_skinfold)[3],2)
subs_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$Subscapular_skinfold)[2],2)
subs_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$Subscapular_skinfold)[5],2)
p20<- format.pval(wilcox.test(nhanes_men$Subscapular_skinfold~nhanes_men$id)$p.value, eps = .001, digits = 3)
#Triceps skinfold Women
tric_w0 <- round(summary(nhanes_women$Triceps_skinfold)[3],2)
tric_w0.1 <- round(summary(nhanes_women$Triceps_skinfold)[2],2)
tric_w0.3 <- round(summary(nhanes_women$Triceps_skinfold)[5],2)
tric_w1 <- round(summary((nhanes_women%>% filter(id==1))$Triceps_skinfold)[3],2)
tric_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$Triceps_skinfold)[2],2)
tric_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$Triceps_skinfold)[5],2)
tric_w2 <- round(summary((nhanes_women%>% filter(id==2))$Triceps_skinfold)[3],2)
tric_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$Triceps_skinfold)[2],2)
tric_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$Triceps_skinfold)[5],2)
p17<- format.pval(wilcox.test(nhanes_women$Triceps_skinfold~nhanes_women$id)$p.value, eps = .001, digits = 3)
#Triceps skinfold Men
tric_m0 <- round(summary(nhanes_men$Triceps_skinfold)[3],2)
tric_m0.1 <- round(summary(nhanes_men$Triceps_skinfold)[2],2)
tric_m0.3 <- round(summary(nhanes_men$Triceps_skinfold)[5],2)
tric_m1 <- round(summary((nhanes_men%>% filter(id==1))$Triceps_skinfold)[3],2)
tric_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$Triceps_skinfold)[2],2)
tric_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$Triceps_skinfold)[5],2)
tric_m2 <- round(summary((nhanes_men%>% filter(id==2))$Triceps_skinfold)[3],2)
tric_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$Triceps_skinfold)[2],2)
tric_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$Triceps_skinfold)[5],2)
p18<- format.pval(wilcox.test(nhanes_men$Triceps_skinfold~nhanes_men$id)$p.value, eps = .001, digits = 3)
#Arm circumference Women
armc_w0 <- round(summary(nhanes_women$Arm_circumference)[3],2)
armc_w0.1 <- round(summary(nhanes_women$Arm_circumference)[2],2)
armc_w0.3 <- round(summary(nhanes_women$Arm_circumference)[5],2)
armc_w1 <- round(summary((nhanes_women%>% filter(id==1))$Arm_circumference)[3],2)
armc_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$Arm_circumference)[2],2)
armc_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$Arm_circumference)[5],2)
armc_w2 <- round(summary((nhanes_women%>% filter(id==2))$Arm_circumference)[3],2)
armc_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$Arm_circumference)[2],2)
armc_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$Arm_circumference)[5],2)
p13<- format.pval(wilcox.test(nhanes_women$Arm_circumference~nhanes_women$id)$p.value, eps = .001, digits = 3)
#Arm circumference Men
armc_m0 <- round(summary(nhanes_men$Arm_circumference)[3],2)
armc_m0.1 <- round(summary(nhanes_men$Arm_circumference)[2],2)
armc_m0.3 <- round(summary(nhanes_men$Arm_circumference)[5],2)
armc_m1 <- round(summary((nhanes_men%>% filter(id==1))$Arm_circumference)[3],2)
armc_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$Arm_circumference)[2],2)
armc_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$Arm_circumference)[5],2)
armc_m2 <- round(summary((nhanes_men%>% filter(id==2))$Arm_circumference)[3],2)
armc_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$Arm_circumference)[2],2)
armc_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$Arm_circumference)[5],2)
p14<- format.pval(wilcox.test(nhanes_men$Arm_circumference~nhanes_men$id)$p.value, eps = .001, digits = 3)
#Thigh circumference Women
thigh_w0 <- round(summary(nhanes_women$Thigh_circumference)[3],2)
thigh_w0.1 <- round(summary(nhanes_women$Thigh_circumference)[2],2)
thigh_w0.3 <- round(summary(nhanes_women$Thigh_circumference)[5],2)
thigh_w1 <- round(summary((nhanes_women%>% filter(id==1))$Thigh_circumference)[3],2)
thigh_w1.1 <- round(summary((nhanes_women%>% filter(id==1))$Thigh_circumference)[2],2)
thigh_w1.3 <- round(summary((nhanes_women%>% filter(id==1))$Thigh_circumference)[5],2)
thigh_w2 <- round(summary((nhanes_women%>% filter(id==2))$Thigh_circumference)[3],2)
thigh_w2.1 <- round(summary((nhanes_women%>% filter(id==2))$Thigh_circumference)[2],2)
thigh_w2.3 <- round(summary((nhanes_women%>% filter(id==2))$Thigh_circumference)[5],2)
p11<- format.pval(wilcox.test(nhanes_women$Thigh_circumference~nhanes_women$id)$p.value, eps = .001, digits = 3)
#Thigh circumference Men
thigh_m0 <- round(summary(nhanes_men$Thigh_circumference)[3],2)
thigh_m0.1 <- round(summary(nhanes_men$Thigh_circumference)[2],2)
thigh_m0.3 <- round(summary(nhanes_men$Thigh_circumference)[5],2)
thigh_m1 <- round(summary((nhanes_men%>% filter(id==1))$Thigh_circumference)[3],2)
thigh_m1.1 <- round(summary((nhanes_men%>% filter(id==1))$Thigh_circumference)[2],2)
thigh_m1.3 <- round(summary((nhanes_men%>% filter(id==1))$Thigh_circumference)[5],2)
thigh_m2 <- round(summary((nhanes_men%>% filter(id==2))$Thigh_circumference)[3],2)
thigh_m2.1 <- round(summary((nhanes_men%>% filter(id==2))$Thigh_circumference)[2],2)
thigh_m2.3 <- round(summary((nhanes_men%>% filter(id==2))$Thigh_circumference)[5],2)
p12<- format.pval(wilcox.test(nhanes_men$Thigh_circumference~nhanes_men$id)$p.value, eps = .001, digits = 3)
#Table
t0_N <- c("Female (%)","Age (years)", "Non-Hispanic White (%)", "Non-Hispanic Black (%)", "Mexican-American (%)", "PhenoAge (years)",
">=1 comorbidity (%)", "Arterial hypertension", "Arthritis", "Asthma", "Diabetes Mellitus", "Bronchitis", "Malignancy", "Heart attack",
"Heart failure", "Stroke", "Emphysema", "Mortality (%)", "Follow-up (months)", "Height Females (cm)", "Height Males (cm)",
"Arm length Females (cm)", "Arm length Males (cm)", "Leg length Females (cm)", "Leg length Males (cm)",
"Weight Females (kg)", "Weight Males (kg)", "BMI Females (kg/m2)", "BMI Males (kg/m2)",
"Waist circumference Females (cm)", "Waist circumference Males (cm)", "WHtR Females", "WHtR Males",
"Subscapular skinfold Females (cm)", "Subscapcular skinfold Males (mm)",
"Triceps skinfold Females (mm)", "Triceps skinfold Males (mm)",
"Arm circumference Females (cm)", "Arm circumference Males (cm)",
"Thigh circumference Females (cm)", "Thigh circumference Males (cm)")
t0_O <- c(paste0(Male0," (",pMale0,")"), paste0(Age0," (",Age0.1,"-",Age0.3,")"),
paste0(WEth0," (",WpEth0,")"), paste0(BEth0," (",BpEth0,")"), paste0(MEth0," (",MpEth0,")"),
paste0(PhenoAge0," (",PhenoAge0.1,"-",PhenoAge0.3,")"), paste0(Comorb0," (",pComorb0,")"),
comorb_list0, paste0(Mort0," (",pMort0,")"),paste0(fut0," (",fut0.1,"-",fut0.3,")"),
paste0(hei_w0," (",hei_w0.1,"-",hei_w0.3,")"),paste0(hei_m0," (",hei_m0.1,"-",hei_m0.3,")"),
paste0(arml_w0," (",arml_w0.1,"-",arml_w0.3,")"), paste0(arml_m0," (",arml_m0.1,"-",arml_m0.3,")"),
paste0(leg_w0," (",leg_w0.1,"-",leg_w0.3,")"),paste0(leg_m0," (",leg_m0.1,"-",leg_m0.3,")"),
paste0(wei_w0," (",wei_w0.1,"-",wei_w0.3,")"),paste0(wei_m0," (",wei_m0.1,"-",wei_m0.3,")"),
paste0(bmi_w0," (",bmi_w0.1,"-",bmi_w0.3,")"),paste0(bmi_m0," (",bmi_m0.1,"-",bmi_m0.3,")"),
paste0(cin_w0," (",cin_w0.1,"-",cin_w0.3,")"),paste0(cin_m0," (",cin_m0.1,"-",cin_m0.3,")"),
paste0(ice_w0," (",ice_w0.1,"-",ice_w0.3,")"),paste0(ice_m0," (",ice_m0.1,"-",ice_m0.3,")"),
paste0(subs_w0," (",subs_w0.1,"-",subs_w0.3,")"), paste0(subs_m0," (",subs_m0.1,"-",subs_m0.3,")"),
paste0(tric_w0," (",tric_w0.1,"-",tric_w0.3,")"), paste0(tric_m0," (",tric_m0.1,"-",tric_m0.3,")"),
paste0(armc_w0," (",armc_w0.1,"-",armc_w0.3,")"), paste0(armc_m0," (",armc_m0.1,"-",armc_m0.3,")"),
paste0(thigh_w0," (",thigh_w0.1,"-",thigh_w0.3,")"), paste0(thigh_m0," (",thigh_m0.1,"-",thigh_m0.3,")"))
t0_3 <- c(paste0(Male1," (",pMale1,")"), paste0(Age1," (",Age1.1,"-",Age1.3,")"),
paste0(WEth1," (",WpEth1,")"), paste0(BEth1," (",BpEth1,")"), paste0(MEth1," (",MpEth1,")"),
paste0(PhenoAge1," (",PhenoAge1.1,"-",PhenoAge1.3,")"), paste0(Comorb1," (",pComorb1,")"),
comorb_list1, paste0(Mort1," (",pMort1,")"),paste0(fut1," (",fut1.1,"-",fut1.3,")"),
paste0(hei_w1," (",hei_w1.1,"-",hei_w1.3,")"),paste0(hei_m1," (",hei_m1.1,"-",hei_m1.3,")"),
paste0(arml_w1," (",arml_w1.1,"-",arml_w1.3,")"), paste0(arml_m1," (",arml_m1.1,"-",arml_m1.3,")"),
paste0(leg_w1," (",leg_w1.1,"-",leg_w1.3,")"),paste0(leg_m1," (",leg_m1.1,"-",leg_m1.3,")"),
paste0(wei_w1," (",wei_w1.1,"-",wei_w1.3,")"),paste0(wei_m1," (",wei_m1.1,"-",wei_m1.3,")"),
paste0(bmi_w1," (",bmi_w1.1,"-",bmi_w1.3,")"),paste0(bmi_m1," (",bmi_m1.1,"-",bmi_m1.3,")"),
paste0(cin_w1," (",cin_w1.1,"-",cin_w1.3,")"),paste0(cin_m1," (",cin_m1.1,"-",cin_m1.3,")"),
paste0(ice_w1," (",ice_w1.1,"-",ice_w1.3,")"),paste0(ice_m1," (",ice_m1.1,"-",ice_m1.3,")"),
paste0(subs_w1," (",subs_w1.1,"-",subs_w1.3,")"), paste0(subs_m1," (",subs_m1.1,"-",subs_m1.3,")"),
paste0(tric_w1," (",tric_w1.1,"-",tric_w1.3,")"), paste0(tric_m1," (",tric_m1.1,"-",tric_m1.3,")"),
paste0(armc_w1," (",armc_w1.1,"-",armc_w1.3,")"), paste0(armc_m1," (",armc_m1.1,"-",armc_m1.3,")"),
paste0(thigh_w1," (",thigh_w1.1,"-",thigh_w1.3,")"), paste0(thigh_m1," (",thigh_m1.1,"-",thigh_m1.3,")"))
t0_4 <- c(paste0(Male2," (",pMale2,")"), paste0(Age2," (",Age2.1,"-",Age2.3,")"),
paste0(WEth2," (",WpEth2,")"), paste0(BEth2," (",BpEth2,")"), paste0(MEth2," (",MpEth2,")"),
paste0(PhenoAge2," (",PhenoAge2.1,"-",PhenoAge2.3,")"), paste0(Comorb2," (",pComorb2,")"),
comorb_list2, paste0(Mort2," (",pMort2,")"),paste0(fut2," (",fut2.1,"-",fut2.3,")"),
paste0(hei_w2," (",hei_w2.1,"-",hei_w2.3,")"),paste0(hei_m2," (",hei_m2.1,"-",hei_m2.3,")"),
paste0(arml_w2," (",arml_w2.1,"-",arml_w2.3,")"), paste0(arml_m2," (",arml_m2.1,"-",arml_m2.3,")"),
paste0(leg_w2," (",leg_w2.1,"-",leg_w2.3,")"),paste0(leg_m2," (",leg_m2.1,"-",leg_m2.3,")"),
paste0(wei_w2," (",wei_w2.1,"-",wei_w2.3,")"),paste0(wei_m2," (",wei_m2.1,"-",wei_m2.3,")"),
paste0(bmi_w2," (",bmi_w2.1,"-",bmi_w2.3,")"),paste0(bmi_m2," (",bmi_m2.1,"-",bmi_m2.3,")"),
paste0(cin_w2," (",cin_w2.1,"-",cin_w2.3,")"),paste0(cin_m2," (",cin_m2.1,"-",cin_m2.3,")"),
paste0(ice_w2," (",ice_w2.1,"-",ice_w2.3,")"),paste0(ice_m2," (",ice_m2.1,"-",ice_m2.3,")"),
paste0(subs_w2," (",subs_w2.1,"-",subs_w2.3,")"), paste0(subs_m2," (",subs_m2.1,"-",subs_m2.3,")"),
paste0(tric_w2," (",tric_w2.1,"-",tric_w2.3,")"), paste0(tric_m2," (",tric_m2.1,"-",tric_m2.3,")"),
paste0(armc_w2," (",armc_w2.1,"-",armc_w2.3,")"), paste0(armc_m2," (",armc_m2.1,"-",armc_m2.3,")"),
paste0(thigh_w2," (",thigh_w2.1,"-",thigh_w2.3,")"), paste0(thigh_m2," (",thigh_m2.1,"-",thigh_m2.3,")"))
t0_P <- c(p1,p2,"","",pEthn,p3,p4,p_comlist,p5,p6, p_hei1,p_hei2,p15,p16,p_leg1,p_leg2,
p_wei1,p_wei2,p7,p8, p_cin1,p_cin2,p9,p10, p19,p20,p17,p18, p13,p14,p11,p12)
tab0<-data.frame("Names"= t0_N, "Overall"= t0_O, "NIII"= t0_3, "NIV"= t0_4, "P"= t0_P) %>%
`names<-`(c("Characteristics","Overall (n=18,794)","NHANES-III (n=11,774)","NHANES-IV (n=7,020)","P-value")) %>%
flextable(cwidth = c(2,1.5,1.5,2,1)) %>% align(align = "center",part = "all")
save_as_docx(tab0,path="tabla1.docx")
####---- Models for anthropometric measurements ---####
### Models in men ###
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+poly(BMI,2)+num_comorb+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk1<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+poly(ICE,2)+num_comorb+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk2<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Subscapular_skinfold,2)+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk3<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Triceps_skinfold,3)+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk4<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Thigh_circumference,4)+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk5<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+Arm_length+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk6<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Arm_circumference,2)+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk7<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+Leg_length+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk8<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+Height+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk9<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Weight,2)+shape(Ethnicity),dist="gompertz",data=nhanes_men)
p1F<-1-predict(gomp1, newdata = nhanes_men ,type="survival", ci=F, times = c(120))
nhanes_men$risk10<-p1F$.pred
### Models in women ###
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(BMI,2)+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk1<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+ICE+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk2<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Subscapular_skinfold,2)+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk3<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Triceps_skinfold,2)+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk4<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Thigh_circumference,3)+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk5<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+Arm_length+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk6<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Arm_circumference,2)+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk7<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+Leg_length+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk8<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+Height+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk9<-p1F$.pred
gomp1<-flexsurvreg(Surv(permth_int,mortstat)~poly(Age,3)+num_comorb+poly(Weight,2)+shape(Ethnicity),dist="gompertz",data=nhanes_women)
p1F<-1-predict(gomp1, newdata = nhanes_women ,type="survival", ci=F, times = c(120))
nhanes_women$risk10<-p1F$.pred
### Run Figure 2 ###
nhanes_fin<-rbind(nhanes_women, nhanes_men)
F_names <- c("Height (cm)", "Arm length (cm)","Leg length (cm)",
"Weight (Kg)", "Body-mass index (kg/m2)",
"Waist-to-height ratio", "Subscapular skinfold (cm)","Triceps skinfold (cm)",
"Thigh circumference (cm)", "Arm circumference (cm)")
#Height
F_lims <- c(140,193); f1A <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=Height, y=risk9, col=Sex, fill=Sex))+geom_smooth(alpha=0.3,fullrange=F)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=Height, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[1])+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "none")))
#Arm_length
F_lims <- c(25.5,45); f1B <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=Arm_length, y=risk6, col=Sex, fill=Sex))+geom_smooth(alpha=0.3)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=Arm_length, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[2])+scale_y_continuous(name="Density", breaks = c(0,.18))+theme(legend.position = "none")))
#Leg_length
F_lims <- c(28,51); f1C <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=Leg_length, y=risk8, col=Sex, fill=Sex))+geom_smooth(alpha=0.3,fullrange=F)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=Leg_length, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[3])+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "none")))
#Weight
F_lims <- c(35,130); f1D <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=Weight, y=risk10, col=Sex, fill=Sex))+geom_smooth(alpha=0.3)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=Weight, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[4])+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "none")))
#BMI
F_lims <- c(16,50); f1E <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=BMI, y=risk1, col=Sex, fill=Sex))+geom_smooth(alpha=0.3)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=BMI, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[5])+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "none")))
#ICE
F_lims <- c(0.35,0.8); f1F <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=ICE, y=risk2, col=Sex, fill=Sex))+geom_smooth(alpha=0.3)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=ICE, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[6])+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "none")))
#Subscapular_skinfold
F_lims <- c(0,45); f1G <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=Subscapular_skinfold, y=risk3, col=Sex, fill=Sex))+geom_smooth(alpha=0.3)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=Subscapular_skinfold, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[7])+scale_y_continuous(name="Density", n.breaks = 2)+theme(legend.position = "none")))
#Triceps_skinfold
F_lims <- c(0,43); f1H <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=Triceps_skinfold, y=risk4, col=Sex, fill=Sex))+geom_smooth(alpha=0.3)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=Triceps_skinfold, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[8])+scale_y_continuous(name="Density", breaks = c(0,.08))+theme(legend.position = "none")))
#Arm_circumference
F_lims <- c(21,45); f1I <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=Arm_circumference, y=risk7, col=Sex, fill=Sex))+geom_smooth(alpha=0.3)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=Arm_circumference, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[10])+scale_y_continuous(name="Density", breaks = c(0,.1))+theme(legend.position = "none")))
#Thigh_circumference
F_lims <- c(36,71); f1J <- ggarrange(
ncol = 1, nrow = 2, heights = c(1,0.35),
(ggplot(nhanes_fin, aes(x=Thigh_circumference, y=risk5, col=Sex, fill=Sex))+geom_smooth(alpha=0.3)+scale_color_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
scale_x_continuous(name="", limits = NULL)+scale_y_continuous(name="10-year mortality risk", limits=NULL)+theme(legend.position = "none")+
scale_fill_manual(values=c("#994455","#6699CC")) + coord_cartesian(ylim = c(0,0.8), xlim = F_lims)),
(ggplot(nhanes_fin, aes(x=Thigh_circumference, fill=Sex))+geom_density(alpha=0.75,size=0.3)+scale_fill_manual(values=c("#994455","#6699CC"))+theme_pubclean()+
coord_cartesian(xlim = F_lims)+xlab(F_names[9])+scale_y_continuous(name="Density", breaks = c(0,.07))+theme(legend.position = "none")))
F_legend <- get_legend(ggplot(nhanes_fin, aes(x=Height, y=risk9, col=Sex, fill=Sex))+geom_smooth(alpha=0.3)+theme_pubclean()+
scale_color_manual(values=c("#994455","#6699CC"))+scale_fill_manual(values=c("#994455","#6699CC"))+
theme(legend.key.size = unit(0.8, 'cm'), legend.text = element_text(size=11.5), legend.title = element_text(size=14)))
fig1<-ggarrange(f1A, f1B, f1C, f1D, f1E, f1F, f1G, f1H, f1I, f1J, ncol=5, nrow=2, labels=letters[1:10], common.legend=T, legend="bottom", legend.grob=F_legend)
ggsave(fig1,filename = "Figure1.jpg", width = 43.75*0.9, height = 24*0.8, units=c("cm"), dpi = 300, limitsize = FALSE)
#Submission
ggsave(fig1,filename = "Submission/Figures/Figure_2.pdf",
width = 39.375, height = 19.2, units=c("cm"), dpi = 600, limitsize = FALSE)
#Graphical abstract
(ggplot(nhanes_fin, aes(x=Arm_circumference, y=risk7, col=Sex, fill=Sex))+
geom_smooth(alpha=0.3)+scale_color_manual(values=c("#994455","#6699CC"))+
theme_void() + coord_cartesian(ylim = c(0,0.8), xlim = c(21,45))) + theme(legend.position = "none")
####---- Development of AnthropoAge ----####
### Training and validation ###
train_nhanes <- nhanes0[nhanes0$id==1,]
test_nhanes <- nhanes0[nhanes0$id==2,]
###Gompertz models###
options(scipen=10)
gomp1aM<-flexsurvreg(Surv(permth_int,mortstat) ~ Age + poly(tr_ice,2) +
tr_armc + poly(tr_thigh,2) + shape(Ethnicity),dist="gompertz",
data=train_nhanes%>%filter(Sex=="Men")); gomp1aM; BIC(gomp1aM)
gomp1aF<-flexsurvreg(Surv(permth_int,mortstat)~Age + tr_weight + tr_ice +
tr_subs + tr_tric + poly(tr_thigh,2) + shape(Ethnicity), dist="gompertz",
data=train_nhanes%>%filter(Sex=="Women")); gomp1aF;BIC(gomp1aF)
gomp1bM<-flexsurvreg(Surv(permth_int,mortstat)~Age,dist="gompertz",data=train_nhanes%>%filter(Sex=="Men"))
gomp1bM;BIC(gomp1bM)
sM<-1/((exp(coef(gomp1bM)[1]*120)-1)/((coef(gomp1bM)[1])))
b0M<-coef(gomp1bM)[2]
b1M<-coef(gomp1bM)[3]
gomp1bF<-flexsurvreg(Surv(permth_int,mortstat)~Age,dist="gompertz",data=train_nhanes%>%filter(Sex=="Women"))
gomp1bF;BIC(gomp1bF)
sW<-1/((exp(coef(gomp1bF)[1]*120)-1)/((coef(gomp1bF)[1])))
b0W<-coef(gomp1bF)[2]
b1W<-coef(gomp1bF)[3]
### Supplementary table 3 ###
coef1M<-round(coef(gomp1aM),4)
confint1M<-round(confint(gomp1aM)[,1],4)
confint2M<-round(confint(gomp1aM)[,2],4)
bic1<-round(BIC(gomp1aM),1)
coef1F<-round(coef(gomp1aF),4)
confint1F<-round(confint(gomp1aF)[,1],4)
confint2F<-round(confint(gomp1aF)[,2],4)
bic2<-round(BIC(gomp1aF),1)
tab2 <- data.frame(
"Model"= c("AnthropoAge Males", paste0("BIC ",bic1), rep(" ",9),
"AnthropoAge Females", paste0("BIC ",bic2), rep(" ",10)),
"Parameter"=c("Shape", "Rate", "Chronological Age", "WHtR (OP,1)", "WHtR (OP,2)",
"Arm circumference", "Thigh circumference (OP,1)", "Thigh circumference (OP,2)",
"Shape (Non-Hispanic Black)", "Shape (Mexican-American)", "Shape (Other race/ethnicity)",
"Shape", "Rate", "Chronological Age", "Weight", "WHtR",
"Subscapular skinfold", "Triceps skinfold", "Thigh circumference (OP,1)", "Thigh circumference (OP,2)",
"Shape (Non-Hispanic Black)", "Shape (Mexican-American)", "Shape (Other race/ethnicity)"),
"B-coefficient"=c(coef1M,coef1F), "Lower 95%CI"=c(confint1M,confint1F), "Upper 95%CI"=c(confint2M,confint1F))
rownames(tab2)<-NULL; tab2<- tab2 %>% `names<-`(c("Model","Parameter","B-coefficient","Lower 95%CI","Upper 95%CI")) %>%
flextable(cwidth = c(1.5,2.5,1,1,1)) %>% align(align = "center",part = "all")
save_as_docx(tab2,path="tabla2.docx")
### Training dataset ###
p1F<-predict(gomp1aF, newdata =train_nhanes %>%filter(Sex=="Women"),type="survival", ci=F, times = c(120))
p1M<-predict(gomp1aM, newdata =train_nhanes %>%filter(Sex=="Men"),type="survival", ci=F, times = c(120))
train_nhanes$pred[train_nhanes$Sex=="Women"]<-as.numeric(1-p1F$.pred)
train_nhanes$pred[train_nhanes$Sex=="Men"]<-as.numeric(1-p1M$.pred)
train_nhanes$AnthropoAge[train_nhanes$Sex=="Women"]<-(log(-sW*log(1-train_nhanes$pred[train_nhanes$Sex=="Women"]))-b0W)/b1W
train_nhanes$AnthropoAge[train_nhanes$Sex=="Men"]<-(log(-sM*log(1-train_nhanes$pred[train_nhanes$Sex=="Men"]))-b0M)/b1M
# Accelerated metrics #
m1F<-lm(AnthropoAge~Age, data=train_nhanes %>% filter(Sex=="Women"))
train_nhanes$AnthropoAgeAccel[train_nhanes$Sex=="Women"]<-m1F$residuals
m1M<-lm(AnthropoAge~Age, data=train_nhanes %>% filter(Sex=="Men"))
train_nhanes$AnthropoAgeAccel[train_nhanes$Sex=="Men"]<-m1M$residuals
m1Ph<-lm(PhenoAge~Age, data=train_nhanes %>% filter(!is.infinite(PhenoAge)))
train_nhanes$PhenoAgeAccel[!is.na(train_nhanes$PhenoAge)]<-m1Ph$residuals
# Sex differences #
tapply(train_nhanes$AnthropoAge, train_nhanes$Sex, quantile)
wilcox.test(train_nhanes$AnthropoAge~as.numeric(train_nhanes$Sex)) #AnthropoAge
tapply(train_nhanes$AnthropoAgeAccel, train_nhanes$Sex, quantile)
wilcox.test(train_nhanes$AnthropoAgeAccel~as.numeric(train_nhanes$Sex)) #AnthropoAgeAccel
tapply(train_nhanes$PhenoAge, train_nhanes$Sex, quantile, na.rm=T)
wilcox.test(train_nhanes$PhenoAge~as.numeric(train_nhanes$Sex)) #PhenoAge
tapply(train_nhanes$PhenoAgeAccel, train_nhanes$Sex, quantile, na.rm=T)
wilcox.test(train_nhanes$PhenoAgeAccel~as.numeric(train_nhanes$Sex)) #PhenoAgeAccel
### Testing dataset ###
p1F<-predict(gomp1aF, newdata = test_nhanes %>% filter(Sex=="Women") ,type="survival", ci=F, times = c(120))
p1M<-predict(gomp1aM, newdata = test_nhanes %>% filter(Sex=="Men"),type="survival", ci=F, times = c(120))
test_nhanes$pred[test_nhanes$Sex=="Women"]<-as.numeric(1-p1F$.pred)
test_nhanes$pred[test_nhanes$Sex=="Men"]<-as.numeric(1-p1M$.pred)
test_nhanes$AnthropoAge[test_nhanes$Sex=="Women"]<-(log(-sW*log(1-test_nhanes$pred[test_nhanes$Sex=="Women"]))-b0W)/b1W
test_nhanes$AnthropoAge[test_nhanes$Sex=="Men"]<-(log(-sM*log(1-test_nhanes$pred[test_nhanes$Sex=="Men"]))-b0M)/b1M
# Accelerated metrics #
m1.1F<-lm(AnthropoAge~Age, data=test_nhanes %>% filter(Sex=="Women"))
test_nhanes$AnthropoAgeAccel[test_nhanes$Sex=="Women"]<-m1.1F$residuals
m1.1M<-lm(AnthropoAge~Age, data=test_nhanes %>% filter(Sex=="Men"))
test_nhanes$AnthropoAgeAccel[test_nhanes$Sex=="Men"]<-m1.1M$residuals
m1.1Ph<-lm(PhenoAge~Age, data=test_nhanes %>% filter(!is.infinite(PhenoAge)))
test_nhanes$PhenoAgeAccel[!is.na(test_nhanes$PhenoAge)]<-m1.1Ph$residuals
# Sex differences #
tapply(test_nhanes$AnthropoAge, test_nhanes$Sex, quantile) %>% lapply(round,1)
wilcox.test(test_nhanes$AnthropoAge~as.numeric(test_nhanes$Sex)) #AnthropoAge
tapply(test_nhanes$AnthropoAgeAccel, test_nhanes$Sex, quantile) %>% lapply(round,2)
wilcox.test(test_nhanes$AnthropoAgeAccel~as.numeric(test_nhanes$Sex)) #AnthropoAgeAccel
tapply(test_nhanes$PhenoAge, test_nhanes$Sex, quantile, na.rm=T) %>% lapply(round,1)
wilcox.test(test_nhanes$PhenoAge~as.numeric(test_nhanes$Sex)) #PhenoAge
tapply(test_nhanes$PhenoAgeAccel, test_nhanes$Sex, quantile, na.rm=T) %>% lapply(round,2)
wilcox.test(test_nhanes$PhenoAgeAccel~as.numeric(test_nhanes$Sex)) #PhenoAgeAccel
### Save models as RDA files to develop ShinyApp ###
# English version #
save(gomp1aM, file="Shiny App/anthropoage/Models/1_CAnthropo_M.rda")
save(gomp1aF, file="Shiny App/anthropoage/Models/2_CAnthropo_F.rda")
save(gomp1bM, file="Shiny App/anthropoage/Models/3_CAge_M.rda")
save(gomp1bF, file="Shiny App/anthropoage/Models/4_CAge_F.rda")
save(m1M, file="Shiny App/anthropoage/Models/5_CAccel_M.rda")
save(m1F, file="Shiny App/anthropoage/Models/6_CAccel_F.rda")
save(m1Ph, file="Shiny App/anthropoage/Models/13_PhenoAgeAccel.rda")
# Spanish version #
save(gomp1aM, file="Shiny App/anthropoage_es/Models/1_CAnthropo_M.rda")
save(gomp1aF, file="Shiny App/anthropoage_es/Models/2_CAnthropo_F.rda")
save(gomp1bM, file="Shiny App/anthropoage_es/Models/3_CAge_M.rda")
save(gomp1bF, file="Shiny App/anthropoage_es/Models/4_CAge_F.rda")
save(m1M, file="Shiny App/anthropoage_es/Models/5_CAccel_M.rda")
save(m1F, file="Shiny App/anthropoage_es/Models/6_CAccel_F.rda")
save(m1Ph, file="Shiny App/anthropoage_es/Models/13_PhenoAgeAccel.rda")
### Figure 2 ###
f1<-ggplot(train_nhanes, aes(x=AnthropoAge, y=Age, col=Sex))+geom_jitter(size=0.75,alpha=0.6)+geom_smooth(method="lm")+
theme_classic()+theme(legend.position = "bottom")+scale_color_manual(values=c("#994455","#8DCBE4"))
f2<-ggplot(train_nhanes, aes(x=PhenoAge, y=Age, col=Sex))+geom_jitter(size=0.75,alpha=0.6)+geom_smooth(method="lm")+
theme_classic()+theme(legend.position = "bottom")+scale_color_manual(values=c("#994455","#8DCBE4"))
f3<-ggplot(test_nhanes, aes(x=AnthropoAge, y=Age, col=Sex))+geom_jitter(size=0.75,alpha=0.6)+geom_smooth(method="lm")+
theme_classic()+theme(legend.position = "bottom")+scale_color_manual(values=c("#994455","#8DCBE4"))