Code
formula <- build_ls_formula(moderator, has_phylogeny = FALSE)
V <- diag(dat_mod$vi_lnM_safe)
fit <- fit_ls_model(
dat_mod, formula,
build_ls_priors(formula, dat_mod, V, A = NULL),
V = V, A = NULL, mcmc_args = default_mcmc_args)The primary models place a phylogenetic random effect (1 | gr(sp_ncbi, cov = A)) on every species-level intercept, using a correlation matrix A derived from an Open Tree of Life scaffold. That scaffold is a pragmatic comparative tree, not a fully resolved, time-calibrated phylogeny (protocol §3.6): its topology is assembled from multiple sources, unresolved nodes are resolved algorithmically, and branch lengths are assigned by Grafen’s method.
Changed: the phylogenetic random effect was removed.
Unchanged: the full dataset, moderator definitions, ref_id effect, priors, and MCMC settings match the primary models.
Models were fit on a remote server, not while rendering this book: 4 chains × 4,000 iterations (2,000 warmup), adapt_delta = 0.97, max_treedepth = 15, and the cmdstanr backend.
formula <- build_ls_formula(moderator, has_phylogeny = FALSE)
V <- diag(dat_mod$vi_lnM_safe)
fit <- fit_ls_model(
dat_mod, formula,
build_ls_priors(formula, dat_mod, V, A = NULL),
V = V, A = NULL, mcmc_args = default_mcmc_args)Six moderator models are reported (m01–m05, m07). The environmental-change model (m08) is excluded because its primary fit did not converge. Convergence criteria: max \(\hat{R} \leq 1.01\), bulk and tail ESS \(\geq 400\), and no divergent transitions.
sens_diagnostics_table(variant)| Moderator | Max R̂ | Min bulk ESS | Min tail ESS | Divergences | Max-treedepth hits |
|---|---|---|---|---|---|
| Comparison design (m02) | 1.0107 | 577 | 1349 | 0 | 0 |
| Disturbance context (m01) | 1.0070 | 793 | 1304 | 0 | 0 |
| Phenotypic vs genetic study (m07) | 1.0069 | 359 | 719 | 0 | 0 |
| Elapsed time — log₁₀ generations (m04) | 1.0131 | 566 | 1149 | 0 | 0 |
| Elapsed time — log₁₀ years (m03) | 1.0099 | 489 | 839 | 0 | 0 |
| Trait type (m05) | 1.0070 | 460 | 1130 | 0 | 0 |
Models requiring convergence caution: Comparison design (m02): max Rhat = 1.0107, min bulk/tail ESS = 577/1349, divergences = 0; Phenotypic vs genetic study (m07): max Rhat = 1.0069, min bulk/tail ESS = 359/719, divergences = 0; Elapsed time in log10 generations (m04): max Rhat = 1.0131, min bulk/tail ESS = 566/1149, divergences = 0. See the table above for ESS and treedepth diagnostics.
The comparison label uses a fixed rule: DIFFERS means that the posterior median changed sign or that the 95% credible interval changed between including and excluding zero. Consistent means neither occurred; it does not mean the two estimates are identical. Intercepts are omitted from the overall count.
cat("**Overall:** ", sens_stability_summary(variant), "\n")Overall: 5 of 34 moderator coefficients change their credible-interval conclusion relative to the primary fit.
Each table reports raw treatment-coded coefficients for the location (mean ln M) and scale (log-SD) submodels. See the sensitivity overview for column definitions.
sens_all_moderator_tables(variant)sens_moderator_table('sens2_nophylo', 'disturbance')| Sub-model | Term | Sensitivity β [95% CrI] | Primary β [95% CrI] | Stability |
|---|---|---|---|---|
| Location (mean lnM) | Intercept (ref.) | -0.692 [-1.030, -0.359] | -0.530 [-1.338, 0.319] | DIFFERS |
| Location (mean lnM) | Hunt_harv | -0.120 [-0.445, 0.214] | -0.276 [-0.630, 0.079] | consistent |
| Location (mean lnM) | Introduction | 0.131 [-0.226, 0.492] | 0.006 [-0.384, 0.399] | consistent |
| Location (mean lnM) | Landscapechange | 0.312 [-0.126, 0.761] | 0.207 [-0.251, 0.672] | consistent |
| Location (mean lnM) | Other | -0.142 [-0.461, 0.190] | -0.281 [-0.623, 0.063] | consistent |
| Location (mean lnM) | Pollution | 0.336 [-0.151, 0.831] | 0.173 [-0.381, 0.729] | consistent |
| Location (mean lnM) | Responsetointroductions | 0.280 [-0.291, 0.845] | 0.100 [-0.503, 0.692] | consistent |
| Scale (log-SD) | Intercept (ref.) | -0.630 [-0.788, -0.476] | -0.692 [-0.871, -0.527] | consistent |
| Scale (log-SD) | Hunt_harv | 0.308 [0.141, 0.473] | 0.365 [0.189, 0.554] | consistent |
| Scale (log-SD) | Introduction | -0.046 [-0.206, 0.116] | 0.015 [-0.155, 0.199] | DIFFERS |
| Scale (log-SD) | Landscapechange | -0.486 [-0.761, -0.214] | -0.431 [-0.737, -0.142] | consistent |
| Scale (log-SD) | Other | 0.095 [-0.070, 0.265] | 0.138 [-0.038, 0.329] | consistent |
| Scale (log-SD) | Pollution | -0.244 [-0.548, 0.044] | -0.184 [-0.489, 0.119] | consistent |
| Scale (log-SD) | Responsetointroductions | 0.194 [-0.019, 0.411] | 0.256 [0.028, 0.486] | DIFFERS |
sens_moderator_table('sens2_nophylo', 'design')| Sub-model | Term | Sensitivity β [95% CrI] | Primary β [95% CrI] | Stability |
|---|---|---|---|---|
| Location (mean lnM) | Intercept (ref.) | -0.817 [-0.970, -0.663] | -0.724 [-1.471, 0.025] | DIFFERS |
| Location (mean lnM) | Synchronic | 0.320 [0.168, 0.479] | 0.250 [0.077, 0.418] | consistent |
| Scale (log-SD) | Intercept (ref.) | -0.457 [-0.496, -0.418] | -0.468 [-0.507, -0.428] | consistent |
| Scale (log-SD) | Synchronic | -0.218 [-0.270, -0.167] | -0.208 [-0.260, -0.157] | consistent |
sens_moderator_table('sens2_nophylo', 'log10_years')| Sub-model | Term | Sensitivity β [95% CrI] | Primary β [95% CrI] | Stability |
|---|---|---|---|---|
| Location (mean lnM) | Intercept (ref.) | -1.058 [-1.214, -0.901] | -1.021 [-1.855, -0.173] | consistent |
| Location (mean lnM) | slope | 0.293 [0.224, 0.363] | 0.307 [0.235, 0.381] | consistent |
| Scale (log-SD) | Intercept (ref.) | -0.340 [-0.413, -0.265] | -0.354 [-0.427, -0.279] | consistent |
| Scale (log-SD) | slope | -0.170 [-0.219, -0.123] | -0.167 [-0.215, -0.119] | consistent |
sens_moderator_table('sens2_nophylo', 'log10_generations')| Sub-model | Term | Sensitivity β [95% CrI] | Primary β [95% CrI] | Stability |
|---|---|---|---|---|
| Location (mean lnM) | Intercept (ref.) | -0.925 [-1.067, -0.779] | -0.918 [-1.839, 0.017] | DIFFERS |
| Location (mean lnM) | slope | 0.260 [0.187, 0.332] | 0.286 [0.215, 0.359] | consistent |
| Scale (log-SD) | Intercept (ref.) | -0.393 [-0.442, -0.343] | -0.401 [-0.450, -0.350] | consistent |
| Scale (log-SD) | slope | -0.148 [-0.180, -0.116] | -0.149 [-0.182, -0.117] | consistent |
sens_moderator_table('sens2_nophylo', 'trait_type')| Sub-model | Term | Sensitivity β [95% CrI] | Primary β [95% CrI] | Stability |
|---|---|---|---|---|
| Location (mean lnM) | Intercept (ref.) | -1.293 [-2.064, -0.506] | -1.332 [-2.519, -0.105] | consistent |
| Location (mean lnM) | growth | 0.739 [-0.064, 1.535] | 0.829 [0.042, 1.616] | DIFFERS |
| Location (mean lnM) | otherLH | 0.815 [0.022, 1.601] | 0.907 [0.131, 1.681] | consistent |
| Location (mean lnM) | othermorphology | 0.683 [-0.115, 1.459] | 0.782 [0.003, 1.555] | DIFFERS |
| Location (mean lnM) | phenology | 0.672 [-0.168, 1.509] | 0.806 [-0.022, 1.626] | consistent |
| Location (mean lnM) | physio | 0.612 [-0.189, 1.390] | 0.698 [-0.077, 1.477] | consistent |
| Location (mean lnM) | response | 1.103 [0.235, 1.957] | 1.167 [0.313, 2.024] | consistent |
| Location (mean lnM) | size | 0.744 [-0.049, 1.525] | 0.835 [0.058, 1.611] | DIFFERS |
| Scale (log-SD) | Intercept (ref.) | -0.355 [-0.848, 0.146] | -0.373 [-0.863, 0.129] | consistent |
| Scale (log-SD) | growth | -0.981 [-1.577, -0.404] | -0.977 [-1.615, -0.387] | consistent |
| Scale (log-SD) | otherLH | -0.192 [-0.690, 0.304] | -0.181 [-0.688, 0.314] | consistent |
| Scale (log-SD) | othermorphology | -0.510 [-1.005, -0.010] | -0.519 [-1.027, -0.025] | consistent |
| Scale (log-SD) | phenology | -0.347 [-0.898, 0.207] | -0.383 [-0.937, 0.171] | consistent |
| Scale (log-SD) | physio | -0.722 [-1.248, -0.197] | -0.698 [-1.225, -0.179] | consistent |
| Scale (log-SD) | response | -0.555 [-1.294, 0.159] | -0.550 [-1.354, 0.158] | consistent |
| Scale (log-SD) | size | -0.052 [-0.547, 0.441] | -0.037 [-0.538, 0.454] | consistent |
sens_moderator_table('sens2_nophylo', 'genphen')| Sub-model | Term | Sensitivity β [95% CrI] | Primary β [95% CrI] | Stability |
|---|---|---|---|---|
| Location (mean lnM) | Intercept (ref.) | -0.492 [-0.613, -0.364] | -0.427 [-1.208, 0.371] | DIFFERS |
| Location (mean lnM) | Phenotypic | -0.198 [-0.336, -0.066] | -0.210 [-0.355, -0.063] | consistent |
| Scale (log-SD) | Intercept (ref.) | -0.828 [-0.881, -0.777] | -0.836 [-0.889, -0.784] | consistent |
| Scale (log-SD) | Phenotypic | 0.336 [0.277, 0.397] | 0.338 [0.278, 0.398] | consistent |