Every fit so far has held the variance components \(\tau^2_k\) fixed at the lmer
estimates. That is a real assumption: it says you know exactly how much
subjects vary, and it makes the posterior for everything else narrower
than it should be. This chapter relaxes it.
The choice is made per random coefficient, through the prior family.
| Family | \(\tau^2_k\) | Consequence |
|---|---|---|
dNormal |
Fixed at the reference estimate | Joint posterior stays Gaussian; exact iid draws |
dIndependent_Normal_Gamma |
Sampled, Gamma prior on \(1/\tau^2_k\) | Target no longer Gaussian; Gibbs sweeps and a pilot stage |
Calibrate as usual, adding a prior weight for the dispersion:
ps <- Prior_Setup_GLMM(form, data = dat, pop.pwt = 0.01,
pop.dispersion.pwt = 0.2)
ps$pop.ing_prior
#> $`(Intercept)`
#> $`(Intercept)`$shape
#> [1] 3.25
#>
#> $`(Intercept)`$rate
#> [1] 3028.828
#>
#> $`(Intercept)`$disp_lower
#> [1] 632.3273
#>
#> $`(Intercept)`$disp_upper
#> [1] 2998.203
#>
#> $`(Intercept)`$max_disp_perc
#> [1] 0.99
#>
#>
#> $Days_c
#> $Days_c$shape
#> [1] 3.25
#>
#> $Days_c$rate
#> [1] 66.08751
#>
#> $Days_c$disp_lower
#> [1] 13.79707
#>
#> $Days_c$disp_upper
#> [1] 65.41931
#>
#> $Days_c$max_disp_perc
#> [1] 0.99pop.dispersion.pwt = 0.2 gives the dispersion prior the
weight of about 20 percent of the groups. With only 18 subjects there is
genuinely little information about a variance component, so this is not
a small choice — compare it against 0.05 and
0.5 before trusting the width of your intervals.
Each ING component carries disp_lower and
disp_upper, and the sampled \(\tau^2_k\) is confined to that
interval.
The bounds are quantiles of the limiting posterior of the variance component, not of the prior. That distinction matters: a Gamma prior on a precision has a fat tail toward zero variance, and a \(\tau^2\) driven to zero collapses the hierarchy — every group’s coefficient is pinned to the population mean, and the sampler’s coupling becomes total. Truncating away that region is what keeps the chain geometrically ergodic.
The lower bound does double duty. The sampler evaluates its
convergence rate at disp_lower, because smaller \(\tau^2\) means tighter coupling and a
slower chain, so a bound computed there is valid across the entire
window. That is conservative rather than correct-on-average, which is
the right direction for a certificate. See
vignette("Chapter-B05", package = "lmebayesCore") and
inst/ING_TRUNCATION_WINDOW.md in the package sources.
pf_ing <- pfamily_list(ps, ptypes = "dIndependent_Normal_Gamma")
class(pf_ing[["Days_c"]])
#> [1] "pfamily"ptypes also accepts a named vector when you want to
sample some components and fix others — for example
ptypes = c("(Intercept)" = "dNormal", "Days_c" = "dIndependent_Normal_Gamma").
set.seed(1)
fit <- lmerb(form, data = dat,
pfamily_list = pf_ing,
dispersion_ranef = ps$group.dispersion,
n = 300L, progbar = FALSE)fit
#> Call:
#> lmerb(formula = form, data = dat, pfamily_list = pf_ing, dispersion_ranef = ps$group.dispersion,
#> n = 300L, progbar = FALSE)
#>
#> Bayesian linear mixed model [300 draws, two-block Gibbs]
#> Formula: Reaction ~ Days_c + (1 + Days_c || Subject)
#>
#> Random effects (lmer reference; tau^2 sampled for non-dNormal components):
#> Groups Name Std.Dev.
#> Subject (Intercept) 37.533
#> Subject.1 Days_c 5.922
#> Residual 25.592
#> Number of obs: 180, groups: Subject, 18
#>
#> Posterior mean tau^2_k: (Intercept) = 1334, Days_c = 30.52
#>
#> --- Block 2 hyperparameters (gamma at lmer tau^2 plug-in; MCMC means when simulated) ---
#>
#> RE component parameter gamma @ lmer tau2 fixef.means draws SD
#> ------------ ----------- ------------ ------------ ----------
#> (Intercept) (Intercept) 298.5079 298.0580 8.7567
#> Days_c (Intercept) 10.3748 10.5316 1.5158Two things changed in the header. The engine is now
two-block Gibbs rather than exact iid, and the
random-effects line says the variance components are sampled rather than
fixed.
head(fit$popef.dispersion)
#> (Intercept) Days_c
#> [1,] 1170.697 21.40815
#> [2,] 2120.044 31.27266
#> [3,] 1082.882 28.72715
#> [4,] 1546.960 23.51717
#> [5,] 1784.991 22.10623
#> [6,] 1658.643 18.22194
round(fit$popef.dispersion.mean, 3)
#> (Intercept) Days_c
#> 1333.681 30.524fit$popef.dispersion holds the \(\tau^2_k\) draws — one column per random
coefficient. Now they have a distribution:
round(t(apply(fit$popef.dispersion, 2, quantile,
probs = c(0.025, 0.5, 0.975))), 2)
#> 2.5% 50% 97.5%
#> (Intercept) 717.75 1286.22 2253.13
#> Days_c 16.16 28.93 54.64On the standard-deviation scale, which is easier to read against
lmer:
round(t(apply(sqrt(fit$popef.dispersion), 2, quantile,
probs = c(0.025, 0.5, 0.975))), 3)
#> 2.5% 50% 97.5%
#> (Intercept) 26.791 35.864 47.467
#> Days_c 4.020 5.379 7.392Compare against the lmer point estimates:
print(lme4::VarCorr(fit$lmer), comp = "Std.Dev.")
#> Groups Name Std.Dev.
#> Subject (Intercept) 37.5334
#> Subject.1 Days_c 5.9221
#> Residual 25.5918The lmer numbers should sit inside the credible
intervals. They are point estimates with no uncertainty attached; the
intervals here are wide, and honestly so — 18 subjects is not much
information about how subjects vary.
set.seed(1)
fit_fixed <- lmerb(form, data = dat,
pfamily_list = pfamily_list(ps),
dispersion_ranef = ps$group.dispersion,
n = 300L, progbar = FALSE)sd_fixed <- vapply(fit_fixed$popef, function(m) sd(m[, 1]), numeric(1))
sd_ing <- vapply(fit$popef, function(m) sd(m[, 1]), numeric(1))
round(data.frame(
fixed_tau2 = sd_fixed,
sampled_tau2 = sd_ing,
ratio = sd_ing / sd_fixed
), 4)
#> fixed_tau2 sampled_tau2 ratio
#> (Intercept) 9.4427 8.7567 0.9274
#> Days_c 1.3637 1.5158 1.1115Posterior standard deviations on the population coefficients are wider once the variance components are uncertain. That widening is the point: fixing \(\tau^2\) at a point estimate and reporting the resulting intervals understates what you know.
The convergence theory of Chapter 06 assumed chains start at the exact posterior mean, making the mean-error term of the bound exactly zero. With sampled variance components the joint target is no longer Gaussian, so there is no exact mean to start from.
The engine’s answer is a pilot stage: a batch of short chains whose cross-chain mean becomes the start point for the main chains. The pilot draws are discarded. Their job is not to estimate anything but to produce a starting point whose distance from the truth can be bounded.
fit$pilot
#> $n
#> [1] 28
#>
#> $m_convergence
#> [1] 3
#>
#> $chisq
#> $chisq$Q
#> [1] 9.441567
#>
#> $chisq$df
#> [1] 2
#>
#> $chisq$p_value
#> [1] 0.008908196
#>
#> $chisq$n_pilot
#> [1] 28
#>
#>
#> $draws
#> $draws$sweep_history
#>
#> --- two-block [pilot stage summary: fixef by sweep (3 sweeps)] ---
#> Block 2 fixed effects (mode and chain stats after each sweep):
#> Random effect Covariate mode/sweep mean sd
#> --------------------------------------------------------------------------------------------
#> (Intercept) (Intercept) mode 298.5079
#> (Intercept) (Intercept) sweep 1 298.4475 7.8858
#> (Intercept) (Intercept) sweep 2 300.2691 7.1027
#> (Intercept) (Intercept) sweep 3 295.9783 7.7262
#> Days_c (Intercept) mode 10.3748
#> Days_c (Intercept) sweep 1 10.7006 1.3049
#> Days_c (Intercept) sweep 2 9.9807 1.2268
#> Days_c (Intercept) sweep 3 10.8656 1.6212
#>
#> Block 2 RE precision (1/tau^2; chain mean and SD after each sweep):
#> Random effect sweep mean sd
#> ------------------------------------------------------------
#> (Intercept) sweep 1 0.0008 0.0002
#> (Intercept) sweep 2 0.0009 0.0003
#> (Intercept) sweep 3 0.0008 0.0002
#> Days_c sweep 1 0.0390 0.0116
#> Days_c sweep 2 0.0339 0.0108
#> Days_c sweep 3 0.0337 0.0101
#>
#>
#> $draws$n
#> [1] 28
#>
#> $draws$popef
#> $draws$popef$`(Intercept)`
#> (Intercept)
#> [1,] 282.7240
#> [2,] 304.2712
#> [3,] 300.5090
#> [4,] 295.4622
#> [5,] 293.1121
#> [6,] 294.9818
#> [7,] 286.9552
#> [8,] 295.4177
#> [9,] 311.7305
#> [10,] 301.1785
#> [11,] 307.8272
#> [12,] 295.1304
#> [13,] 285.2527
#> [14,] 298.6190
#> [15,] 302.3361
#> [16,] 289.9715
#> [17,] 294.4007
#> [18,] 304.3161
#> [19,] 287.4933
#> [20,] 306.4539
#> [21,] 290.3458
#> [22,] 292.8609
#> [23,] 294.3391
#> [24,] 303.9967
#> [25,] 283.7590
#> [26,] 287.5298
#> [27,] 303.1061
#> [28,] 293.3112
#>
#> $draws$popef$Days_c
#> (Intercept)
#> [1,] 11.013188
#> [2,] 12.900300
#> [3,] 11.359803
#> [4,] 6.775070
#> [5,] 12.101193
#> [6,] 10.192872
#> [7,] 11.538034
#> [8,] 8.541031
#> [9,] 13.549008
#> [10,] 11.927607
#> [11,] 11.815705
#> [12,] 13.044874
#> [13,] 11.955479
#> [14,] 12.171287
#> [15,] 10.372858
#> [16,] 8.887261
#> [17,] 9.991738
#> [18,] 12.422787
#> [19,] 9.756531
#> [20,] 11.337961
#> [21,] 11.238495
#> [22,] 11.377870
#> [23,] 8.401936
#> [24,] 12.245348
#> [25,] 10.057903
#> [26,] 8.215412
#> [27,] 10.391309
#> [28,] 10.655121
#>
#>
#> $draws$groupef
#> draw Subject (Intercept) Days_c
#> 1 1 308 341.5230 18.6094553
#> 2 1 309 221.7624 1.6277763
#> 3 1 310 232.2291 7.5298500
#> 4 1 330 305.4151 5.4896824
#> 5 1 331 300.0683 4.2594356
#> 6 1 332 302.1343 6.7475775
#> 7 1 333 331.7761 9.8924748
#> 8 1 334 291.8679 11.5816039
#> 9 1 335 248.2752 0.3085758
#> 10 1 337 371.2312 15.6293060
#> 11 1 349 273.3260 11.1527935
#> 12 1 350 306.1311 19.1194226
#> 13 1 351 285.7674 11.4103338
#> 14 1 352 336.9012 15.3331682
#> 15 1 369 301.6050 5.6469137
#> 16 1 370 291.8501 19.4097283
#> 17 1 371 294.2652 8.6088097
#> 18 1 372 319.1516 11.3888097
#> 19 2 308 333.1203 22.4548051
#> 20 2 309 216.4987 0.3941687
#> 21 2 310 222.5487 8.2997188
#> 22 2 330 315.0140 7.5394806
#> 23 2 331 309.3864 8.7103653
#> 24 2 332 313.9446 9.6957497
#> 25 2 333 316.2543 13.0481320
#> 26 2 334 275.8828 11.8429023
#> 27 2 335 248.7191 -3.8995638
#> 28 2 337 367.8447 15.9837194
#> 29 2 349 273.1828 14.7809986
#> 30 2 350 319.2049 13.9058376
#> 31 2 351 295.2633 9.1563875
#> 32 2 352 326.6707 11.7593754
#> 33 2 369 319.8961 12.0253590
#> 34 2 370 299.8679 20.0146998
#> 35 2 371 296.5546 9.8686241
#> 36 2 372 326.6029 10.7564998
#> 37 3 308 343.2872 16.5755043
#> 38 3 309 212.5484 3.9190282
#> 39 3 310 229.6962 8.7181681
#> 40 3 330 297.7579 2.6359529
#> 41 3 331 301.5870 8.9597385
#> 42 3 332 303.8111 7.7584043
#> 43 3 333 314.3704 7.7300397
#> 44 3 334 309.2788 12.8305911
#> 45 3 335 246.4958 1.1268182
#> 46 3 337 374.2241 18.7288817
#> 47 3 349 274.4578 14.0550081
#> 48 3 350 322.6235 21.1735917
#> 49 3 351 290.2900 7.1748273
#> 50 3 352 345.7829 12.7743186
#> 51 3 369 307.5338 13.8919290
#> 52 3 370 299.4022 15.3013389
#> 53 3 371 281.8073 8.7083617
#> 54 3 372 326.3297 9.1916862
#> 55 4 308 319.1986 20.1421135
#> 56 4 309 217.2379 2.7699384
#> 57 4 310 235.6751 3.1145774
#> 58 4 330 300.9196 2.2950304
#> 59 4 331 306.2107 4.1013870
#> 60 4 332 302.5206 7.6640589
#> 61 4 333 328.7180 10.4368285
#> 62 4 334 297.5637 16.0497739
#> 63 4 335 246.7743 0.3013843
#> 64 4 337 360.1866 15.8167409
#> 65 4 349 281.5127 10.9741591
#> 66 4 350 307.9010 21.4652147
#> 67 4 351 303.1997 4.6014316
#> 68 4 352 333.1540 15.2003878
#> 69 4 369 289.8902 9.5058427
#> 70 4 370 299.3696 17.3270874
#> 71 4 371 292.4075 6.1750389
#> 72 4 372 322.1889 14.5564073
#> 73 5 308 321.4943 18.9115071
#> 74 5 309 235.5008 5.3686718
#> 75 5 310 232.8471 4.1278531
#> 76 5 330 299.6642 6.7050242
#> 77 5 331 310.1792 5.3291893
#> 78 5 332 299.0084 9.7547452
#> 79 5 333 305.0531 16.7782855
#> 80 5 334 308.0878 14.0270647
#> 81 5 335 253.4594 -1.3438191
#> 82 5 337 386.2609 14.3318332
#> 83 5 349 284.6985 13.8577557
#> 84 5 350 319.5555 21.8801683
#> 85 5 351 290.1941 8.0211458
#> 86 5 352 312.1756 12.8825892
#> 87 5 369 312.1567 17.2888059
#> 88 5 370 282.4324 17.5739439
#> 89 5 371 295.0997 13.3842694
#> 90 5 372 314.5225 11.4379841
#> 91 6 308 331.4745 18.4630832
#> 92 6 309 214.5416 4.9727587
#> 93 6 310 233.3579 7.5557508
#> 94 6 330 298.3434 9.8614549
#> 95 6 331 304.8936 7.2927219
#> 96 6 332 304.3563 12.0019153
#> 97 6 333 325.7781 9.1336673
#> 98 6 334 288.4007 13.0795011
#> 99 6 335 259.7737 1.0064581
#> 100 6 337 375.2196 17.1520417
#> 101 6 349 268.6210 14.4006527
#> 102 6 350 303.6638 20.1711326
#> 103 6 351 294.9127 12.1108083
#> 104 6 352 334.1585 9.2198023
#> 105 6 369 295.2228 14.5797613
#> 106 6 370 288.4876 13.6465967
#> 107 6 371 298.7774 9.4056430
#> 108 6 372 308.5868 5.3489146
#> 109 7 308 334.3079 20.1314641
#> 110 7 309 220.6855 3.2621759
#> 111 7 310 234.0762 7.3340432
#> 112 7 330 308.4353 7.7157121
#> 113 7 331 295.8429 6.6133204
#> 114 7 332 304.4778 12.2307458
#> 115 7 333 332.2771 9.1128994
#> 116 7 334 299.1114 14.3827463
#> 117 7 335 267.0680 2.6850422
#> 118 7 337 351.7315 13.9879951
#> 119 7 349 275.6945 17.5805480
#> 120 7 350 313.3213 17.6414135
#> 121 7 351 291.7804 8.5262829
#> 122 7 352 343.8658 15.3012058
#> 123 7 369 286.4654 5.3809900
#> 124 7 370 291.7608 18.2260056
#> 125 7 371 282.7495 11.0233721
#> 126 7 372 307.6806 11.5323188
#> 127 8 308 339.4833 16.3659929
#> 128 8 309 237.3850 5.2613625
#> 129 8 310 260.8292 8.4535520
#> 130 8 330 301.2189 3.6134662
#> 131 8 331 305.1505 2.4104368
#> 132 8 332 290.1120 9.3983673
#> 133 8 333 328.1633 10.0825230
#> 134 8 334 294.0852 13.7346441
#> 135 8 335 256.7342 0.6420389
#> 136 8 337 374.3969 16.7808681
#> 137 8 349 287.1942 13.5087203
#> 138 8 350 300.8210 19.3041823
#> 139 8 351 307.7687 7.6107698
#> 140 8 352 351.2212 13.9939169
#> 141 8 369 310.8433 10.2518133
#> 142 8 370 276.7522 13.3681060
#> 143 8 371 294.8806 6.1453253
#> 144 8 372 304.6511 10.7024594
#> 145 9 308 335.9100 25.3908900
#> 146 9 309 220.4059 5.7375300
#> 147 9 310 238.6226 7.6158993
#> 148 9 330 309.0241 6.5062210
#> 149 9 331 315.9219 9.3754061
#> 150 9 332 316.1288 10.2284396
#> 151 9 333 305.5929 3.0158317
#> 152 9 334 292.3562 8.2417393
#> 153 9 335 250.1913 0.1131248
#> 154 9 337 375.3605 21.4382710
#> 155 9 349 291.4332 15.3673191
#> 156 9 350 315.4702 18.6201768
#> 157 9 351 290.6885 3.6762542
#> 158 9 352 352.3873 16.1032066
#> 159 9 369 315.9932 10.1336220
#> 160 9 370 297.3802 17.7103967
#> 161 9 371 282.8429 9.3700455
#> 162 9 372 320.7626 12.4068937
#> 163 10 308 333.7667 24.0891610
#> 164 10 309 235.5113 5.7682532
#> 165 10 310 229.8991 4.5428265
#> 166 10 330 291.9704 2.8483002
#> 167 10 331 293.3859 7.6010805
#> 168 10 332 294.4443 6.5652164
#> 169 10 333 320.1697 10.3975236
#> 170 10 334 304.4213 13.0733293
#> 171 10 335 252.3828 1.0838771
#> 172 10 337 357.8407 17.3504302
#> 173 10 349 278.5199 14.7675422
#> 174 10 350 311.8609 17.6881571
#> 175 10 351 279.4269 8.6464930
#> 176 10 352 318.9662 13.3285712
#> 177 10 369 308.4959 14.7647950
#> 178 10 370 299.3259 18.9644755
#> 179 10 371 280.2205 13.5320166
#> 180 10 372 312.6937 17.8904714
#> 181 11 308 333.7562 15.3447124
#> 182 11 309 224.8823 4.8842336
#> 183 11 310 244.3050 6.3834710
#> 184 11 330 294.6767 7.2634172
#> 185 11 331 306.2474 9.5717901
#> 186 11 332 311.5475 9.3385477
#> 187 11 333 316.1105 10.4926210
#> 188 11 334 285.3169 10.3166807
#> 189 11 335 254.4805 5.8949679
#> 190 11 337 377.7255 17.5148164
#> 191 11 349 284.0550 13.6741708
#> 192 11 350 306.8988 19.6019498
#> 193 11 351 281.0614 5.3945702
#> 194 11 352 337.3838 16.7091660
#> 195 11 369 300.3798 13.6479695
#> 196 11 370 290.0058 16.8480424
#> 197 11 371 282.8259 7.0609586
#> 198 11 372 331.8268 11.1281556
#> 199 12 308 341.4343 12.2811230
#> 200 12 309 228.6910 3.2590477
#> 201 12 310 237.5522 7.5863227
#> 202 12 330 306.6165 3.1485136
#> 203 12 331 324.9567 6.3289256
#> 204 12 332 305.9126 13.5889449
#> 205 12 333 312.7598 5.5240521
#> 206 12 334 278.4752 11.2182187
#> 207 12 335 247.2502 -1.0088009
#> 208 12 337 373.8582 22.4646724
#> 209 12 349 282.3286 11.9470031
#> 210 12 350 323.9157 16.3979332
#> 211 12 351 295.0515 9.9233205
#> 212 12 352 335.5648 7.5650319
#> 213 12 369 302.0108 15.6229534
#> 214 12 370 290.5199 19.0171674
#> 215 12 371 299.1039 9.2491752
#> 216 12 372 295.7932 12.5957360
#> 217 13 308 334.3353 18.7306035
#> 218 13 309 217.3981 8.3912336
#> 219 13 310 226.6274 -0.4434891
#> 220 13 330 307.6344 6.2236055
#> 221 13 331 307.4443 5.4293533
#> 222 13 332 320.1990 3.8260974
#> 223 13 333 306.4453 11.2294294
#> 224 13 334 299.0045 15.2971146
#> 225 13 335 247.4697 -4.9927882
#> 226 13 337 377.9058 22.2735031
#> 227 13 349 277.3847 17.9002865
#> 228 13 350 325.6135 19.1876198
#> 229 13 351 294.5364 3.6295464
#> 230 13 352 353.0037 13.8102080
#> 231 13 369 304.6794 9.1224015
#> 232 13 370 270.0169 15.7834628
#> 233 13 371 287.1796 9.4400978
#> 234 13 372 329.2987 13.6187271
#> 235 14 308 324.7720 20.6651042
#> 236 14 309 213.1113 -1.6231365
#> 237 14 310 226.7648 2.6897903
#> 238 14 330 295.2918 7.5005264
#> 239 14 331 294.7866 6.7965123
#> 240 14 332 307.5777 9.1974153
#> 241 14 333 315.3691 8.1815866
#> 242 14 334 295.2085 16.4961149
#> 243 14 335 266.5909 -0.1739985
#> 244 14 337 367.3742 21.2180771
#> 245 14 349 266.3697 12.8572942
#> 246 14 350 314.7593 20.3540869
#> 247 14 351 288.1473 13.3508186
#> 248 14 352 328.0618 10.2320881
#> 249 14 369 325.3057 12.6749028
#> 250 14 370 289.0861 14.4635396
#> 251 14 371 299.6656 9.8818921
#> 252 14 372 306.2024 10.7909715
#> 253 15 308 343.7591 19.4878724
#> 254 15 309 211.0296 8.9606499
#> 255 15 310 226.6645 7.3189354
#> 256 15 330 311.6061 4.7431457
#> 257 15 331 320.5271 13.0357338
#> 258 15 332 315.6582 11.8584470
#> 259 15 333 306.4875 13.3214398
#> 260 15 334 295.0277 12.3760898
#> 261 15 335 254.1397 -0.2317385
#> 262 15 337 387.3183 21.4859284
#> 263 15 349 270.3571 11.1969070
#> 264 15 350 312.4509 13.6015175
#> 265 15 351 295.5442 8.5568388
#> 266 15 352 345.6934 10.2052393
#> 267 15 369 313.5665 12.9889989
#> 268 15 370 290.8341 12.4432948
#> 269 15 371 293.0249 13.2864499
#> 270 15 372 322.3227 12.1388089
#> 271 16 308 316.0627 20.1326794
#> 272 16 309 227.3088 0.4417324
#> 273 16 310 233.0293 7.6405480
#> 274 16 330 304.8361 6.7357960
#> 275 16 331 308.1824 5.9387732
#> 276 16 332 316.0351 9.8725654
#> 277 16 333 305.0738 6.9400775
#> 278 16 334 302.4625 14.0795117
#> 279 16 335 260.1465 0.5975607
#> 280 16 337 379.5510 16.5756802
#> 281 16 349 289.5916 9.4392102
#> 282 16 350 319.2701 17.0979494
#> 283 16 351 297.1210 6.7435138
#> 284 16 352 331.1662 13.2527600
#> 285 16 369 308.6245 11.2230543
#> 286 16 370 291.3002 14.5298687
#> 287 16 371 305.6032 9.5252478
#> 288 16 372 319.1570 14.8154446
#> 289 17 308 352.6924 22.7964776
#> 290 17 309 217.4296 6.0982421
#> 291 17 310 248.1792 3.9529896
#> 292 17 330 291.2805 5.2908085
#> 293 17 331 303.3966 12.1517888
#> 294 17 332 316.4386 3.0809409
#> 295 17 333 300.9346 11.6523636
#> 296 17 334 298.1360 17.2304208
#> 297 17 335 254.3953 5.2625805
#> 298 17 337 354.2654 14.1576950
#> 299 17 349 278.1283 11.5161517
#> 300 17 350 305.5689 14.2158313
#> 301 17 351 285.7294 3.5860405
#> 302 17 352 328.9388 15.1107620
#> 303 17 369 298.7851 13.4836478
#> 304 17 370 294.3075 17.1350210
#> 305 17 371 277.1897 4.7242196
#> 306 17 372 317.2859 15.5436773
#> 307 18 308 348.3975 18.5536667
#> 308 18 309 229.8547 3.9288596
#> 309 18 310 234.3688 11.0287516
#> 310 18 330 293.6486 4.4598134
#> 311 18 331 302.2537 5.1373311
#> 312 18 332 293.9398 10.0360792
#> 313 18 333 323.8761 9.1910444
#> 314 18 334 293.4249 13.2917399
#> 315 18 335 263.7775 2.9338090
#> 316 18 337 379.2829 20.3794194
#> 317 18 349 269.1327 12.5028251
#> 318 18 350 321.1136 15.6460426
#> 319 18 351 296.8078 7.6041148
#> 320 18 352 344.6333 8.0342649
#> 321 18 369 308.8552 13.6521491
#> 322 18 370 296.9732 19.7245698
#> 323 18 371 294.9587 9.1595966
#> 324 18 372 324.5004 10.5520483
#> 325 19 308 351.7711 23.5470073
#> 326 19 309 215.1363 2.3362722
#> 327 19 310 245.5698 9.4038230
#> 328 19 330 309.0812 3.1512632
#> 329 19 331 310.4350 9.6515316
#> 330 19 332 304.0435 10.8671005
#> 331 19 333 296.4416 12.6429533
#> 332 19 334 284.2710 8.0271401
#> 333 19 335 263.4935 3.2309967
#> 334 19 337 367.2055 15.5518485
#> 335 19 349 284.5728 15.4130145
#> 336 19 350 312.5918 15.2733428
#> 337 19 351 287.4651 8.9307901
#> 338 19 352 334.0543 10.3799116
#> 339 19 369 298.2805 11.2147326
#> 340 19 370 292.1743 14.6867236
#> 341 19 371 293.8830 10.2392136
#> 342 19 372 321.2035 15.3174548
#> 343 20 308 361.4886 20.5953725
#> 344 20 309 211.0722 5.7799626
#> 345 20 310 224.0302 10.8037757
#> 346 20 330 296.0288 5.2727447
#> 347 20 331 324.9793 8.0777155
#> 348 20 332 307.0939 11.3041545
#> 349 20 333 329.1471 7.0632956
#> 350 20 334 300.5226 15.2258148
#> 351 20 335 247.5252 1.2114035
#> 352 20 337 372.1280 17.3655523
#> 353 20 349 285.7948 12.3264049
#> 354 20 350 311.7257 16.4514743
#> 355 20 351 283.4235 1.5134694
#> 356 20 352 329.9853 17.2068268
#> 357 20 369 305.1691 7.7105630
#> 358 20 370 287.2077 12.7008164
#> 359 20 371 282.7039 11.7605021
#> 360 20 372 314.7297 12.7598814
#> 361 21 308 335.1777 15.4230781
#> 362 21 309 213.7719 1.9166370
#> 363 21 310 226.0776 6.9226365
#> 364 21 330 311.2234 4.6614995
#> 365 21 331 292.2941 11.2123961
#> 366 21 332 316.6820 15.9063250
#> 367 21 333 313.4513 14.6879532
#> 368 21 334 297.3547 10.7823797
#> 369 21 335 245.1786 -3.8262002
#> 370 21 337 381.1068 20.3709139
#> 371 21 349 286.2029 14.5410748
#> 372 21 350 315.3610 18.0633557
#> 373 21 351 306.9037 6.0630710
#> 374 21 352 330.2489 13.8375961
#> 375 21 369 300.8858 7.7453917
#> 376 21 370 284.5816 17.5699880
#> 377 21 371 310.8065 13.3975232
#> 378 21 372 307.9724 11.4640181
#> 379 22 308 355.8322 23.0574873
#> 380 22 309 227.2197 4.1700710
#> 381 22 310 244.3375 9.5884631
#> 382 22 330 300.8969 2.1240576
#> 383 22 331 305.9737 2.2576857
#> 384 22 332 313.5121 9.2316336
#> 385 22 333 295.5808 6.2764468
#> 386 22 334 298.1678 14.3644537
#> 387 22 335 255.3923 -3.5350394
#> 388 22 337 364.7458 25.2095485
#> 389 22 349 288.3950 13.5255072
#> 390 22 350 311.3975 17.3869505
#> 391 22 351 296.5596 6.4079598
#> 392 22 352 330.2986 12.0111321
#> 393 22 369 305.3614 13.4996108
#> 394 22 370 273.6084 21.4866046
#> 395 22 371 296.1789 10.2970003
#> 396 22 372 321.6136 9.1822731
#> 397 23 308 330.3470 17.1557483
#> 398 23 309 224.8526 4.8935532
#> 399 23 310 225.1600 6.2211653
#> 400 23 330 290.8462 4.8644200
#> 401 23 331 304.5920 3.5662178
#> 402 23 332 309.0139 12.5183120
#> 403 23 333 301.2703 7.7004032
#> 404 23 334 311.1751 13.2703625
#> 405 23 335 274.3561 -5.0343935
#> 406 23 337 372.3208 15.0568408
#> 407 23 349 286.9094 16.4272383
#> 408 23 350 316.4397 22.5016957
#> 409 23 351 298.4848 2.8292796
#> 410 23 352 332.9082 15.6380083
#> 411 23 369 286.7670 11.8327355
#> 412 23 370 288.5175 15.5568899
#> 413 23 371 286.1231 10.1092175
#> 414 23 372 318.9274 12.5167310
#> 415 24 308 342.8706 20.7456201
#> 416 24 309 225.2356 2.2297298
#> 417 24 310 244.0462 9.8968992
#> 418 24 330 304.0090 3.8092392
#> 419 24 331 309.8151 8.8910935
#> 420 24 332 302.9504 11.9800482
#> 421 24 333 321.2510 4.0533323
#> 422 24 334 290.3785 8.6271127
#> 423 24 335 263.0088 -2.9460436
#> 424 24 337 367.8356 16.7605520
#> 425 24 349 287.4257 14.3610773
#> 426 24 350 312.3772 15.8901452
#> 427 24 351 295.1945 6.9978437
#> 428 24 352 314.3515 15.5002525
#> 429 24 369 309.8853 10.0564835
#> 430 24 370 293.8638 14.6328696
#> 431 24 371 312.2099 9.7878843
#> 432 24 372 328.4393 14.7428822
#> 433 25 308 334.3018 18.0358419
#> 434 25 309 221.5117 2.9034392
#> 435 25 310 243.4557 7.5226386
#> 436 25 330 307.3018 -0.1641379
#> 437 25 331 303.4960 7.1057699
#> 438 25 332 310.5269 7.3398304
#> 439 25 333 315.6378 8.5610484
#> 440 25 334 302.1850 12.8757146
#> 441 25 335 252.6368 2.6301599
#> 442 25 337 370.8274 17.8560472
#> 443 25 349 277.1338 13.4997287
#> 444 25 350 316.9487 20.3589570
#> 445 25 351 293.1813 7.9315129
#> 446 25 352 334.7793 16.0923532
#> 447 25 369 310.6084 10.5067561
#> 448 25 370 295.1242 14.8140578
#> 449 25 371 292.0509 3.3430701
#> 450 25 372 310.7648 12.5312450
#> 451 26 308 356.5677 14.2769911
#> 452 26 309 221.5999 1.6448857
#> 453 26 310 233.3242 8.8373235
#> 454 26 330 294.3697 1.7608073
#> 455 26 331 308.0553 2.0993454
#> 456 26 332 293.1388 8.6315853
#> 457 26 333 311.5140 5.0723131
#> 458 26 334 286.0817 12.0207821
#> 459 26 335 241.6766 3.0760326
#> 460 26 337 353.4758 14.8050443
#> 461 26 349 278.9764 10.0634861
#> 462 26 350 310.4432 15.6058295
#> 463 26 351 295.6148 8.2900169
#> 464 26 352 340.9767 13.9232890
#> 465 26 369 322.1259 10.9388196
#> 466 26 370 293.3965 12.5759118
#> 467 26 371 292.0620 11.8909762
#> 468 26 372 316.8778 15.6309281
#> 469 27 308 356.4983 16.1016992
#> 470 27 309 202.7684 6.8916683
#> 471 27 310 249.6151 9.3781140
#> 472 27 330 301.2493 5.1281323
#> 473 27 331 312.5724 7.5169810
#> 474 27 332 309.9793 7.7594099
#> 475 27 333 310.5965 9.7805126
#> 476 27 334 289.6472 12.5308037
#> 477 27 335 256.1126 -0.8762244
#> 478 27 337 370.2684 16.1681036
#> 479 27 349 293.8056 10.2166389
#> 480 27 350 308.2256 20.5781002
#> 481 27 351 277.8511 9.9058572
#> 482 27 352 322.6950 13.3488232
#> 483 27 369 305.9647 9.7125610
#> 484 27 370 284.2801 16.3115189
#> 485 27 371 279.8284 9.3120828
#> 486 27 372 312.9467 13.5259330
#> 487 28 308 351.8884 17.5190344
#> 488 28 309 218.4330 4.6900684
#> 489 28 310 244.1110 10.6562245
#> 490 28 330 313.5345 4.0468364
#> 491 28 331 313.7893 9.0340766
#> 492 28 332 320.2786 7.6965517
#> 493 28 333 332.8965 11.4941604
#> 494 28 334 304.0607 9.2814871
#> 495 28 335 249.2768 0.1957849
#> 496 28 337 364.8366 15.8031045
#> 497 28 349 268.1214 13.3263069
#> 498 28 350 322.7961 16.1333947
#> 499 28 351 275.6995 8.8451438
#> 500 28 352 339.2529 14.4152130
#> 501 28 369 310.7659 3.6741548
#> 502 28 370 307.6155 17.7150686
#> 503 28 371 298.4900 6.6291057
#> 504 28 372 320.4133 9.3732712
#>
#> $draws$popef.dispersion
#> (Intercept) Days_c
#> [1,] 1792.5832 25.35418
#> [2,] 2057.2044 38.92543
#> [3,] 1097.7640 43.89731
#> [4,] 991.7761 54.37557
#> [5,] 1027.7515 31.85308
#> [6,] 2356.3418 24.07505
#> [7,] 1443.9129 35.57345
#> [8,] 1185.8583 27.33573
#> [9,] 1641.7314 52.87073
#> [10,] 709.0813 22.83257
#> [11,] 1683.9956 20.55383
#> [12,] 1043.1028 25.91006
#> [13,] 1724.8386 32.01998
#> [14,] 1331.0646 60.04669
#> [15,] 1380.2851 24.70344
#> [16,] 1348.9403 20.88037
#> [17,] 1267.1674 24.99671
#> [18,] 1155.1833 18.76378
#> [19,] 1641.6347 26.18182
#> [20,] 1501.5203 35.18011
#> [21,] 1121.4614 26.22491
#> [22,] 1927.8192 32.11730
#> [23,] 1032.7585 44.93079
#> [24,] 804.4577 33.09633
#> [25,] 2010.0714 53.75450
#> [26,] 1190.6984 29.73931
#> [27,] 1576.1523 20.58577
#> [28,] 1157.8362 31.62110
#>
#> $draws$popef.iters
#> (Intercept) Days_c
#> [1,] 8 7
#> [2,] 11 14
#> [3,] 3 9
#> [4,] 14 19
#> [5,] 18 17
#> [6,] 16 11
#> [7,] 24 20
#> [8,] 14 6
#> [9,] 4 15
#> [10,] 13 18
#> [11,] 17 14
#> [12,] 31 17
#> [13,] 6 17
#> [14,] 7 22
#> [15,] 17 12
#> [16,] 20 15
#> [17,] 6 16
#> [18,] 11 12
#> [19,] 25 9
#> [20,] 37 8
#> [21,] 5 24
#> [22,] 9 9
#> [23,] 26 10
#> [24,] 27 11
#> [25,] 15 14
#> [26,] 32 31
#> [27,] 14 19
#> [28,] 15 9
#>
#> $draws$groupef.iters
#> [1] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
#>
#> $draws$popef.mode
#> $draws$popef.mode$`(Intercept)`
#> (Intercept)
#> 298.5079
#>
#> $draws$popef.mode$Days_c
#> (Intercept)
#> 10.37476
#>
#>
#> $draws$popef.init
#> $draws$popef.init$`(Intercept)`
#> (Intercept)
#> 298.5079
#>
#> $draws$popef.init$Days_c
#> (Intercept)
#> 10.37476If the pilot mean averages n_pilot independent chains,
its sampling distribution has covariance \(\Sigma/n_{\text{pilot}}\), so the squared
standardized start distance obeys \(D_0 =
\chi^2_{p,\alpha} / n_{\text{pilot}}\) at confidence level \(\alpha\). Bigger pilots give smaller \(D_0\) and therefore fewer main-stage sweeps
— but the pilot itself costs sweeps. The engine minimizes total cost
over n_pilot; the optimization is worked through in
vignette("Chapter-B03", package = "lmebayesCore").
Both stages leave a sweep history:
names(fit$sweep_history)
#> [1] "pilot" "main"
fit$sweep_history$pilot
#>
#> --- two-block [pilot stage summary: fixef by sweep (3 sweeps)] ---
#> Block 2 fixed effects (mode and chain stats after each sweep):
#> Random effect Covariate mode/sweep mean sd
#> --------------------------------------------------------------------------------------------
#> (Intercept) (Intercept) mode 298.5079
#> (Intercept) (Intercept) sweep 1 298.4475 7.8858
#> (Intercept) (Intercept) sweep 2 300.2691 7.1027
#> (Intercept) (Intercept) sweep 3 295.9783 7.7262
#> Days_c (Intercept) mode 10.3748
#> Days_c (Intercept) sweep 1 10.7006 1.3049
#> Days_c (Intercept) sweep 2 9.9807 1.2268
#> Days_c (Intercept) sweep 3 10.8656 1.6212
#>
#> Block 2 RE precision (1/tau^2; chain mean and SD after each sweep):
#> Random effect sweep mean sd
#> ------------------------------------------------------------
#> (Intercept) sweep 1 0.0008 0.0002
#> (Intercept) sweep 2 0.0009 0.0003
#> (Intercept) sweep 3 0.0008 0.0002
#> Days_c sweep 1 0.0390 0.0116
#> Days_c sweep 2 0.0339 0.0108
#> Days_c sweep 3 0.0337 0.0101fit$sweep_history$main
#>
#> --- two-block [main stage summary: fixef by sweep (3 sweeps)] ---
#> Block 2 fixed effects (mode and chain stats after each sweep):
#> Random effect Covariate mode/sweep mean sd
#> --------------------------------------------------------------------------------------------
#> (Intercept) (Intercept) mode 298.5079
#> (Intercept) (Intercept) sweep 1 297.7582 9.7325
#> (Intercept) (Intercept) sweep 2 298.8448 9.0653
#> (Intercept) (Intercept) sweep 3 298.0580 8.7567
#> Days_c (Intercept) mode 10.3748
#> Days_c (Intercept) sweep 1 10.5522 1.3832
#> Days_c (Intercept) sweep 2 10.4410 1.4733
#> Days_c (Intercept) sweep 3 10.5316 1.5158
#>
#> Block 2 RE precision (1/tau^2; chain mean and SD after each sweep):
#> Random effect sweep mean sd
#> ------------------------------------------------------------
#> (Intercept) sweep 1 0.0008 0.0002
#> (Intercept) sweep 2 0.0008 0.0002
#> (Intercept) sweep 3 0.0008 0.0002
#> Days_c sweep 1 0.0359 0.0117
#> Days_c sweep 2 0.0366 0.0122
#> Days_c sweep 3 0.0365 0.0120The pilot history starts at the ICM mode and moves; the main history starts at the pilot mean and barely moves. That contrast is the pilot doing its job.
summary(fit)
#> Call:
#> lmerb(formula = form, data = dat, pfamily_list = pf_ing, dispersion_ranef = ps$group.dispersion,
#> n = 300L, progbar = FALSE)
#>
#> Bayesian linear mixed model fit [300 draws, two-block Gibbs]
#> Formula: Reaction ~ Days_c + (1 + Days_c || Subject)
#>
#> Random effects (lmer reference; tau^2 sampled for non-dNormal components):
#> Groups Name Std.Dev.
#> Subject (Intercept) 37.533
#> Subject.1 Days_c 5.922
#> Residual 25.592
#> Number of obs: 180, groups: Subject, 18
#>
#> === Block 2 dispersion (RE variance tau^2_k) ===
#>
#> Prior and lmer reference:
#>
#> Prior 1/E[1/tau2] E[tau2] sqrt(E[tau2])
#> (Intercept) dIndependent_Normal_Gamma 931.9470 1346.1456 36.6899
#> Days_c dIndependent_Normal_Gamma 20.3346 29.3722 5.4196
#> Residual fixed 709.8260 709.8260 26.6426
#> disp_lower disp_upper lmer lmer SD
#> (Intercept) 632.3273 2998.2033 1408.7541 37.5334
#> Days_c 13.7971 65.4193 35.0716 5.9221
#> Residual NA NA 654.9399 25.5918
#>
#> Overview:
#> Post.Mode Post.Mean Post.Sd MC Error Mean SD Pr(Prior_tail)
#> (Intercept) 1346.1456 1333.6806 402.1977 23.2209 36.1213 0.4367
#> Days_c 29.3722 30.5235 10.2703 0.5930 5.4494 0.4800
#> Residual 709.8260 709.8260 NA NA 26.6426 NA
#> Cand/draw
#> (Intercept) 5.057
#> Days_c 5.034
#> Residual 1.000
#>
#> Distribution percentiles (tau^2):
#>
#> 1.0% 2.5% 5.0% Median 95.0% 97.5% 99.0%
#> (Intercept) 673.98 717.75 785.42 1286.22 2023.16 2253.13 2429.99
#> Days_c 15.10 16.16 17.57 28.93 49.66 54.64 56.47
#> Residual 709.83 709.83 709.83 709.83 709.83 709.83 709.83
#>
#> SD credible interval (sqrt(tau^2) draws; lmer SD for reference):
#>
#> 2.5% Median 97.5% lmer SD
#> (Intercept) 26.791 35.864 47.467 37.533
#> Days_c 4.020 5.379 7.392 5.922
#> Residual 26.643 26.643 26.643 25.592
#>
#> === Block 2: Level-2 fixed effects (hyperparameters) ===
#>
#> Prior and lmer reference:
#>
#> Prior Mean Prior.sd lmer lmer.se
#> (Intercept)::(Intercept) 298.51 90.05 298.51 9.050
#> Days_c::(Intercept) 0.00 15.38 10.47 1.546
#>
#> Overview:
#> fixef.mode fixef.means Post.Sd MC.Error Pr(Prior_tail)
#> (Intercept)::(Intercept) 298.508 298.058 8.757 0.506 0.483
#> Days_c::(Intercept) 10.375 10.532 1.516 0.088 <2e-16
#>
#> (Intercept)::(Intercept)
#> Days_c::(Intercept) ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Distribution percentiles:
#>
#> 1.0% 2.5% 5.0% Median 95.0% 97.5% 99.0%
#> (Intercept)::(Intercept) 276.812 280.974 283.642 298.158 311.736 314.281 317.37
#> Days_c::(Intercept) 7.116 7.717 7.875 10.485 13.299 13.715 14.55
#>
#> === Block 1: Random effects (group-level) ===
#>
#> Summary of posterior mode (ranef.mode) across groups:
#>
#> Mean SD Min Q1 Median Q3 Max
#> (Intercept) 298.5079 36.4724 219.4041 290.8999 304.3215 314.6673 371.8535
#> Days_c 10.4463 5.0724 0.1222 7.1416 10.4194 12.8294 19.1842
#> MCMC.mean
#> (Intercept) 298.44
#> Days_c 10.43
#>
#> Per-group random effects: inspect fit$groupef.mode or fit$groupef,
#> or call summary(fit, groups = <level ids>) for selected groups.The Block 2 dispersion section is now informative.
Post.Mode, Post.Mean, Post.Sd,
and the percentile rows are real distributions rather than repeated
constants, disp_lower / disp_upper show the
truncation window, and Cand/draw reports how many
accept-reject candidates the envelope sampler needed per draw — a value
near 1 means the envelope is tight, larger values mean it is working
harder.
Sample them when the number of groups is small (a variance component from 18 subjects is barely identified), when the variance component is itself of interest, or when you are reporting intervals you want to be honest.
Fix them when there are many groups and \(\tau^2\) is well determined, when you want exact iid draws with no sweeps, or when speed matters and the sensitivity check shows it makes no difference.
The cheapest way to decide is to fit both, as above, and look at the ratio of posterior standard deviations.
vignette("Chapter-B05", package = "lmebayesCore") — the
ING Block 2 derivation and the truncation window.vignette("Chapter-B06", package = "lmebayesCore") — the
local rate diagnostic used when \(\tau^2\) is sampled.?pfamily_list,
?dIndependent_Normal_Gamma