Repository navigation
Expand file tree
/
Copy pathNotes.txt
More file actions
1209 lines (949 loc) · 51.5 KB
/
Copy pathNotes.txt
File metadata and controls
1209 lines (949 loc) · 51.5 KB
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
----------------------------------------------- Insights summary stats -------------------------------------------
Categorical Variables ------------------
- Target (ten_year_chd): 84.8% No vs 15.2% Yes — clear class imbalance that drives all downstream decisions
around validation and modeling.
- Rare categories to watch: prevalent_stroke (only 25 Yes, 0.6%) is near-zero variance and may be unstable in the model.
diabetes (109 Yes, 2.6%) is rare but clinically important — keep it but monitor its posterior carefully.
- bp_meds has 53 missing and only 3% exposed — rare and incomplete, missingness worth investigating.
current_smoker is well balanced (50/50) and a strong candidate predictor. education is ordinal with 4 levels and 105 missing — decide early whether to treat as ordinal or dummy-coded.
Continuous Variables --------------------
- age is the cleanest variable — skewness of 0.2, no missing, well behaved.
dia_bp and heart_rate are also relatively clean with mild skew and negligible missingness.
- glucose is the most problematic — skewness of 6.2, 388 missing, and a max of 394 which is only plausible in diabetic patients. If any of those extreme values are paired with diabetes = No, that's a data quality flag.
Missingness here is almost certainly not random (MNAR).
- tot_chol max of 696 is clinically implausible — typical clinical ceiling is around 400.
Worth cross-checking and likely removing that observation. sys_bp max of 295 is extreme but possible in a hypertensive crisis — check if paired with bp_meds = Yes or prevalent_hyp = Yes.
bmi of 56.8 is severe obesity but biologically plausible — keep it.
- cigs_per_day has median 0, mean 9, and skewness 1.2 — the zero inflation is entirely explained by non-smokers.
The real smoker distribution runs from roughly 1 to 30 (P95), which is reasonable.
((Points to Carry Forward))
- Class imbalance must be addressed through stratified splitting and validation metrics focused on AUC and calibration rather than accuracy.
Glucose needs the most careful imputation treatment given both its missingness volume and likely MNAR nature.
The redundancy between cigs_per_day and current_smoker needs a decision before modeling.
Scaling is essential given the wide range differences across variables.
And the extreme values in tot_chol and glucose should be investigated against other clinical variables before imputation.
------------------------------------------ Univariate investigation -------------------------------------
Continuous Variables (Distributions + Boxplots + Skewness) ------------------
- The density plots confirm what the summary stats suggested. Age is the cleanest variable, approximately symmetric and well-behaved.
Diastolic BP and heart rate are similarly well-distributed with mild right tails.
- The most visually striking finding is glucose — the density is almost entirely compressed near 80 with an extreme right tail stretching to 400, which the boxplot makes even clearer.
The mass of the distribution and the outliers are on completely different scales.
This reinforces that glucose extreme values are a small diabetic subpopulation, not a gradual skew.
- Cigarettes per day shows the zero-inflation clearly in the density plot — the spike at zero is dominant, then a secondary bump around 20 representing actual smokers.
This visually confirms the redundancy with current_smoker.
Total cholesterol and systolic BP both show long right tails with isolated extreme points visible in the boxplots — the tot_chol value near 700
and sys_bp near 300 are clearly separated from the main distribution, reinforcing the need to investigate those specific observations.
- BMI shows a clean unimodal distribution with a gradual right tail — the max of 56.8 is visible but not dramatically separated from the rest.
Categorical Variables -----------------------------
- Again largely confirmatory, but the visual makes the severity of some imbalances more tangible.
Prevalent stroke at 0.6% is visually almost invisible — the Yes bar is barely a line.
This is the strongest visual argument for flagging it as a potentially uninformative predictor after SSVS.
Diabetes and bp_meds tell a similar story.
- Hypertension at 31.1% Yes is the most balanced among the rare-event categoricals and is clinically meaningful — this one is worth keeping with confidence.
Current smoker being nearly 50/50 is reassuring. Education being dominated by "Some HS" at 41.6% is worth keeping
in mind when interpreting that variable's effect.
((Bottom Line))
These plots don't change anything from the summary stats but they do visually confirm two things worth carrying forward — the glucose distribution is genuinely bimodal
in nature (normal population vs diabetic subgroup) rather than just skewed, and prevalent stroke is so rare it may
cause estimation instability regardless of what SSVS does with it.
------------------------------------------ Bivariate investigation -------------------------------------
Continuous Predictors by CHD Status -------------------------
- Age is the clearest separator — the CHD=Yes distribution is visibly shifted to the right, peaking around 55-60 compared
to 40-45 for CHD=No. This is the strongest visual signal among all continuous predictors and aligns well with the literature.
- Systolic BP shows a meaningful rightward shift for CHD=Yes, with a heavier tail at higher values.
The separation is not as clean as age but is clearly present. This is an expected and important predictor.
- Cigarettes per day shows a subtle but visible difference — the CHD=Yes group has a slightly heavier distribution in the 10-30 range
relative to CHD=No. The zero spike is similar between groups, suggesting the smoking effect comes from quantity smoked
rather than smoking status alone. This is an argument for keeping cigs_per_day over current_smoker.
- Total cholesterol, diastolic BP, BMI, heart rate, and glucose show very little separation between CHD groups.
The distributions nearly overlap completely. This doesn't mean they're unimportant — it means their effect may be modest
or mediated through other variables — but expect weaker posterior inclusion probabilities for these in SSVS.
Categorical Predictors by CHD Proportion -----------------------
- Prevalent stroke stands out here despite its rarity — roughly 40% of stroke patients developed CHD versus about 15% in the non-stroke group.
This is a strong proportional signal, but the very small sample (25 cases) means this estimate is highly uncertain.
The wide credible interval in your Bayesian model will reflect that uncertainty honestly.
- Diabetes tells a similar story — about 35% CHD rate among diabetics versus 15% in non-diabetics.
Clinically meaningful and consistent with literature, though again the small n limits precision.
- Hypertension shows a clear difference — roughly 22% CHD rate among hypertensives versus about 12% in normotensives.
Well-powered enough to be reliable given 31% prevalence.
- BP medication shows elevated CHD in the Yes group, but this is likely confounded — people on BP meds already have cardiovascular risk factors.
The association reflects underlying disease severity more than the medication itself. <<<<<<<<<<<<<<<<
- Current smoker shows a modest but visible difference, consistent with the continuous density plot observation.
- Sex shows males have noticeably higher CHD proportion than females — this is a well-established finding and should be a reliable predictor.
- Education shows a gradient — lower education levels associate with slightly higher CHD proportion,
consistent with socioeconomic health literature, though the differences are modest.
Correlation Matrix ---------------------------------
- The most important finding here is the sys_bp / dia_bp correlation of 0.78 — this is substantial multicollinearity. Including both in the model simultaneously
will make their individual coefficients unstable and harder to interpret.
You should either drop one (dia_bp is typically the weaker CHD predictor), use only sys_bp, or be aware that
SSVS may select one and exclude the other depending on which explains more variance.
- cigs_per_day and current_smoker correlate at 0.77 — this confirms the redundancy we flagged earlier.
Keeping both is problematic. Given that the bivariate plot suggested cigs_per_day carries more signal, dropping current_smoker and keeping cigs_per_day is the more defensible choice.
- glucose and diabetes correlate at 0.62 — expected, but not so
high as to be a problem since they capture different things (continuous level vs clinical diagnosis). Keep both but monitor their posteriors together.
- sys_bp and prevalent_hyp correlate at 0.39 and age and sys_bp at 0.39 — moderate but not alarming.
Worth watching in the posterior but unlikely to cause serious instability.
- Correlations with the outcome (ten_year_chd) are all modest, with age (0.23) and sys_bp (0.22)
being the strongest, followed by tot_chol (0.15) and cigs_per_day (0.18). This is consistent with the density plots.
((Key Decisions to Make Before Modeling))
The correlation matrix crystallizes two decisions you need to make explicitly:
drop current_smoker in favor of cigs_per_day, and decide how to handle the sys_bp / dia_bp pair — either drop dia_bp or let SSVS handle it and report whichever gets selected.
Both decisions should be documented and justified in your write-up.
>> Drop both sys_bp and dia_bp, replace with pulse_pressure = sys_bp - dia_bp, and cite the cardiovascular literature supporting it as an independent CHD predictor. Clean, justified, and interpretable.
-------------------------------------------------- Missingness analysis ------------------------------------------
Missing Proportions ------------------------------
The bar chart tells a clear two-tier story. Glucose stands alone at 9.2% (n=388) — it is in a
completely different category from everything else. Education at 2.5% is a distant second, and everything below that
(bp_meds, tot_chol, cigs_per_day, bmi, heart_rate) is at or below 1.2% and largely negligible in terms of imputation complexity.
Heart rate with a single missing value barely warrants any treatment at all.
Missingness Pattern Across All Rows ------------------------------------
The row-level pattern plot confirms that missingness is scattered randomly across the dataset with no obvious
clustering of missing rows in a particular region of the data. Glucose missingness appears throughout the
entire index range (rows 0 to 4000), not concentrated in any particular block. This is a mild visual argument against a
systematic data collection failure at a specific time point, though it doesn't rule out MNAR.
Co-missingness (UpSet Plot) --------------------------------------
The dominant finding is that 331 observations have glucose missing alone, by far the largest bar and confirming that glucose missingness
is largely its own phenomenon. Similarly, 93 observations have education missing alone and 51 have bp_meds missing alone — these are
all single-variable missingness, not co-occurrence.
- When it comes to actual co-missingness, the intersections are very small. The only one worth noting is tot_chol and glucose
co-missing in 38 rows. Everything else is in single digits and essentially negligible. This is a clean and reassuring picture overall
((Call to action))
Drop all the observations with more than 1 missingness value (observations with co-missingness are dropped)
Assume that all missingness is MAR.
--------------------------------------- Plan for analysis ---------------------------------------
1. Drop rows with >1 missing value
2. Feature engineering — compute pulse pressure from sys_bp and dia_bp, keep current_smoker temporarily for imputation
3. Outlier detection and treatment
4. Train/test split stratified by ten_year_chd
5. Scale continuous predictors using train mean/SD only, apply same scaling to test — binary and categorical variables stay unscaled throughout
6. Bayesian imputation on train set — for each variable with missingness, fit a Bayesian model with all other variables as predictors
(continuous predictors scaled, binary/categorical unscaled, ten_year_chd included as predictor) and the target imputation variable as the unscaled outcome — generate full posterior predictive distributions for missing values
7. Apply learned imputation models to test set using train scaling parameters
8. Drop current_smoker
9. Bayesian logistic regression with SSVS for variable selection
10. Validation
--------------------------------------------------------------------------------------------------------
-------------------------------------- Drop rows with >1 missing value ---------------------------------
n_missing n
1 0 3658
2 1 521
3 2 59
4 3 2
# proportion of dropped observation by CHD (including the one observation of heart_rate)
ten_year_chd n prop
1 No 49 0.7903226
2 Yes 13 0.2096774
Prior to analysis, two exclusion criteria were applied. First, one observation with a missing heart rate value was removed,
as building a full Bayesian imputation model for a single missing value was considered unnecessary overhead. Second, 61 observations
with more than one simultaneously missing variable were removed, as jointly missing variables cannot serve as predictors in each
other's imputation models without introducing substantial additional complexity. In total, 62 observations (1.5% of the sample) were excluded.
To assess whether these exclusions were systematic with respect to the outcome, the 10-year CHD rate among excluded observations was
computed and found to be 21.0% (13 out of 62), compared to 15.2% in the full sample. While slightly elevated, the absolute number of excluded
CHD-positive cases was only 13, representing 2.0% of all 644 CHD-positive cases in the original dataset. This difference was
therefore considered negligible and unlikely to introduce meaningful bias. All subsequent analyses were conducted on the
remaining 4,178 observations.
--------------------------------------- Feature engineering ---------------------------------------
adding new column (pulse pressure) with stats:
min max mean sd
1 15 160 49.4203 14.65787
The pulse pressure range looks reasonable. A minimum of 15 and maximum of 160 are both clinically plausible
— narrow pulse pressure can occur in conditions like aortic stenosis and wide pulse pressure is common in elderly
hypertensive patients. The mean of 49.4 mmHg and SD of 14.7 are consistent with what would
be expected in a middle-aged cohort like Framingham.
No extreme outliers flagged here — the sys_bp = 295 value that concerned us earlier produced a pulse pressure
of 160 which is high but not implausible given severe hypertension. We can revisit this during the formal
outlier detection step.
----------------------------------------- Outlier detection and treatment -------------------------------------------
# A tibble: 7 × 5
variable P1 P99 min max
<chr> <dbl> <dbl> <dbl> <dbl>
1 age 35 67 32 70
2 bmi 18.2 39.0 15.5 56.8
3 cigs_per_day 0 43 0 70
4 glucose 55 175. 40 394
5 heart_rate 52 110 44 143
6 pulse_pressure 26 96.2 15 160
7 tot_chol 153 354. 107 696
Variables Needing Investigation ------------------------------------
glucose — P99 is 175 but max is 394. Anything above 200 is clinically in diabetic crisis territory. Run the cross-check against diabetes status.
tot_chol — P99 is 354 but max is 696. Anything above 500 is extremely rare clinically. Run the cross-check.
bmi — P99 is 39 but max is 56.8. Severe obesity but biologically plausible. No cross-check needed.
heart_rate — P99 is 110 but max is 143. Possible in atrial fibrillation or exercise, biologically plausible. No cross-check needed.
cigs_per_day — P99 is 43 but max is 70. Heavy but not implausible for a 1960s cohort. No cross-check needed.
pulse_pressure — P99 is 96 but max is 160. Already discussed, clinically plausible. No cross-check needed.
age — completely clean, no concern.
cross-check for glucose --------------------------------
Every single extreme glucose value (>200) is paired with diabetes = Yes. This is perfect internal consistency — these are not
data entry errors, they are genuine diabetic patients with clinically expected high glucose levels.
A glucose of 394 in a confirmed diabetic is entirely plausible and represents real biological signal that should be
retained in the model.
Removing these values would actually bias your analysis by artificially truncating the glucose distribution in diabetic
patients and weakening the glucose-CHD relationship.
cross-check for total cholesterol --------------------------------
tot_chol age sex ten_year_chd
1 600 52 Female Yes
2 696 51 Male No
Two observations with total cholesterol values of 600 and 696 mg/dL were removed.
These values exceed the typical range of heterozygous familial hypercholesterolemia and are more consistent with
the homozygous form, which is genuinely rare. In the absence of any corroborating clinical variable to validate these extremes,
they cannot be reliably distinguished from data entry errors and were therefore excluded.
((Report Paragraph for Outlier Treatment))
Outlier detection was performed on all continuous variables by examining values beyond the 1st and 99th percentiles alongside clinical plausibility thresholds.
Extreme glucose values (>200 mg/dL, n=34) were retained as all were paired with a confirmed diabetes diagnosis, representing genuine biological
signal rather than data error. Two observations with total cholesterol values of 600 and 696 mg/dL were removed as these values exceed
the typical range seen even in heterozygous familial hypercholesterolemia, cannot be corroborated by any other clinical
variable in the dataset, and cannot be reliably distinguished from data entry errors. All other continuous variables had extreme values
considered clinically plausible and were retained. Following outlier removal the analytic dataset comprised 4,176 observations.
------------------------------------------------- Bayesian imputation ----------------------------------------------
# missingness after dropping co-missingness
sex age education current_smoker cigs_per_day bp_meds prevalent_stroke prevalent_hyp
1 0 0 92 0 23 51 0 0
diabetes tot_chol bmi heart_rate glucose ten_year_chd pulse_pressure
1 0 9 13 0 331 0 0
Imputation Order (Least to Most Missing)
tot_chol (n=9) — continuous, normal model
bmi (n=13) — continuous, normal model
cigs_per_day (n=23) — continuous, keep current_smoker as key predictor
bp_meds (n=51) — binary, logistic model
education (n=92) — ordinal, ordinal logistic model
glucose (n=331) — continuous, normal model, last since most missing and benefits from all others being complete
total cholesterol imputation ------------------------------------
print(gelman.diag(posterior_totchol))
Potential scale reduction factors:
Point est. Upper C.I.
beta[1] 1 1
beta[2] 1 1
beta[3] 1 1
beta[4] 1 1
beta[5] 1 1
beta[6] 1 1
beta[7] 1 1
beta[8] 1 1
beta[9] 1 1
beta[10] 1 1
beta[11] 1 1
beta[12] 1 1
beta[13] 1 1
beta[14] 1 1
beta0 1 1
sigma 1 1
Multivariate psrf
1
> cat("\nEffective Sample Sizes:\n")
Effective Sample Sizes:
> print(effectiveSize(posterior_totchol))
beta[1] beta[2] beta[3] beta[4] beta[5] beta[6] beta[7] beta[8]
11216.650 12000.000 11315.649 5536.196 6186.369 12227.763 12000.000 11738.822
beta[9] beta[10] beta[11] beta[12] beta[13] beta[14] beta0 sigma
11321.694 11672.997 12000.000 11809.830 12000.000 11360.532 5242.812 11564.965
colnames(predictors_fit) # verify column order
[1] "sex" "age" "education" "current_smoker"
[5] "cigs_per_day" "bp_meds" "prevalent_stroke" "prevalent_hyp"
[9] "diabetes" "bmi" "heart_rate" "glucose"
[13] "ten_year_chd" "pulse_pressure"
print(summary(posterior_totchol))
Iterations = 10005:30000
Thinning interval = 5
Number of chains = 3
Sample size per chain = 4000
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
beta[1] -0.149266 0.03888 0.0003549 0.0003675
beta[2] 0.250553 0.02028 0.0001851 0.0001852
beta[3] 0.042756 0.01746 0.0001594 0.0001655
beta[4] -0.003432 0.05641 0.0005149 0.0007609
beta[5] 0.039604 0.02916 0.0002662 0.0003714
beta[6] 0.297038 0.10712 0.0009778 0.0009691
beta[7] -0.010403 0.23878 0.0021797 0.0021798
beta[8] 0.032223 0.04687 0.0004279 0.0004328
beta[9] 0.026373 0.12563 0.0011468 0.0011825
beta[10] 0.108542 0.01889 0.0001725 0.0001751
beta[11] 0.070734 0.01837 0.0001677 0.0001677
beta[12] -0.015451 0.02115 0.0001931 0.0001947
beta[13] 0.051381 0.05076 0.0004634 0.0004634
beta[14] 0.027125 0.02224 0.0002030 0.0002093
beta0 0.002569 0.04397 0.0004014 0.0006090
sigma 0.942273 0.01240 0.0001132 0.0001155
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
beta[1] -0.225523 -0.1753475 -0.149252 -0.123012 -0.07302
beta[2] 0.210761 0.2369219 0.250462 0.264453 0.29006
beta[3] 0.008388 0.0312482 0.042611 0.054707 0.07666
beta[4] -0.114590 -0.0420188 -0.002921 0.034748 0.10745
beta[5] -0.016524 0.0198418 0.039739 0.059070 0.09730
beta[6] 0.089887 0.2230968 0.297244 0.370874 0.50772
beta[7] -0.476791 -0.1728991 -0.010444 0.152741 0.45098
beta[8] -0.059321 0.0001361 0.032108 0.063858 0.12423
beta[9] -0.219017 -0.0598484 0.027537 0.111273 0.26991
beta[10] 0.070978 0.0958722 0.108511 0.121239 0.14555
beta[11] 0.034975 0.0582677 0.070807 0.083346 0.10669
beta[12] -0.056402 -0.0299051 -0.015540 -0.001064 0.02592
beta[13] -0.047496 0.0172548 0.051251 0.085525 0.15073
beta[14] -0.016193 0.0122553 0.026882 0.041989 0.07151
beta0 -0.083749 -0.0266667 0.001941 0.032756 0.08840
sigma 0.917918 0.9338686 0.942144 0.950736 0.96657
cat("Imputed train tot_chol values (original scale):\n")
Imputed train tot_chol values (original scale):
> print(imputed_train_totchol)
[1] 229 222 250 230 234 239
> cat("\n95% Credible Intervals — train (original scale):\n")
95% Credible Intervals — train (original scale):
> print(round(ci_train, 1))
[,1] [,2] [,3] [,4] [,5] [,6]
2.5% 161.6 155.4 175.1 160.6 163.5 166.9
97.5% 317.7 306.4 348.9 318.2 325.6 331.0
> cat("\nImputed test tot_chol values (original scale):\n")
Imputed test tot_chol values (original scale):
> print(imputed_test_totchol)
[1] 249 253 242
> cat("\n95% Credible Intervals — test (original scale):\n")
95% Credible Intervals — test (original scale):
> print(round(ci_test, 1))
[,1] [,2] [,3]
2.5% 174.4 175.7 168.6
97.5% 347.1 350.5 337.6
BMI imputation ------------------------------------
Potential scale reduction factors:
Point est. Upper C.I.
beta[1] 1 1
beta[2] 1 1
beta[3] 1 1
beta[4] 1 1
beta[5] 1 1
beta[6] 1 1
beta[7] 1 1
beta[8] 1 1
beta[9] 1 1
beta[10] 1 1
beta[11] 1 1
beta[12] 1 1
beta[13] 1 1
beta[14] 1 1
beta0 1 1
sigma 1 1
Multivariate psrf
1
> cat("\nEffective Sample Sizes:\n")
Effective Sample Sizes:
> print(effectiveSize(posterior_bmi))
beta[1] beta[2] beta[3] beta[4] beta[5] beta[6] beta[7] beta[8]
11098.831 12255.245 11693.360 5964.186 6231.171 12000.000 12352.728 11784.248
beta[9] beta[10] beta[11] beta[12] beta[13] beta[14] beta0 sigma
12053.124 12000.000 12802.730 11680.607 12000.000 12274.010 5481.822 12000.000
colnames(predictors_fit_bmi)
[1] "sex" "age" "education" "current_smoker"
[5] "cigs_per_day" "bp_meds" "prevalent_stroke" "prevalent_hyp"
[9] "diabetes" "tot_chol" "heart_rate" "glucose"
[13] "ten_year_chd" "pulse_pressure"
print(summary(posterior_bmi))
Iterations = 10005:30000
Thinning interval = 5
Number of chains = 3
Sample size per chain = 4000
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
beta[1] 0.27285 0.03754 0.0003427 0.0003572
beta[2] -0.02888 0.02011 0.0001836 0.0001818
beta[3] -0.10266 0.01692 0.0001545 0.0001566
beta[4] -0.33832 0.05398 0.0004928 0.0007009
beta[5] 0.02305 0.02803 0.0002559 0.0003551
beta[6] 0.06919 0.10501 0.0009586 0.0009587
beta[7] -0.30357 0.23234 0.0021210 0.0021021
beta[8] 0.54834 0.04521 0.0004127 0.0004167
beta[9] 0.24582 0.12325 0.0011252 0.0011239
beta[10] 0.10312 0.01822 0.0001663 0.0001663
beta[11] 0.01370 0.01796 0.0001640 0.0001590
beta[12] 0.01655 0.02022 0.0001846 0.0001873
beta[13] 0.03000 0.04986 0.0004552 0.0004552
beta[14] 0.01952 0.02166 0.0001978 0.0001959
beta0 -0.03759 0.04264 0.0003893 0.0005768
sigma 0.92061 0.01214 0.0001109 0.0001109
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
beta[1] 0.200682 0.247541 0.27293 0.298219 0.34580
beta[2] -0.067697 -0.042792 -0.02884 -0.015024 0.01008
beta[3] -0.136266 -0.113945 -0.10277 -0.091246 -0.06949
beta[4] -0.443931 -0.374246 -0.33832 -0.301939 -0.23472
beta[5] -0.031631 0.004134 0.02298 0.042141 0.07789
beta[6] -0.139915 -0.002139 0.07044 0.141003 0.27238
beta[7] -0.761830 -0.460453 -0.30094 -0.146759 0.14817
beta[8] 0.459555 0.517787 0.54785 0.578801 0.63623
beta[9] 0.002113 0.163898 0.24634 0.329318 0.48719
beta[10] 0.067194 0.091084 0.10307 0.115187 0.13965
beta[11] -0.021245 0.001426 0.01361 0.025728 0.04939
beta[12] -0.023091 0.002985 0.01645 0.030263 0.05616
beta[13] -0.068901 -0.003052 0.03007 0.063569 0.12906
beta[14] -0.023042 0.004825 0.01953 0.034280 0.06267
beta0 -0.120201 -0.066569 -0.03755 -0.008385 0.04656
sigma 0.897272 0.912467 0.92043 0.928644 0.94461
cat("Imputed train BMI values (original scale):\n")
Imputed train BMI values (original scale):
> print(imputed_train_bmi)
[1] 24.5 25.5 26.4 24.5 24.1 24.8 24.9 23.8 24.5 26.2 30.8 24.8 28.3
> cat("\n95% Credible Intervals — train (original scale):\n")
95% Credible Intervals — train (original scale):
> print(round(ci_train_bmi, 1))
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
2.5% 18.5 19.2 20.0 18.3 18.1 18.5 18.6 17.8 18.2 19.4 23.0 18.7 21.2
97.5% 32.1 33.1 34.5 32.0 31.6 32.3 32.6 31.1 32.2 34.6 40.5 32.5 36.6
> cat("\nImputed BMI range:", range(imputed_train_bmi), "\n")
Imputed BMI range: 23.8 30.8
> cat("Observed BMI range:", range(train$bmi, na.rm = TRUE), "\n")
Observed BMI range: 15.54 56.8
cigs/day imputation ------------------------------------
print(summary(posterior_cigs))
Iterations = 13005:28000
Thinning interval = 5
Number of chains = 3
Sample size per chain = 3000
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
beta[1] 0.5051521 0.03290 0.0003468 0.0004258
beta[2] -0.0829206 0.01777 0.0001873 0.0001879
beta[3] 0.0169363 0.01568 0.0001653 0.0001879
beta[4] 0.0277436 0.11250 0.0011858 0.0012233
beta[5] -0.1116914 0.34491 0.0036356 0.0036350
beta[6] 0.0032031 0.04353 0.0004588 0.0005202
beta[7] 0.0632889 0.11839 0.0012479 0.0012611
beta[8] 0.0020826 0.01633 0.0001721 0.0001704
beta[9] 0.0004825 0.01694 0.0001785 0.0001804
beta[10] 0.0536211 0.01624 0.0001712 0.0001712
beta[11] -0.0424417 0.01746 0.0001841 0.0001810
beta[12] 0.1523618 0.04468 0.0004710 0.0004850
beta[13] 0.0124881 0.01978 0.0002085 0.0002191
beta0 2.5583538 0.03077 0.0003243 0.0004530
r 3.4684415 0.16099 0.0016970 0.0016420
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
beta[1] 0.43992 0.4828807 0.5052818 0.52732 0.569166
beta[2] -0.11850 -0.0945750 -0.0829059 -0.07102 -0.047533
beta[3] -0.01346 0.0065739 0.0167868 0.02738 0.047904
beta[4] -0.19056 -0.0486894 0.0266163 0.10252 0.251382
beta[5] -0.75460 -0.3481618 -0.1227981 0.11427 0.601746
beta[6] -0.08182 -0.0259973 0.0023558 0.03297 0.090148
beta[7] -0.16956 -0.0150455 0.0630637 0.13924 0.303869
beta[8] -0.02971 -0.0089217 0.0023094 0.01298 0.033838
beta[9] -0.03314 -0.0109268 0.0003663 0.01175 0.034016
beta[10] 0.02176 0.0426651 0.0537445 0.06451 0.085805
beta[11] -0.07670 -0.0541662 -0.0423581 -0.03080 -0.008091
beta[12] 0.06547 0.1217212 0.1521681 0.18270 0.239872
beta[13] -0.02648 -0.0009229 0.0125978 0.02570 0.051502
beta0 2.49898 2.5374510 2.5580372 2.57868 2.620353
r 3.16248 3.3603470 3.4646281 3.57466 3.790824
> cat("\nGelman-Rubin Diagnostic:\n")
Gelman-Rubin Diagnostic:
> print(gelman.diag(posterior_cigs))
Potential scale reduction factors:
Point est. Upper C.I.
beta[1] 1 1
beta[2] 1 1
beta[3] 1 1
beta[4] 1 1
beta[5] 1 1
beta[6] 1 1
beta[7] 1 1
beta[8] 1 1
beta[9] 1 1
beta[10] 1 1
beta[11] 1 1
beta[12] 1 1
beta[13] 1 1
beta0 1 1
r 1 1
Multivariate psrf
1
> cat("\nEffective Sample Sizes:\n")
Effective Sample Sizes:
> print(effectiveSize(posterior_cigs))
beta[1] beta[2] beta[3] beta[4] beta[5] beta[6] beta[7] beta[8] beta[9] beta[10]
6006.273 8950.258 6986.084 8515.914 9000.000 7006.903 8880.579 9184.732 8824.023 9000.000
beta[11] beta[12] beta[13] beta0 r
9318.326 8495.610 8164.649 4633.367 9725.622
colnames(predictors_fit_cigs)
[1] "sex" "age" "education" "bp_meds"
[5] "prevalent_stroke" "prevalent_hyp" "diabetes" "tot_chol"
[9] "bmi" "heart_rate" "glucose" "ten_year_chd"
[13] "pulse_pressure"
bp_meds imputation ------------------------------------
due to the severe imbalance in the bp_meds, we used trivial imputation method (the modeling is instable)
cat("Hypertensives with missing bp_meds — train:", n_train_hyp_miss, "\n")
Hypertensives with missing bp_meds — train: 19
> cat("Hypertensives with missing bp_meds — test:", n_test_hyp_miss, "\n")
Hypertensives with missing bp_meds — test: 3
> # Store imputed values
> imputed_train_bp <- rbinom(n_train_hyp_miss, size = 1, prob = 0.0946)
> imputed_test_bp <- rbinom(n_test_hyp_miss, size = 1, prob = 0.0946)
> cat("\nImputed bp_meds values — train:\n")
Imputed bp_meds values — train:
> print(imputed_train_bp)
[1] 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0
> cat("n(0):", sum(imputed_train_bp == 0), "| n(1):", sum(imputed_train_bp == 1), "\n")
n(0): 17 | n(1): 2
> cat("\nImputed bp_meds values — test:\n")
Imputed bp_meds values — test:
> print(imputed_test_bp)
[1] 1 0 0
> cat("n(0):", sum(imputed_test_bp == 0), "| n(1):", sum(imputed_test_bp == 1), "\n")
n(0): 2 | n(1): 1
prevalent_hyp n n_bp_meds prop_bp
<int> <int> <dbl> <dbl>
1 0 2306 0 0
2 1 1034 98 0.0948
education imputation ------------------------------------
> print(gelman.diag(posterior_edu))
Potential scale reduction factors:
Point est. Upper C.I.
alpha[1] 1 1
alpha[2] 1 1
alpha[3] 1 1
beta[1] 1 1
beta[2] 1 1
beta[3] 1 1
beta[4] 1 1
beta[5] 1 1
beta[6] 1 1
beta[7] 1 1
beta[8] 1 1
beta[9] 1 1
beta[10] 1 1
beta[11] 1 1
beta[12] 1 1
beta[13] 1 1
Multivariate psrf
1
> cat("\nEffective Sample Sizes:\n")
Effective Sample Sizes:
> print(effectiveSize(posterior_edu))
alpha[1] alpha[2] alpha[3] beta[1] beta[2] beta[3] beta[4] beta[5] beta[6]
4166.657 5310.371 6257.212 5685.646 7950.575 7600.129 9034.971 10783.037 5307.125
beta[7] beta[8] beta[9] beta[10] beta[11] beta[12] beta[13]
7795.922 9662.928 8482.877 9315.105 7926.695 8844.523 7253.145
> print(summary(posterior_edu))
Iterations = 4003:13999
Thinning interval = 3
Number of chains = 3
Sample size per chain = 3333
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
alpha[1] -0.24290 0.05733 0.0005733 0.0008899
alpha[2] 1.05643 0.06050 0.0006051 0.0008334
alpha[3] 2.15791 0.07230 0.0007231 0.0009157
beta[1] 0.06597 0.07550 0.0007550 0.0010025
beta[2] -0.32311 0.04040 0.0004040 0.0004538
beta[3] -0.02742 0.03749 0.0003749 0.0004301
beta[4] 0.28393 0.21277 0.0021278 0.0022382
beta[5] -0.68106 0.46874 0.0046877 0.0045405
beta[6] 0.20123 0.09351 0.0009352 0.0012843
beta[7] -0.38829 0.26561 0.0026562 0.0030125
beta[8] 0.10103 0.03511 0.0003512 0.0003581
beta[9] -0.25109 0.03716 0.0003716 0.0004036
beta[10] -0.09088 0.03612 0.0003612 0.0003747
beta[11] 0.04811 0.04137 0.0004137 0.0004651
beta[12] -0.12706 0.10241 0.0010241 0.0010890
beta[13] -0.16617 0.04385 0.0004385 0.0005152
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
alpha[1] -0.35507 -0.28097 -0.24371 -0.204096 -0.13097
alpha[2] 0.93924 1.01492 1.05646 1.096068 1.17638
alpha[3] 2.01883 2.10875 2.15682 2.207199 2.30176
beta[1] -0.08582 0.01630 0.06599 0.117450 0.21395
beta[2] -0.40206 -0.35072 -0.32291 -0.295604 -0.24430
beta[3] -0.10007 -0.05248 -0.02785 -0.001755 0.04497
beta[4] -0.13653 0.13976 0.28450 0.427955 0.70471
beta[5] -1.63167 -0.98478 -0.66953 -0.363165 0.21868
beta[6] 0.01796 0.13938 0.20163 0.265213 0.38113
beta[7] -0.91451 -0.56948 -0.38287 -0.207589 0.12680
beta[8] 0.03174 0.07760 0.10120 0.124458 0.16957
beta[9] -0.32399 -0.27618 -0.25125 -0.225704 -0.17943
beta[10] -0.16051 -0.11559 -0.09122 -0.066518 -0.01999
beta[11] -0.03333 0.02064 0.04833 0.076329 0.12832
beta[12] -0.32985 -0.19713 -0.12619 -0.058407 0.07340
beta[13] -0.25085 -0.19608 -0.16614 -0.136474 -0.07971
> colnames(predictors_fit_edu)
[1] "sex" "age" "cigs_per_day" "bp_meds"
[5] "prevalent_stroke" "prevalent_hyp" "diabetes" "tot_chol"
[9] "bmi" "heart_rate" "glucose" "ten_year_chd"
[13] "pulse_pressure"
The education variable is coded as follows: 0 = Some High School (41.6%), 1 = High School Graduate (30.3%), 2 = Some College (16.7%), and 3 = College or above (11.4%). In the JAGS model, the outcome is 1-indexed, so these categories become 1 through 4 respectively.
The three estimated cutpoints divide the underlying latent scale into four education categories. The first cutpoint (α₁ = −0.24) separates Some High School from High School Graduate. The second cutpoint (α₂ = 1.06) separates High School
Graduate from Some College. The third cutpoint (α₃ = 2.16) separates Some College from College or above. The cutpoints are well
separated and precisely estimated, reflecting the clear ordering of education levels in the data. The relatively small value of α₁
is consistent with the high proportion of participants in the lowest education category (41.6%), indicating that most of the latent distribution mass
lies below the first threshold.
print(round(cum_probs, 3))
alpha1 alpha2 alpha3
0.440 0.743 0.897
> cat("\nCell probabilities:\n")
Cell probabilities:
> print(round(cell_probs, 3))
alpha1 alpha2 alpha3 alpha3
0.440 0.302 0.154 0.103
print(table(imputed_train_edu))
imputed_train_edu
0 1
63 12
> cat("\nImputed test education:\n")
Imputed test education:
> print(table(imputed_test_edu))
imputed_test_edu
0 1
15 2
glucose imputation ------------------------------------
print(gelman.diag(posterior_gluc))
Potential scale reduction factors:
Point est. Upper C.I.
beta[1] 1 1
beta[2] 1 1
beta[3] 1 1
beta[4] 1 1
beta[5] 1 1
beta[6] 1 1
beta[7] 1 1
beta[8] 1 1
beta[9] 1 1
beta[10] 1 1
beta[11] 1 1
beta[12] 1 1
beta[13] 1 1
beta0 1 1
sigma 1 1
Multivariate psrf
1
> cat("\nEffective Sample Sizes:\n")
Effective Sample Sizes:
> print(effectiveSize(posterior_gluc))
beta[1] beta[2] beta[3] beta[4] beta[5] beta[6] beta[7] beta[8] beta[9]
10853.849 12139.871 11802.579 11820.170 12568.935 11701.781 11347.035 11869.669 12000.000
beta[10] beta[11] beta[12] beta[13] beta0 sigma
12000.000 11821.583 12582.171 12629.630 9352.299 12185.597
> print(summary(posterior_gluc))
Iterations = 10005:30000
Thinning interval = 5
Number of chains = 3
Sample size per chain = 4000
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
beta[1] 0.03088 0.03329 0.0003039 3.196e-04
beta[2] 0.02932 0.01789 0.0001633 1.624e-04
beta[3] 0.01066 0.01507 0.0001375 1.387e-04
beta[4] -0.05260 0.01650 0.0001507 1.518e-04
beta[5] -0.09013 0.09234 0.0008429 8.250e-04
beta[6] 0.08908 0.19565 0.0017861 1.814e-03
beta[7] -0.02671 0.04131 0.0003771 3.881e-04
beta[8] 3.11775 0.09412 0.0008592 8.644e-04
beta[9] -0.01029 0.01600 0.0001461 1.461e-04
beta[10] 0.01572 0.01639 0.0001496 1.496e-04
beta[11] 0.06812 0.01577 0.0001440 1.451e-04
beta[12] 0.10062 0.04411 0.0004026 3.938e-04
beta[13] 0.09455 0.01934 0.0001766 1.727e-04
beta0 -0.11429 0.02793 0.0002549 2.890e-04
sigma 0.83574 0.01082 0.0000988 9.805e-05
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
beta[1] -0.03347 0.0081746 0.03095 0.0532431 0.09621
beta[2] -0.00593 0.0173765 0.02941 0.0413577 0.06390
beta[3] -0.01912 0.0006569 0.01057 0.0208714 0.04029
beta[4] -0.08490 -0.0636125 -0.05244 -0.0414984 -0.02028
beta[5] -0.26989 -0.1516055 -0.09082 -0.0286442 0.09189
beta[6] -0.30089 -0.0412694 0.08857 0.2202947 0.47611
beta[7] -0.10723 -0.0544038 -0.02692 0.0014966 0.05380
beta[8] 2.93406 3.0551195 3.11856 3.1808869 3.30282
beta[9] -0.04173 -0.0212820 -0.01036 0.0004979 0.02059
beta[10] -0.01602 0.0047511 0.01561 0.0264909 0.04814
beta[11] 0.03751 0.0573929 0.06804 0.0787262 0.09905
beta[12] 0.01518 0.0709634 0.10007 0.1294926 0.18869
beta[13] 0.05668 0.0818032 0.09452 0.1070138 0.13283
beta0 -0.16891 -0.1331696 -0.11458 -0.0951426 -0.05918
sigma 0.81464 0.8284317 0.83564 0.8431090 0.85736
> colnames(predictors_fit_gluc)
[1] "sex" "age" "education" "cigs_per_day"
[5] "bp_meds" "prevalent_stroke" "prevalent_hyp" "diabetes"
[9] "tot_chol" "bmi" "heart_rate" "ten_year_chd"
[13] "pulse_pressure"
------------------------------------------------- Bayesian Modeling of 10-year Risk of Developing CHD ----------------------------------------------
> det(t(X_train) %*% X_train)
[1] 1.075349e+39
> det(t(X_test) %*% X_test)
[1] 1.646345e+31
Both determinants are large and positive, which means:
1. No perfect multicollinearity — no predictor is an exact linear combination of others.
2. X'X is invertible — the design matrix has full column rank (rank = 13).
3. Well-conditioned for estimation — coefficients are identifiable.
Feature selection using SSVS --------------------------------------
# Diagnostics
> cat("\n--- Posterior Summary ---\n")
--- Posterior Summary ---
> print(summary(ssvs_samples))
Iterations = 13005:33000
Thinning interval = 5
Number of chains = 3
Sample size per chain = 4000
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
alpha -2.4048071 0.09973 0.0009104 0.0013031
beta[1] 0.5621012 0.06061 0.0005533 0.0006151
beta[2] 0.2945909 0.05221 0.0004766 0.0005070
beta[3] 0.0482944 0.05544 0.0005061 0.0007685
beta[4] 0.2327967 0.07207 0.0006579 0.0009715
beta[5] 0.0218124 0.03761 0.0003434 0.0005268
beta[6] 0.0019818 0.02705 0.0002469 0.0002517
beta[7] 0.1126683 0.07110 0.0006491 0.0014460
beta[8] 0.5571461 0.11323 0.0010336 0.0013244
beta[9] -0.0008596 0.02622 0.0002393 0.0002572
beta[10] 0.1356249 0.21192 0.0019346 0.0032454
beta[11] 0.2209846 0.38284 0.0034948 0.0054251
beta[12] 0.4527393 0.13241 0.0012087 0.0017889
beta[13] 0.2285270 0.31007 0.0028305 0.0066259
gamma[1] 0.9851667 0.12089 0.0011036 0.0047020
gamma[2] 0.9750000 0.15613 0.0014253 0.0071184
gamma[3] 0.2975833 0.45721 0.0041738 0.0061461
gamma[4] 0.9365000 0.24387 0.0022262 0.0081246
gamma[5] 0.1426667 0.34975 0.0031927 0.0038260
gamma[6] 0.0718333 0.25822 0.0023572 0.0023584
gamma[7] 0.6611667 0.47333 0.0043209 0.0102103
gamma[8] 0.9845833 0.12321 0.0011247 0.0052388
gamma[9] 0.0700833 0.25530 0.0023305 0.0023704
gamma[10] 0.4252500 0.49440 0.0045132 0.0083428
gamma[11] 0.4880000 0.49988 0.0045632 0.0085480
gamma[12] 0.9730000 0.16209 0.0014797 0.0065087
gamma[13] 0.5220833 0.49953 0.0045601 0.0109639
tau 21.8549968 13.15964 0.1201306 0.2309877
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
alpha -2.603277 -2.4705724 -2.4035327 -2.33808 -2.21314
beta[1] 0.446368 0.5201572 0.5621814 0.60320 0.67908
beta[2] 0.192587 0.2589676 0.2949353 0.32941 0.39801
beta[3] -0.021267 0.0090833 0.0304117 0.07703 0.18436
beta[4] 0.065970 0.1893955 0.2360048 0.28086 0.36578
beta[5] -0.031281 -0.0013480 0.0146594 0.03514 0.12422
beta[6] -0.051299 -0.0135847 0.0015360 0.01665 0.05875
beta[7] -0.007525 0.0483558 0.1212959 0.16728 0.23871
beta[8] 0.333870 0.4813778 0.5587450 0.63260 0.77945
beta[9] -0.055726 -0.0152368 -0.0003069 0.01419 0.04902
beta[10] -0.073911 -0.0034410 0.0251846 0.26355 0.65935
beta[11] -0.279120 -0.0072485 0.0244417 0.43123 1.18006
beta[12] 0.188702 0.3684797 0.4528455 0.54179 0.70901
beta[13] -0.118360 -0.0009132 0.0494760 0.45527 0.93619
gamma[1] 1.000000 1.0000000 1.0000000 1.00000 1.00000
gamma[2] 0.975000 1.0000000 1.0000000 1.00000 1.00000
gamma[3] 0.000000 0.0000000 0.0000000 1.00000 1.00000
gamma[4] 0.000000 1.0000000 1.0000000 1.00000 1.00000
gamma[5] 0.000000 0.0000000 0.0000000 0.00000 1.00000
gamma[6] 0.000000 0.0000000 0.0000000 0.00000 1.00000
gamma[7] 0.000000 0.0000000 1.0000000 1.00000 1.00000
gamma[8] 1.000000 1.0000000 1.0000000 1.00000 1.00000
gamma[9] 0.000000 0.0000000 0.0000000 0.00000 1.00000
gamma[10] 0.000000 0.0000000 0.0000000 1.00000 1.00000
gamma[11] 0.000000 0.0000000 0.0000000 1.00000 1.00000
gamma[12] 0.000000 1.0000000 1.0000000 1.00000 1.00000
gamma[13] 0.000000 0.0000000 1.0000000 1.00000 1.00000
tau 0.895534 12.3995839 19.8383126 29.24585 53.19190
> cat("\nGelman-Rubin Diagnostic:\n")
Gelman-Rubin Diagnostic:
> gelman.diag(ssvs_samples)
Potential scale reduction factors:
Point est. Upper C.I.
alpha 1.00 1.00
beta[1] 1.00 1.00
beta[2] 1.00 1.00
beta[3] 1.00 1.00
beta[4] 1.00 1.00
beta[5] 1.00 1.00
beta[6] 1.00 1.00
beta[7] 1.00 1.00
beta[8] 1.00 1.00
beta[9] 1.00 1.00
beta[10] 1.00 1.00
beta[11] 1.00 1.00
beta[12] 1.00 1.00
beta[13] 1.00 1.00
gamma[1] 1.02 1.03
gamma[2] 1.02 1.02
gamma[3] 1.00 1.00
gamma[4] 1.00 1.00
gamma[5] 1.00 1.00
gamma[6] 1.00 1.00
gamma[7] 1.00 1.00
gamma[8] 1.02 1.02
gamma[9] 1.00 1.00
gamma[10] 1.00 1.00
gamma[11] 1.00 1.00
gamma[12] 1.01 1.01
gamma[13] 1.00 1.00
tau 1.00 1.00
Multivariate psrf
1
> cat("\nEffective Sample Sizes:\n")
Effective Sample Sizes: