Package: glmbayesCore 0.6.0

glmbayesCore: Core C++ Sampling Engine for 'glmbayes'

Core C++ engine for 'glmbayes': envelope-based iid linear and generalized linear model samplers, prior-family routing, and optional 'OpenCL' acceleration. Sampling for supported non-conjugate models uses accept-reject methods based on likelihood subgradients as in Nygren and Nygren (2006) <doi:10.1198/016214506000000357>. Intended as a developer backend for the 'glmbayes' formula interface; end users should use 'glmbayes' for modelling with interfaces analogous to 'lm' and 'glm'. Experimental mixed-model design utilities use the 'lme4', 'Matrix', 'reformulas', and 'glmmTMB' packages (API only; no bundled third-party source).

Authors:Kjell Nygren [aut, cre], The R Core Team [ctb, cph], The R Foundation [cph], Ross Ihaka [ctb, cph], Robert Gentleman [ctb, cph], Simon Davies [ctb], Morten Welinder [ctb, cph], Martin Maechler [ctb], Douglas Bates [ctb], Ben Bolker [ctb], Steven Walker [ctb], Anna Ly [ctb], Mollie Brooks [ctb], Kasper Kristensen [ctb], The Khronos Group Inc [cph]

glmbayesCore_0.6.0.tar.gz
glmbayesCore_0.6.0.zip(r-4.7-x86_64)glmbayesCore_0.6.0.zip(r-4.7-arm64)glmbayesCore_0.6.0.zip(r-4.6-x86_64)glmbayesCore_0.6.0.zip(r-4.6-arm64)glmbayesCore_0.6.0.zip(r-4.5-x86_64)
glmbayesCore_0.6.0.tgz(r-4.6-x86_64)glmbayesCore_0.6.0.tgz(r-4.6-arm64)glmbayesCore_0.6.0.tgz(r-4.5-x86_64)glmbayesCore_0.6.0.tgz(r-4.5-arm64)
glmbayesCore_0.6.0.tar.gz(r-4.7-arm64)glmbayesCore_0.6.0.tar.gz(r-4.7-x86_64)glmbayesCore_0.6.0.tar.gz(r-4.6-arm64)glmbayesCore_0.6.0.tar.gz(r-4.6-x86_64)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
glmbayesCore/json (API)

# Install 'glmbayesCore' in R:
install.packages('glmbayesCore', repos = c('https://knygren.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/knygren/glmbayescore/issues

Uses libs:
  • openblas– Optimized BLAS
  • onetbb– Parallelism library for C++
  • c++– GNU Standard C++ Library v3
Datasets:
  • AMI - Amitriptyline overdose data
  • BikeSharing - Bike Sharing Dataset
  • Boston_centered - Boston housing data with mean-centered predictors
  • carinsca - Canadian Automobile Insurance Claims for 1957-1958
  • Cleveland - Cleveland Heart Disease Dataset

On CRAN:

Conda:

openblasonetbbcpp

8.28 score 3 stars 3 packages 348 downloads 62 exports 68 dependencies

Last updated from:3b6628593a. Checks:14 OK, 1 FAIL. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK352
linux-devel-x86_64OK331
source / vignettesOK691
linux-release-arm64OK341
linux-release-x86_64OK423
macos-release-arm64OK317
macos-release-x86_64OK653
macos-oldrel-arm64OK265
macos-oldrel-x86_64OK617
windows-devel-arm64OK520
windows-devel-x86_64OK551
windows-release-arm64OK615
windows-release-x86_64OK340
windows-oldrel-x86_64OK461
wasm-releaseFAIL303

Exports:check_identifiabilitycompute_gaussian_priordBetadGammadGamma_listdiagnose_glmbayesdIndependent_Normal_GammadNormaldNormal_GammaEnvelopeBuildEnvelopeCenteringEnvelopeDispersionBuildEnvelopeEvalEnvelopeOptEnvelopeOrchestratorEnvelopeSetGridEnvelopeSetLogPEnvelopeSizeEnvelopeSortglmb_Standardize_Modelglmb.wfitglmbayesCore_has_openclglmbfamfuncmodel_setupmulti_prior_setupmulti_rindepNormalGamma_regmulti_rlmbmulti_rNormal_regmulti_rNormalGamma_regnormalize_grouppfamilypfamily_listpinvgamma_ctpnorm_ctPrior_CheckPrior_SetupPrior_Setup_GLMMPrior_SetupGroupqinvgamma_ctrBeta_priorrBeta_regrGamma_Conjugate_priorrGamma_Conjugate_regrgamma_ctrGamma_priorrGamma_regrglmbrIndependent_Normal_Gamma_priorrindepNormalGamma_regrIndepNormalGammaReg_stdrinvgamma_ctrlmbrnorm_ctrNormal_Gamma_priorrNormal_priorrNormal_regrNormal_reg_grouprNormal_reg.wfitrNormalGamma_regrNormalGLM_reg_grouprNormalGLM_stdsimfunction

Dependencies:backportsbootbroomclicolorspacecowplotcpp11DerivdoBydplyrfarverforecastfracdiffgenericsggplot2glmmTMBgluegtableisobandjsonlitelabelinglatticelifecyclelme4lmtestmagrittrMASSMatrixmgcvminqamodelrnlmenloptrnmathopenclnnetnumDerivopencltoolspbkrtestpillarpkgconfigpurrrR6rbibutilsRColorBrewerRcppRcppArmadilloRcppEigenRcppParallelRdpackreformulasrlangRTMBS7sandwichscalesstringistringrtibbletidyrtidyselecttimeDateTMBurcautf8vctrsviridisLitewithrzoo

Core 01: Overview of the glmbayesCore package
Ecosystem | Primary R entry points | Vignette index by Part | Legacy map (glmbayes appendices → Core) | Reserved numbers (future)

Last update: 2026-10-03
Started: 2026-09-30

Core 20-S01: Model setup and identifiability
1. User interface | 1.1 Formula rules | 1.2 Arguments | 1.3 Returned fields | 1.4 check_identifiability() | 2. Example: Big Word Club | 2.1 The sampler design | 2.2 The hyper-design matrices | 2.3 The reference fit | 2.4 Identifiability at two levels | 2.5 Calling check_identifiability() directly | 3. Lineage: what runs inside model_setup() | 3.1 Call tree | 3.2 Helper reference | 3.3 Exploring the internals | 4. Next

Last update: 2026-10-03
Started: 2026-10-03

Core 20-S02: Calibrating mixed-model priors with Prior_Setup_GLMM()
1. User interface | 1.1 Arguments | 1.2 Returned fields | 2. Example: Big Word Club | 2.1 Pooled measurement dispersion (dispformula = ~1) | 2.2 Block 2: Normal priors on (\gamma_k) | 2.3 Block 2: the (\tau^2_k) centres and Gamma priors | 2.4 Block 1: the pooled measurement-precision prior | 2.5 Per-group measurement dispersion (dispformula = ~ school_id) | 2.6 Non-Gaussian families and failed defaults | 3. Lineage: what runs inside Prior_Setup_GLMM() | 3.1 Call tree | 3.2 Helper reference | 3.3 How the stages map to returned fields | 4. Next

Last update: 2026-10-03
Started: 2026-10-03

Core 20-S03: From calibrated priors to pfamily objects — pfamily_list() and dGamma_list()
Core 20-S03: From calibrated priors to pfamily objects | 1. User interface | 1.1 pfamily_list() | 1.2 dGamma_list() | 2. Example | 2.1 Normal priors with fixed (\tau^2_k) (default) | 2.2 Independent Normal–Gamma priors (sample (\tau^2_k)) | 2.3 Mixing prior types | 2.4 Per-group measurement-variance priors | 2.5 Changing the truncation windows | 2.6 Pooled measurement dispersion | 2.7 Putting it together | 3. Lineage | 3.1 Call trees | 3.2 Helper reference | 3.3 Where the values come from | 4. Next

Last update: 2026-10-03
Started: 2026-10-03

Core 20-S04: Row-group priors and samplers
1. User interface | 1.1 Group specifications and normalize_group() | 1.2 Prior_SetupGroup() | 1.3 rNormal_reg_group() and rNormalGLM_reg_group() | 2. Examples | 2.1 Group partitions | 2.2 Independent priors per species | 2.3 Converting to pfamily objects | 2.4 Gaussian group draws with one shared prior | 2.5 Gaussian group draws with per-group priors from Prior_SetupGroup() | 2.6 Non-Gaussian group draws | 3. Lineage | 3.1 Prior_SetupGroup() and its pfamily_list() method | 3.2 The groupwise samplers (R to C++) | 3.3 Helper reference: R | 3.4 Helper reference: C++ (glmbayes::sim::group) | 4. Role in the mixed-model samplers

Last update: 2026-10-03
Started: 2026-10-03

Core 20: Mixed-model design and priors in glmbayesCore — overview
Core 20: Mixed-model design and priors — overview | 1. Where these functions sit | 2. The two-block structure | 3. What Part 4 covers | 4. Package-wide lineage | 5. Where the code lives | 6. Naming conventions for helpers | 7. Requirements and current limitations | 8. Related documentation in the package

Last update: 2026-10-03
Started: 2026-10-03

Core 02: Overview of Estimation Procedures
Introduction | 1. rglmb/rlmb, pfamilies, and the Simulation Architecture | 1.1 How glmb and lmb use rglmb and rlmb respectively | 1.2 pfamilies: the Bayesian analogue of family() | pfamily name Prior components in prior_list | 1.3 The uniform simfunction interface | 1.4 How rglmb and rlmb select the simfunction | 1.5 The four core simfunctions | 1.6 Inspecting the Simulation Function Used: the simfunction() Generic | 1.7 Summary | 2. Mapping Families and Pfamilies to Simulation Functions | 2.1 Mappings to Simulation Functions | 2.2 Mapping Simulation Functions to Primary C++ Routines | 3. Conjugate vs. Envelope-Based Sampling | 3.1 Conjugate Cases | 3.2 Envelope-Based Cases | 4. Theoretical Foundations and Cross-References | 5. Overview of Each Simulation Function | Simfunction Supported Families and Links | 5.1 rNormal_reg | 5.2 rNormalGamma_reg | 5.3 rindepNormalGamma_reg | 5.4 rGamma_reg | 6. Use in Gibbs Samplers and Custom Algorithms | 7. Source Code and File Structure | 7.1 C and C++ Backends Used by the Simfunctions | 7.2 Utility Functions | 8. Summary

Last update: 2026-09-30
Started: 2026-09-30

Core 03: Simulation Methods - Likelihood Subgradient Densities
1. Introduction | 2. Overview of the Main Simulation Function: .rNormalGLM_cpp | 3. Input Validation and Preprocessing | 4. Posterior Optimization | 5. Model Standardization with Theoretical Underpinnings: glmb_Standardize_Model() | Implementation Details: glmb_Standardize_Model() | 6. Envelope Sizing | 1. Gridtype 1: Static Threshold Test | 2. Gridtype 2: Dynamic Envelope via EnvelopeOpt(a, n) | 3. Gridtype 3: Always Three-Point Grid | 4. Gridtype 4: Always Single-Point Grid (Mode Only) | Deep Dive: Gridtype 1 — Static Threshold Envelope | Deep Dive: Gridtype 2 — Adaptive Envelope via EnvelopeOpt() | 6. Building the Envelope | 1. Compute width parameters ( \omega_i ) from the diagonal precision matrix | 2. Construct intervals around the posterior mode ( \theta^\star ) | 3. Select tangency points ( \theta^\star \pm \omega_i ) | 4. Build the full grid of tangency points | 5. Evaluate negative log-likelihood and gradients at each grid point | 6. Call Set_Grid_C2_pointwise to evaluate restricted multivariate normal log-densities | 7. Call setlogP_C2 to compute component log-probabilities and constants | 8. Normalize probabilities (PLSD) and optionally sort grid components | 7. Simulation Execution | 8. Post-Processing and Output | 8.1 Reverse-transformation pipeline | 8.2 Returned object (fields you can rely on)

Last update: 2026-09-30
Started: 2026-09-30

Core 04: Accept–Reject Sampling for Dispersion in Gamma Regression
1. Introduction | 1.2 Likelihood | [\ell_i(v) | v\log v | v\log \mu_i+(v-1)\log y_i | \log\Gamma(v) | [\ell(v) | \sum_{i=1}^nw_i\left[v\log v | 1.3 Prior | 1.4. Posterior Log‑Density | [f(v) | 2. The sampler | 2.1 Proposal Distribution | [\begin{aligned}\log p_{prop}(v) & = (a_0+ \frac{1}{2}\sum_i w_i )\log [ b_0 - \bar{c}(v_{\text{tangent}})] ;-; \log\Gamma(a_0+ \frac{1}{2}\sum_i w_i ) \[4pt]& ;+; ((a_0+ \frac{1}{2}\sum_i w_i ) - 1)\log v ;-; [ b_0 - \bar{c}(v_{\text{tangent}})] v.\end{aligned}] | 2.2 Bounding function | [\log h(v) | \ell(v) | \bigl[\ell(v_{\text{tangent}}) | \bar{c}(v_{\text{tangent}})(v - v_{\text{tangent}})\bigr] | 2.3 Equivalence Claim | 2.4 Implementation Outline

Last update: 2026-09-30
Started: 2026-09-30

Core 05: Accept–Reject Sampling for gaussian Regression models with independent normal-gamma priors
Envelope construction with independent Normal–Gamma prior (Gaussian regression) | 1. Model Setup (Gaussian Regression with Independent Normal–Gamma Prior) | 1.1 Weighted log‑likelihood | [\mathrm{RSS}(\beta) | [\ell(\beta,\phi) | [\ell(\beta,\tau) | 1.2 Independent Normal–Gamma prior | [\log p(\beta,\tau) | [p_{\text{trunc}}(\tau) | \frac{\tau^{a_0 - 1} e^{-b_0\tau}}{F_{\Gamma}(\tau_{\max};a_0,b_0) | 2. Full Joint Log‑Posterior (Gaussian Case, Weighted) | [\log p(\beta,\tau \mid y) | 3. General Sampling Process | 4. Main Proposition and Supporting claims | | Constant | Definition | Description ||----------|------------|-------------|| Posterior Gamma parameters | $\text{shape}2 = \text{Shape} + \tfrac{n{w}}{2}$ $\text{rate}2 = \text{Rate} + \mathrm{RSS}{\text{post}}/2$ | Posterior shape and rate parameters. || Envelope dispersion anchor | $d^{}_{1} = \dfrac{\text{rate}2}{\text{shape}2 - 1}$ | Dispersion used for baseline envelope. || Dispersion bounds | $\begin{aligned}& \text{low} \[4pt]& \text{upp}\end{aligned}$ | Lower and upper bounds for dispersion. || Tangency offset vector | $B(d) = P\mu + \dfrac{1}{d},X^\top W(\alpha - y)$ | Offset vector used in the inverse map $c^{-1}(\bar c, d)$. || Tangency slope components | $\begin{aligned} Q &= X^\top X \ A(d) &= Q + dP \ r &= X^\top(y-\alpha) \ V(d) &= \bar c_j - P,A(d)^{-1}(r + d,\bar c_j) \end{aligned}$ | Components for quad–linear slope term. || Tangency inverse map | $c^{-1}(\bar c, d) = A(d)^{-1}(\bar c - B(d))$ | Maps gradient vector $\bar c$ and dispersion $d$ to tangency point $\theta$. || Tangency map | $\theta(d) = c^{-1}(\bar c_j, d)$ | Tangency point in coefficient space at dispersion $d$. || Tangency face energy | (g{1j}(d) = -\tfrac12,\theta(d)^\top P,\theta(d) + \bar c_j^\top \theta(d)) | Quadratic–linear face energy at dispersion (d). || Baseline face constant | (g{1j}(d^{}{1})) | Face‑specific constant obtained by evaluating (g{1j}(d)) at the anchor (d^{}{1}). || Derivative of face energy | $\begin{aligned} & g'{1j}(d) = V(d)^\top A(d)^{-1},\bar c_j \[6pt] & \qquad -, \Big( V(d)^\top A(d)^{-1} P,A(d)^{-1} \[2pt] & \qquad\qquad\qquad;;\times \big(r + d,\bar c_j\big) \Big) \end{aligned}$ | Derivative of $g_{1j}(d)$ with respect to dispersion. || Derivative at the anchor | $\begin{aligned}& g'_{1j}(d^{}{1}) = V(d^{*}{1})^\top A(d^{}_{1})^{-1},\bar c_j \[6pt]& \qquad -, \Big( V(d^{}{1})^\top A(d^{*}{1})^{-1} P,A(d^{}_{1})^{-1} \[2pt]& \qquad\qquad\qquad;;\times \big(r + d^{}{1},\bar c_j\big) \Big)\end{aligned}$ | Value of the derivative at the envelope anchor $d^{*}{1}$. || Tangency face energy | (g_{1j}(d) = -\tfrac12,\theta(d)^\top P,\theta(d) + \bar c_j^\top \theta(d)) | Quadratic–linear face energy at dispersion (d). || Mean quad–linear slope | $\mathrm{m}{g'{1}} = \displaystyle \operatorname*{mean}\limits_{j}!\big(g'{1j}(d^{*}{1})\big)$ | Average derivative $g'{1j}(d^{*}{1})$ across faces. || Supporting line for face (j) | (g_{2j}(d) = g_{1j}(d^{}_{1}) + (d - d^{}{1}),g'{1j}(d^{}{1})) | Linear supporting line of (g{1j}(d)) at the anchor (d^{}{1}). || Extrapolated face constants | $\begin{aligned}& g{2j}(\text{upp}) = g_{1j}(d^{}_{1}) \[2pt]& \qquad\qquad;; +, (\text{upp}-d^{}{1}), g'{1j}(d^{}{1}) \[6pt]& g{2j}(\text{low}) = g_{1j}(d^{}{1}) \[2pt]& \qquad\qquad;; +, (\text{low}-d^{*}{1}), g'{1j}(d^{*}{1})\end{aligned}$ | Linear extrapolations to dispersion bounds. || Endpoint maxima | $\begin{aligned}\mathrm{max_upp} & = \max_j!\big(g_{2j}(\text{upp})\big) \[8pt]\mathrm{max_low} & = \max_j!\big(g_{2j}(\text{low})\big)\end{aligned}$ | Maxima at upper and lower dispersion bounds. || Mean lower-bound maximum | $\begin{aligned}&\mathrm{max_low_mean} \[4pt]&= \mathrm{max_upp} \[4pt]&\quad - \mathrm{m}{g'{1}},(\text{upp}-\text{low})\end{aligned}$ | Linearized lower-bound maximum. || Global line parameters | $\text{lmc}2 = \dfrac{\mathrm{max_upp} - \mathrm{max_low_mean}}{\text{upp}-\text{low}}$ $\text{lmc}1 = \mathrm{max_low_mean} - \text{lmc}2,\text{low}$ | Slope and intercept of global affine bound. || Log–linear anchor | $d^{*}{2} = \dfrac{\text{upp}-\text{low}}{\log(\text{upp}/\text{low})}$ | Anchor point for log–tilt. || Log–tilt coefficients | $\begin{aligned} & \mathrm{lm_log2} = \[4pt]& \text{lmc}2,d^{*}{2} \[4pt]& \mathrm{lm_log1} = \[4pt]& \text{lmc}1 + \text{lmc}2 d^{*}{2} - \text{lmc}2\log(d^{*}{2}) \[4pt]& \mathrm{max_LL_log_disp} =\[4pt]& \mathrm{lm_log1} + \mathrm{lm_log2}\log(\text{upp}) \end{aligned}$ | Coefficients for log–tilt bounding function. || Face-specific RSS | $\mathrm{RSS}j(d) = \sum{i=1}^n w_i,(y_i - x_i^\top c^{-1}(\bar c_j,d))^2$ | Residual sum of squares for face $j$ at dispersion $d$. || Global minimum RSS | $\mathrm{RSS_Min} = \min{j};\min{d\in[\text{low},,\text{upp}]};\mathrm{RSS}j(d)$ | Global minimum RSS across all faces and dispersion values. || UB2 term | $\mathrm{UB2}j(d) = \dfrac{1}{2d}\big(\mathrm{RSS}j(d) - \mathrm{RSS_Min}\big)$ | Nonnegative UB2 bound for face $j$. || Per-face UB2 minimum | $\mathrm{UB2_Min}j = \min{d\in[\text{low},,\text{upp}]}\mathrm{UB2}j(d)$ | Minimum UB2 value for face $j$. || Per‑face shift (UB3A) | $\begin{aligned}& \mathrm{lg_prob_factor1}{j} = \[4pt]& \max\Big{, g{2j}(\text{upp}) - \mathrm{max_upp}, \[-2pt]& \qquad;; g{2j}(\text{low}) - \mathrm{max_low} \Big}\end{aligned}$ | Raw per‑face shift used in UB3A construction. || Per‑face shift (PLSD) | $\begin{aligned}& \mathrm{lg_prob_factor2}{j} = \[4pt]& \mathrm{lg_prob_factor1}{j} ;-; \mathrm{UB2_Min}{j}\end{aligned}$ | UB2‑adjusted shift used in PLSD mixture weights. || Global affine bound (g3_j) | $\displaystyleg3{j}(d) | From the definitions of the global affine bound,[\mathrm{lmc}_2 | \frac{\mathrm{max_upp} - \mathrm{max_low}}{\text{upp} - \text{low}},\qquad\mathrm{lmc}_1 | At (d = \text | 4.2 Proposal distributions | Gamma proposal in dispersion (d) (with truncation) | Mixture of truncated normals for (\beta) (two-step sampling) | 4.3 Correction terms | 4.4 Proposition: Log‑posterior decomposition in dispersion form | Explanation | Proof of Proposition | 5. Supporting Claims | 5.1 Claim 1 | (1a) | (1b) | (1c) | (2a) | (2b) | (3a) | (3b) | (4a) | (4b) | (4c) | (4d) | (5a) | F_{\Gamma}!\Big(\tfrac{1}{\mathrm{disp}{\mathrm{upper}}};\text{Shape},\text{Rate}\Big)\Bigg) \[6pt]&\quad + \log!\Bigg(F{\Gamma}!\Big(\tfrac{1}{\mathrm{disp}{\mathrm{lower}}};\text{Shape} + \tfrac{n{2}}{2} - \mathrm{lm_log2},\text{Rate} + \tfrac{\mathrm{RSS}_{\mathrm{Min}}}{2}\Big)\[-2pt]&\qquad\qquad\qquad | (5b) | (5c) | (5d) | F_{\Gamma}(\tfrac{1}{\mathrm{disp}{\mathrm{upper}}};\text{Shape},\text{Rate})\Big) \[4pt]&\quad - \log!\Big(F{\Gamma}(\tfrac{1}{\mathrm{disp}{\mathrm{lower}}};\text{Shape} + n{2}/2 - \mathrm{lm_log2},\text{Rate} + \mathrm{RSS}_{\mathrm{Min}}/2)\[-2pt]&\qquad\qquad\qquad | 5.2 Claim 2 | 5.3 Claim 3 | 5.4 Claims 4 and 5 | [g3_{j}(d) = \mathrm{lg_prob_factor1_j} + \text{lmc}_1 + \text{lmc}_2,d.] | By definition of the per‑face UB3A shift,[\mathrm{lg_prob_factor1}_j | 5.5 Claims 6 and 7 | 5.5.1 Notation and setup | 5.5.2 Remarks for Claim 6 | Proof. From the definition of the tangency point in implementationnotation,[\beta_j(d) | A(d)^{-1},\bigl(\bar{c}_j - B_0(d)\bigr),]with(A(d) = P + \mathrm{base_A}/d)and(B_0(d) = \mathrm{base_B0}/d + P\mu.)Rewriting in terms of (t = 1/d) and using (A(t) = P + tQ),(B_0(t) = t,\mathrm{base_B0} + P\mu),we obtain[\tilde{\beta}_j(t) | A(t)^ | A(t)^{-1},\bigl(\bar{c}_j - P\mu - P\hat{\beta}\bigr) | A(t)^{-1} r^{*}_j.]Substituting this into the exact decomposition of Remark 5.5.1 with(\beta = \beta_j(d)) and (t = 1/d) gives[\mathrm{RSS}_j(d) | \mathrm{RSS}_{ML}+(\beta_j(d) - \hat{\beta})^{T} Q (\beta_j(d) - \hat{\beta}) | Proof. For (t > 0), we have(A(t) = P + tQ \succ tQ) in the Loewner order, so(A(t)^{-1} \prec (tQ)^{-1}). Therefore[\tilde{M}(t) | A(t)^ | 5.5.3 Claim 6: RSS decomposition and lower bound | 5.5.4 Remarks for Claim 7 | Proof. From Remark 5.5.2 and the definition of (\mathrm{UB2}_j(d)),[\mathrm{UB2}_j(d) | \frac{1}{2d}\Bigl(\mathrm{RSS}_{ML}+ (r^{}_j)^{T} \tilde{M}(1/d), r^{}j- \mathrm{RSS}{\mathrm{Min}}\Bigr).]Writing (t = 1/d) and using (\tilde{M}(t) = Q^{-1/2}(K + tI)^{-2}Q^{-1/2}),we obtain[(r^{}_j)^{T} \tilde{M}(t), r^{}_j | v_j^{T}(K + tI)^{-2}v_j = g_j(t),]and hence[\tilde{\mathrm{UB2}}_j(t) | Proof. In the eigenbasis of (K+tI), write (v_j) in coordinates(v_j = \sum_i \sqrt | \frac | \frac | Remark 5.5.7 (Critical points of (\tilde | Proof. From Remark 5.5.4 and Remark 5.5.5,[\tilde | \frac | By Remark 5.5.6, we can write[\frac | Remark 5.5.8 (Inflection points of (\tilde | Proof. From Remark 5.5.5,[\tilde{\mathrm{UB2}}_j''(t)= g_j'(t) + \frac{t}{2},g_j''(t)= -2, v_j^{T}(K+tI)^{-3} v_j+ 3t, v_j^{T}(K+tI)^{-4} v_j.]Writing this in the eigenbasis of (K+tI), let(\mu_i = \lambda_i + t) denote the eigenvalues of (K+tI) and write[v_j^{T}(K+tI)^{-3} v_j= \sum_i w_i \mu_i^{-3},\qquadv_j^{T}(K+tI)^{-4} v_j= \sum_i w_i \mu_i^{-4},]for some weights (w_i \ge 0) (not all zero). Then[\tilde{\mathrm{UB2}}_j''(t)= \sum_i w_i\Bigl(-2,\mu_i^{-3} + 3t,\mu_i^{-4}\Bigr)= \sum_i w_i \mu_i^{-4},\bigl(-2\mu_i + 3t\bigr).]At an inflection point (t^{}), we have (\tilde{\mathrm{UB2}}_j''(t^{}) = 0),so[0= \sum_i w_i \mu_i^{-4},\bigl(-2\mu_i + 3t^{*}\bigr).]Define normalized weights[\alpha_i | 5.5.5 Claim 7: UB2 derivatives and endpoint minimization | Any critical point (t^ | 5.5.5(') Corrected minimization for anisotropic (K)

Last update: 2026-09-30
Started: 2026-09-30

Core 06: Overview of Envelope Related Functions
1. Introduction and Purpose | 1.1 Why Envelopes? | 1.2 High-Level Flow | 2. Theoretical Foundation | 2.1 Posterior and Definition 2 (paper Section 2) | (c) for all (\theta\in\Theta),[q(\theta) | 2.2 Claim 1: finite mixture of normal priors | Suppose (\pi(\theta) = \sum_{i=1}^{k} p_i,\pi_i(\theta\mid \mu_i,\Sigma_i)) and (c(\bar{\theta})) is a subgradient for (-\log g) at (\bar{\theta}). Then[\mathrm{MGF}!\big(-c(\bar{\theta})\big) | \sum_{i=1}^{k} p_i,\exp!\Big(-c(\bar{\theta})^T\mu_i + \tfrac12,c(\bar{\theta})^T\Sigma_i,c(\bar{\theta})\Big),]and the generalized likelihood-subgradient density is again a mixture of multivariate normals:[q(\theta) = \sum_{i=1}^{k} \tilde{p}_i,\pi_i(\theta\mid \tilde{\mu}_i,\Sigma_i),]with[\tilde{p}_i | 2.3 Theorem 1: envelope dominance and tangency | Define[a(\bar{\theta}) | \frac{g(\bar{\theta}),\mathrm{MGF}!\big(-c(\bar{\theta})\big)}{f(y),\exp!\big(-c(\bar{\theta})^T\bar{\theta}\big)},]and[h_{\bar{\theta}}(\theta) | Then Theorem 1 states[a(\bar{\theta}),q_{\bar{\theta}}(\theta)\gea(\bar{\theta}),h_{\bar{\theta}}(\theta),q_{\bar{\theta}}(\theta) | 2.4 Models in standard form | [\mathbb{E}_{\tilde{q}^{\bar{\theta}}}[\theta_r \mid \theta \in A] | 2.5 Construction of restricted subgradient densities | [\tilde{q}_{\bar{\theta}}(\theta) | [\tilde{a}(\theta_{\text{bar}}) | [\int_{\theta \in A} q_{\bar{\theta}}(\theta), d\theta | 2.6 Mixture construction and tractable probabilities | [\tilde{p}_i | [\int_{\theta\in A_i} q^{{\bar{\theta}}}(\theta), d\theta | \displaystyle\prod_{r=1}^{p}\Bigl[\Phi!\bigl(l_{U,r}^{(i)} + c_{r}(\bar{\theta})\bigr) | 2.7 Log-scale properties of the envelope function | [\log h_{\bar{\theta}}(\theta) | 2.8 Standard form: Definition 3 and Remarks 11-15 (paper Section 3.3) | 2.10 Remarks 7-8: sampling restricted normals (paper) | 2.11 Theorem 2: univariate Normal data, three intervals, and (\tilde{a}\to 2/\sqrt{\pi}) | Let (\theta^\ast) be the posterior mode. Define (univariate case)[\omega | \frac | 2.12 Multivariate partition in standard form (paper; Remark 16) | Let (\theta^\ast) be the unique posterior mode. For each coordinate (i), define[\omega_i | 2.13 Theorem 3 (paper) | 3. Function Map and Workflow | 3.1 Where Envelopes Are Used | 3.2 Pipeline Order | 4. Envelope Functions Reference | 5. Gridtype and Envelope Sizing | 6. Central Distributions: Normal_ct, Gamma_ct, InvGamma_ct | 7. Cross-References

Last update: 2026-09-30
Started: 2026-09-30

Core 07: Parallel Sampling Implementation using RcppParallel
1. Introduction | 2. Where Parallel Sampling Is Used | 3. Why Parallel Sampling Cannot Be Interrupted | 4. Pilot-Based Time Estimation and Opt-In | 5. rNormalGLM Pilot Logic (Non-Gaussian GLMs) | 5.1 Single-Draw Test | 5.2 max_draws Cap and Zero Accepts | 5.3 Calibration Run and Refined Estimate | 5.4 Five-Minute Safeguard | 5.5 Diagnostics (verbose = TRUE) | 6. rIndepNormalGammaReg Pilot Logic | 6.1 Single-Draw Test | 6.2 Calibration Run | 6.3 Time Estimate | 6.4 Five-Minute Safeguard | 7. EnvelopeDispersionBuild Pilot (Envelope Construction) | 7.1 Five-Minute Safeguard | 8. Choosing Serial vs Parallel | 9. Technical Details | 9.1 RcppParallel Worker Pattern | 9.2 Thread Safety | 9.3 Dependencies | 10. Troubleshooting | 11. Cross-References

Last update: 2026-09-30
Started: 2026-09-30

Core 08: Accelerated EnvelopeBuild Implementation using OpenCL
1. Introduction | 2. Architecture Overview | 2.1 Call Path | 3. Program Construction | 3.1 Assembly Order | 3.2 load_kernel_source and load_kernel_library | 4. Ported Math Libraries (nmath / rmath / dpq) | 4.1 nmath | 4.2 rmath | 4.3 dpq | 5. Family/Link Kernels | 5.1 Kernel Structure | 6. f2_f3_opencl Flow | 7. f2_f3_kernel_runner | 8. Pilot and Safeguards | 8.1 Pilot Logic | 8.2 When the Pilot Runs | 9. Installation and Availability | 10. Cross-References

Last update: 2026-09-30
Started: 2026-09-30

Core 09: Implementation Companion for Independent Normal-Gamma
1. Introduction | 2. Core Function #1: rIndepNormalGammaReg (non-_std) - Internal Workflow | 2.1 Stage A: EnvelopeCentering() for dispersion2 and RSS_Post2 | 2.2 Stage B: Posterior mode (bstar) and Hessian (A1) | 2.3 Stage C: Standardization (glmb_Standardize_Model) | 2.4 Stage D: EnvelopeOrchestrator() - envelope + dispersion refinement | 2.5 Stage E: Delegation to rIndepNormalGammaReg_std / _parallel | 2.6 Stage F: Back-transform and return values | 3. Core Function #2: EnvelopeOrchestrator - Composition of Envelope Steps | 3.1 Orchestrator inputs and internal Gamma anchoring | 3.2 Step 1: EnvelopeBuild() call (coefficient-envelope) | 3.3 Step 2 (Deep Dive): EnvelopeDispersionBuild() - dispersion-aware extension | 3.3.1 Inputs and the role of RSS_Post2 | 3.3.2 Dispersion interval construction (low, upp) | 3.3.3 Anchor dispersion and face slopes | 3.3.4 RSS/UB minimization and construction of UB_list | 3.3.5 Gamma tilt parameters (gamma_list) | 3.3.6 Returned object summary | 3.4 Step 3: EnvelopeSort() (component reordering) | 4. Simulation Execution: rIndepNormalGammaReg_std - Serial Accept-Reject Loop | 4.1 Precomputation (Inv_f3_precompute_disp) | 4.2 Proposal generation (per accepted draw) | 4.3 Accept-reject test statistic | 4.4 Record outputs | 5. Dataflow: From EnvelopeOrchestrator Outputs to the Sampler | 5.1 What the sampler reads from Env | 5.2 What the sampler reads from gamma_list / UB_list | 6. Practical Knobs and Diagnostics | 6.1 Tuning parameters | 6.2 Interpreting iters_out | 6.3 Minimal examples | 7. Cross-References

Last update: 2026-09-30
Started: 2026-09-30

Core 10: Technical Derivations for Priors Returned by `Prior_Setup()
1. Introduction | 1. Introductory Discussion | 2. Default Priors for Coefficient Means and Covariance Matrices | 2.1 How prior means are determined | 2.2 Data precision $P(\beta)$. | 2.3 Zellner-type prior using $P(\beta^{\ast})$ | 2.3.1 Precision mapping and default covariance scaling | [\Sigma_0 = \Sigma / d,]so[\Sigma_0^ | d,\Sigma^ | d,\frac | 2.3.2 Posterior mean and Variance under dNormal() | dNormal() (Gaussian, coefficient-scale covariance Sigma).For Gaussian likelihood precision $P(\beta^\ast)$ and prior precision$\Sigma^{-1}$,[E(\beta\mid y) | \bigl(P(\beta^\ast)+\Sigma^ | The posterior covariance is[\mathrm{Var}(\beta\mid y) | \bigl(P(\beta^\ast)+\Sigma^ | 2.3.3 Marginal posterior mean under dNormal_Gamma() | dNormal_Gamma() (Gaussian conjugate Normal--Gamma, using Sigma_0).The marginal posterior mean is[E(\beta\mid y) | E_{\tau\mid y}!\left[E(\beta\mid \tau,y)\right].]For fixed $\tau$,[E(\beta\mid \tau,y) | \bigl(\tau X^ | 2.4 Vector pwt and optional sd | 3. Default Priors for Dispersion, Shape, and Rate Parameters | 3.1 Posterior pieces: contribution from likelihood + Normal block | and the marginal quadratic term[S_ | 3.2 Prior-strength parameterization from pwt | The scalar prior‑weight pwt is mapped to an effective prior sample size[n_ | \frac | The dispersion‑free covariance used in dNormal_Gamma() is[\Sigma_0 | \frac | 3.3 Gaussian prior-family calibration and parameter mapping | 3.3.1 Default calibration and posterior Gamma shape/rate | Let (n_w=\sum_i w_i) be the effective sample size (n_effective).For scalar pwt, Prior_Setup() defines the effective prior sample size[n_ | \frac | 3.3.2 Conjugate Normal–Gamma posterior (dNormal_Gamma()) | Theorem 1 (Conjugate posterior under the default dNormal_Gamma() calibration) | Let the prior be[\beta\mid\tau\sim N(\mu,\tau^{-1}\Sigma_0),\qquad\tau\sim\Gamma(a_0,b_0),]with[\Sigma_0 | \frac | (i) Posterior mean of (\beta) | [\mu_ | \mathrm{pwt},\mu+(1-\mathrm{pwt}),\hat\beta | (ii) Posterior dispersion‑free covariance | [\Sigma_ | (\Sigma_0^ | \frac{n_{\mathrm{prior}}}{n_{\mathrm{prior}}+n_w},\Sigma_0 | (iii) Posterior Gamma shape | (iv) Posterior Gamma rate | (v) Marginal posterior mean of (\beta) | (vi) Posterior expectation of (\sigma^2=1/\tau) | For (a_n>1),[\mathbb{E}[\sigma^2\mid y] | \frac | (vii) Marginal posterior covariance of (\beta) | Let[V_n=\Sigma_ | Then[\mathrm{Cov}(\beta\mid y) | \mathbb{E}[\sigma^2\mid y],V_n | Interpretation | Theorem 2 (Weak‑prior limit of the dNormal_Gamma() posterior) | Under the default calibration of Theorem 1, let[n_ | (i) Limiting posterior mean of (\beta) | [\mu_ | \lim_ | (ii) Limiting dispersion‑free covariance | [\Sigma_ | \lim_ | (iii) Limiting Gamma shape | [a_ | \lim_{n_{\mathrm{prior}}\to 0^+} a_n | (iv) Limiting Gamma rate | [b_ | \lim_{n_{\mathrm{prior}}\to 0^+} b_n | (v) Limiting marginal mean of (\beta) | [\mathbb{E}{\Pi{0}}[\beta\mid y] | \mu_ | (vi) Limiting expectation of (\sigma^2 = 1/\tau) | For (\tau\mid y \sim \Gamma(a_{\Pi_{0}},b_{\Pi_{0}})),[\mathbb{E}{\Pi{0}}[\sigma^2\mid y] | \frac | (vii) Limiting marginal covariance of (\beta) | [\mathrm{Cov}{\Pi{0}}(\beta\mid y) | \mathbb | Proof of Theorem 2. | By Theorem 1, for each (n_{\mathrm{prior}}>0) the dNormal_Gamma posterior is Normal–Gamma withhyperparameters[\mu_{\mathrm{post}}(n_{\mathrm{prior}}),\quad\Sigma_{0,\mathrm{post}}(n_{\mathrm{prior}}),\quada_n(n_{\mathrm{prior}}),\quadb_n(n_{\mathrm{prior}}),]given explicitly by[\mu_{\mathrm{post}}(n_{\mathrm{prior}}) | \frac{n_{\mathrm{prior}}}{n_{\mathrm{prior}}+n_w},\mu+\frac{n_w}{n_{\mathrm{prior}}+n_w},\hat\beta,][\Sigma_{0,\mathrm{post}}(n_{\mathrm{prior}}) | \frac{n_w}{n_{\mathrm{prior}}+n_w},G^{-1},][a_n(n_{\mathrm{prior}}) | \frac{n_{\mathrm{prior}}+k+n_w}{2},\qquadb_n(n_{\mathrm{prior}}) | 3.3.3 Posterior covariance under dNormal() with default dispersion | Covariance under fixed (\sigma^2) | From Section 2.3.2, under scalar pwt,[\mathrm{Var}(\beta\mid y,\sigma^2) | For weighted Gaussian regression,[P(\beta^\ast) | \sigma^{-2}X^{\mathsf T}W_{\mathrm{obs}}X,]so[\mathrm{Var}(\beta\mid y,\sigma^2) | Using[n_ | \frac | \frac{n_w}{n_w+n_{\mathrm{prior}}},]this becomes[\mathrm{Var}(\beta\mid y,\sigma^2) | Default dispersion | To choose a default fixed value of (\sigma^2), Prior_Setup() uses theposterior mean from the Normal–Gamma model (Theorem 1 (vi)):[\mathrm | Substituting this into the covariance expression gives[\mathrm{Var}(\beta\mid y,\mathrm{dispersion}_{\mathrm{default}}) | Calibrated prior covariance returned by Prior_Setup() | With the same default dispersion, Prior_Setup() returns the coefficient‑scaleprior covariance[\Sigma_ | Weak‑prior limit | 3.3.4 Independent Normal–Gamma Prior | Coefficient-scale covariance:[\Sigma | ING Gamma shape:[\mathrm | a_0 + \frac | Gamma rate:[\texttt | b_0 | Theorem 3 (Weak-prior limit of the Independent Normal–Gamma posterior) | From the posterior ratio identity in A.2 and Lemma B, we have, for each (n_{\mathrm{prior}}>0),[\Pi^{(\mathrm{ING})}{n{\mathrm{prior}}}(\mathrm{d}\beta,\mathrm{d}\tau) | Let (f\colon\mathbb | For the moment statements, take (f(\beta,\tau)=\beta_j),(f(\beta,\tau)=\tau^{-1}), and(f(\beta,\tau)=(\beta-\mathbb{E}{\Pi_0}[\beta])(\beta-\mathbb{E}{\Pi_0}[\beta])^\top) componentwise.Lemma A again applies because Assumptions 4–5 ensure that the NG Gamma parametersstay uniformly bounded away from zero, giving uniform integrability of the correspondingNG moments.The same envelope (M) from Claim B.2 transfers this to the ING path via the ratiorepresentation. Hence dominated convergence applies to these (unbounded) test functionsas well, yielding[\mathbb{E}{\Pi^{(\mathrm{ING})}{n_{\mathrm{prior}}}}[\beta]\to\mathbb{E}{\Pi_0}[\beta]=\hat\beta,\quad\mathbb{E}{\Pi^{(\mathrm{ING})}{n{\mathrm{prior}}}}[\tau^{-1}]\to\mathbb{E}_{\Pi_0}[\tau^{-1}] | \frac{\mathrm{RSS}w}{n_w-p},]and[\mathrm{Cov}{\Pi^{(\mathrm{ING})}{n{\mathrm{prior}}}}(\beta\mid y)\to\mathrm{Cov}_{\Pi_0}(\beta\mid y) | 3.3.5 dGamma() Prior (Fixed $\beta$, Gamma Prior on Precision) | Prior on (\tau) (fixed-$\beta$ path) | Posterior for (\tau) given (y) and fixed (\beta^{+}) | Posterior expectation of (\sigma^2 = 1/\tau) | For (a_n > 1),[E[\sigma^2 \mid y, \beta^{+}] | \frac | This completes the description of the fixed-$\beta$ Gamma prior used by dGamma() andrGamma_reg(). | Appendix A: Technical Ingredients for the ING Weak‑Prior Limit | A.1 Common Gaussian Setup | A.2 Posterior Ratio Representation | NG prior (Theorem 1, §3.3.2) | For each (n_{\mathrm{prior}} > 0),[\beta \mid \tau \sim N!\left(\mu,;\tau^{-1}\Sigma_0\right),\qquad\tau \sim \Gamma!\left(a_0(n_{\mathrm{prior}}),, b_0(n_{\mathrm{prior}})\right),]where the dispersion–free Zellner matrix is[\Sigma_0 | ING prior (§3.3.4) | The ING prior uses a fixed coefficient–scale covariance and a Gamma shape shifted by (p/2):[\beta \mid n_{\mathrm{prior}} \sim N!\left(\mu,;\Sigma(n_{\mathrm{prior}})\right),\qquad\tau \sim \Gamma!\left(a_0(n_{\mathrm{prior}})+\tfrac{p}{2},; b_0(n_{\mathrm{prior}})\right),]with (\beta) and (\tau) independent, and[\Sigma(n_{\mathrm{prior}}) | Ratio of prior kernels | Define[R_{n_{\mathrm{prior}}}(\beta,\tau) | Because the ING Gamma shape equals the NG Gamma shape plus (p/2), the (\tau)-powers match and cancel.The ratio therefore reduces to[R_{n_{\mathrm{prior}}}(\beta,\tau) | Posterior ratio identity | A.3 Lemma A: Uniform moment bounds for the NG path | Lemma A (Uniform moment bounds for the NG posterior) | Claim A.1 (Continuity and compactness of NG hyperparameters) | [\mu_{\mathrm{post}}(n_{\mathrm{prior}}) | [\Sigma_{0,\mathrm{post}}(n_{\mathrm{prior}}) | [a_n(n_{\mathrm{prior}}) | \frac{n_{\mathrm{prior}} + k + n_w}{2},\qquadb_n(n_{\mathrm{prior}}) | Proof of Lemma A | Bounds for (\tau) | [\mathbb{E}[\tau \mid y, n_{\mathrm{prior}}] | \frac{a_n(n_{\mathrm{prior}})}{b_n(n_{\mathrm{prior}})},\qquad\mathbb{E}[\tau^2 \mid y, n_{\mathrm{prior}}] | Bounds for (\beta) | [\mathbb{E}[\beta \mid y, n_{\mathrm{prior}}] | [\mathrm{Cov}(\beta \mid y, n_{\mathrm{prior}}) | [\mathbb{E}[\sigma^2 \mid y, n_{\mathrm{prior}}] | [\mathbb{E}\bigl[|\beta|^2 \mid y, n_{\mathrm{prior}}\bigr] | A.4 Lemma B: Ratio convergence and domination | Let (R_{n_{\mathrm{prior}}}(\beta,\tau)) be the posterior density ratio[R_{n_{\mathrm{prior}}}(\beta,\tau) | Claim B.1 (Explicit prior ratio and quadratic form) | Then (\tilde R_{n_{\mathrm{prior}}}) can be written in the form[\tilde R_{n_{\mathrm{prior}}}(\beta,\tau) | From Section A.2, the NG and ING prior kernels are[\pi^{(\mathrm{NG})}{n{\mathrm{prior}}}(\beta,\tau)\propto\tau^{a_0(n_{\mathrm{prior}})+p/2-1}\exp!\left(-b_0(n_{\mathrm{prior}})\tau-\frac{\tau}{2}(\beta-\mu)^\top\Sigma_0^{-1}(\beta-\mu)\right),][\pi^{(\mathrm{ING})}{n{\mathrm{prior}}}(\beta,\tau)\propto\tau^{a_0(n_{\mathrm{prior}})+p/2-1}\exp!\left(-b_0(n_{\mathrm{prior}})\tau\right)\exp!\left(-\frac{1}{2}(\beta-\mu)^\top\Sigma(n_{\mathrm{prior}})^{-1}(\beta-\mu)\right),]with[\Sigma_0 | \frac{1-pwt}{pwt},(X^\top W_{\mathrm{obs}}X)^{-1},\qquad\Sigma(n_{\mathrm{prior}}) | The (\tau)-powers match (ING shape = NG shape (+;p/2)), so[\tilde R_{n_{\mathrm{prior}}}(\beta,\tau) | \frac | Then[\tilde R_{n_{\mathrm{prior}}}(\beta,\tau) | Using the explicit formula for (\Sigma(n_ | \frac{n_{\mathrm{prior}}}{n_w},\frac{n_w - p}{\mathrm{Smarg}},(X^\top W_{\mathrm{obs}}X),]we see that (\Sigma(n_{\mathrm{prior}})^{-1}\to 0) as (n_{\mathrm{prior}}\to 0^+).This uses Assumptions 2–3 to ensure the scalar prefactor is positive.Hence, for each fixed (\beta),[h_{n_{\mathrm{prior}}}(\beta) | Claim B.2 (Uniform envelope and integrability) | [M(\beta,\tau) | Recall[R_{n_{\mathrm{prior}}}(\beta,\tau) | \frac | \tilde R_ | \iint L(y\mid\beta,\tau),\pi^ | Step 1: Envelope for (\tilde R_{n_{\mathrm{prior}}}). | From Claim B.1 and the explicit formulas in A.2,[\log \tilde R_{n_{\mathrm{prior}}}(\beta,\tau) | Step 2: Boundedness of the normalizing–constant ratio. | Step 3: Envelope for (R_{n_{\mathrm{prior}}}) and integrability under (\Pi_0). | Combining Steps 1–2,[\bigl|R_{n_{\mathrm{prior}}}(\beta,\tau)\bigr|\leK,M_0(\beta,\tau) | Write both posteriors as[\pi^{(\cdot)}{n{\mathrm{prior}}}(\beta,\tau\mid y)\proptoL(y\mid\beta,\tau),\pi^{(\cdot)}{n{\mathrm{prior}}}(\beta,\tau),]with the common Gaussian likelihood (L(y\mid\beta,\tau)) from Section A.1.The likelihood cancels in the posterior ratio, so[R_{n_{\mathrm{prior}}}(\beta,\tau) | \frac | \tilde R_ | \iint L,\pi^ | By Claim B.1,[\tilde R_{n_{\mathrm{prior}}}(\beta,\tau) | In our explicit construction, (q_{n_{\mathrm{prior}}}(\beta)) does not depend on(n_{\mathrm{prior}}) at all, and[h_{n_{\mathrm{prior}}}(\beta) | Next, write the normalizing–constant ratio as[\frac | \frac | \frac | Finally,[R_{n_{\mathrm{prior}}}(\beta,\tau) | A.8 Summary | Appendix B: Derivation of Theorem 1 (Conjugate Normal–Gamma posterior) | B.1 Setup and joint kernel | Under the Zellner calibration in §3.3.2,[\Sigma_0 | \frac | The joint prior–likelihood kernel in ((\beta,\tau)) is[\pi(\beta,\tau\mid y)\propto\tau^{a_0-1}\exp(-b_0\tau),\tau^{p/2}\exp!\Bigl(-\tfrac{\tau}{2}(\beta-\mu)^\top\Sigma_0^{-1}(\beta-\mu)\Bigr),\tau^{n_w/2}\exp!\Bigl(-\tfrac{\tau}{2}\mathrm{RSS}_w(\beta)\Bigr),]where[\mathrm{RSS}_w(\beta) | B.2 Posterior Normal block: mean and dispersion‑free covariance | Write[G_{\mathrm{post}} := G + \Sigma_0^{-1},]and complete the square:[(\beta-\hat\beta)^\top G(\beta-\hat\beta)+(\beta-\mu)^\top\Sigma_0^{-1}(\beta-\mu) | Using (\Sigma_0^ | \Bigl(1+\frac{n_w}{n_{\mathrm{prior}}}\Bigr)G | \frac | Substituting into (\mu_ | \frac | G_ | \frac | B.3 Posterior Gamma block: shape and rate | The integral over (\beta) is a multivariate Gaussian integral:[\int \tau^{p/2}\exp!\Bigl(-\tfrac{\tau}{2}Q(\beta)\Bigr),d\beta | After cancellation, the only remaining powers of (\tau) are[a_0 - 1 + \frac{n_w}{2},]so the posterior Gamma shape is[a_n | a_0 + \frac | \frac | Thus[b_n = b_0 + \frac | \frac | B.4 Marginal moments of (\beta) and (\sigma^2) | Given (\tau), the posterior factorizes as[\beta\mid\tau,y \sim N\bigl(\mu_ | \frac | \frac{n_{\mathrm{prior}}+n_w}{n_w},G^{-1},][a_n | \frac{n_{\mathrm{prior}}+k+n_w}{2},\qquadb_n | Marginal mean of (\beta).Using the law of total expectation,[E[\beta\mid y] | E_\tau\bigl[E[\beta\mid\tau,y]\bigr] | E_\tau[\mu_{\mathrm{post}}] | \mu_{\mathrm{post}},]since (\mu_{\mathrm{post}}) does not depend on (\tau). Thus[E[\beta\mid y] | Marginal mean of (\sigma^2 = \tau^{-1}).For (\tau\sim\Gamma(a_n,b_n)) with shape–rate parameterization,[E[\tau^{-1}\mid y] | Substituting the expressions for (a_n) and (b_n),[E[\sigma^2\mid y] | \frac | Marginal covariance of (\beta).By the law of total covariance,[\mathrm{Cov}(\beta\mid y) | E_\tau\bigl[\mathrm{Cov}(\beta\mid\tau,y)\bigr]+\mathrm{Cov}\tau\bigl(E[\beta\mid\tau,y]\bigr).]Since (E[\beta\mid\tau,y]=\mu{\mathrm{post}}) does not depend on (\tau), the second term vanishes and[\mathrm{Cov}(\beta\mid y) | E_\tau\bigl[\tau^{-1}\Sigma_{0,\mathrm{post}}\bigr] | Substitute:[a_n-1 | \frac{n_{\mathrm{prior}}+k+n_w}{2}-1 | \frac{n_{\mathrm{prior}}+k+n_w-2}{2},]so[E[\tau^{-1}\mid y] | \frac | Step 2: (\Sigma_ | Under the Zellner calibration,[\Sigma_0 | \frac | Hence[\Sigma_0^{-1} + G | \Bigl(\frac{\mathrm{pwt}}{1-\mathrm{pwt}} + 1\Bigr)G | \frac | Now use the mapping between (\mathrm | \frac | Thus[\Sigma_ | (1-\mathrm | Step 3: Combine the pieces.Putting Steps 1 and 2 together,[\mathrm{Cov}(\beta\mid y) | E[\tau^ | In particular, the covariance can be written as[\mathrm{Cov}(\beta\mid y)

Last update: 2026-09-30
Started: 2026-09-30

Core 11: Large models — GPU acceleration using OpenCL (backend installation)
Introduction | What you see when you load glmbayesCore | Enabling GPU acceleration: three steps | Step 1: Check whether OpenCL is already enabled | Step 2: Ensure dependencies are OpenCL-ready | Step 3: Reinstall glmbayesCore from source | Windows | Linux / macOS | After the install | Verifying the setup | Running a GPU-accelerated model | Appendix A: AMD GPUs on Linux (ROCm OpenCL)

Last update: 2026-09-30
Started: 2026-09-30

Readme and manuals

Help Manual

Help pageTopics
glmbayesCore: Core C++ Sampling Engine for 'glmbayes'glmbayesCore-package glmbayesCore
Amitriptyline overdose dataAMI
Bike Sharing Dataset (Processed)BikeSharing
Boston housing data with mean-centered predictorsBoston_centered
Canadian Automobile Insurance Claims for 1957-1958carinsca
Check identifiability and estimability of a single-factor mixed-model designcheck_identifiability
Cleveland Heart Disease DatasetCleveland
Compute Calibrated Gaussian Normal–Gamma Prior Componentscompute_gaussian_prior
Build a named list of dGamma measurement-dispersion priorsdGamma_list dGamma_list.Prior_Setup_GLMM print.dGamma_list
GPU and OpenCL diagnostics for 'glmbayes'diagnose_glmbayes glmbayesCore_has_opencl gpu_diagnostics print.diagnose_glmbayes
GPU-Accelerated Envelope Construction for Posterior SimulationEnvelopeBuild EnvelopeSetGrid EnvelopeSetLogP
Envelope Centering for Bayesian Gaussian RegressionEnvelopeCentering
Builds Dispersion-Aware Envelope for SimulationEnvelopeDispersionBuild
Evaluate Negative Log-Likelihood and GradientsEnvelopeEval
Envelope Construction Orchestrator for Bayesian Gaussian RegressionEnvelopeOrchestrator
Envelope Sizing and OptimizationEnvelopeOpt EnvelopeSize
Sorts Envelope function for simulationEnvelopeSort
Model Formulae for 'summary.rglmb' Objectsformula.summary.rglmb
The Central Gamma Distributionctrgamma Gamma_ct pgamma_ct rgamma_ct
Standardize A Non-Gaussian Modelglmb_Standardize_Model
Return family functions used during simulation and post processingglmbfamfunc print.glmbfamfunc
The Central Inverse-Gamma DistributionInvGamma_ct pinvgamma_ct qinvgamma_ct rinvgamma_ct
Model setup for generalized linear mixed modelsmodel_setup print.model_setup
Prior setup for multiple Gaussian responsesmulti_prior_setup
Multi-response Bayesian regression and simulationmulti_rindepNormalGamma_reg multi_rlmb multi_rNormalGamma_reg
Multi-response Normal regression simulationmulti_rNormal_reg
The Central Normal DistributionNormal_ct pnorm_ct rnorm_ct
Normalize a row-group partitionnormalize_group
Prior Family Objects for Bayesian ModelsdBeta dGamma dIndependent_Normal_Gamma dNormal dNormal_Gamma pfamily print.pfamily
Build a named list of pfamily objects from a prior-setup objectpfamily_list pfamily_list.Prior_Setup_GLMM print.pfamily_list
Checks for Prior-data conflictsPrior_Check
Setup Prior Objectsprint.PriorSetup Prior_Setup
Prior setup for generalized linear mixed modelsprint.Prior_Setup_GLMM Prior_Setup_GLMM
Prior setup for row-block regressionspfamily_list.Prior_SetupGroup print.Prior_SetupGroup Prior_SetupGroup
Prior Simulation Functions for glmbayesCore pfamily Objectsprior_simfuncs rBeta_prior rGamma_Conjugate_prior rGamma_prior rIndependent_Normal_Gamma_prior rNormal_Gamma_prior rNormal_prior
Deviance Residuals for 'rglmb' and 'summary.rglmb' Objectsresiduals.rglmb residuals.rlmb residuals.summary.rglmb
The Bayesian Generalized Linear Model Distributionprint.rglmb rglmb
The Bayesian Gaussian Regression with Independent Normal-Gamma Prior in Standard FormrIndepNormalGammaReg_std
The Bayesian Linear Model Distributionprint.rlmb rlmb
Bayesian Weighted Fitting Enginesglmb.wfit rNormal_reg.wfit
The Bayesian Generalized Linear Model Distribution in Standard FormrNormalGLM_std
Simulation Functions for Bayesian Generalized Linear Modelsprint.rGamma_reg print.simfunction rBeta_reg rGamma_Conjugate_reg rGamma_reg rindepNormalGamma_reg rNormalGamma_reg rNormal_reg simfuncs simfunction
Conditionally independent row-group simulation (Gibbs / product likelihood)rNormalGLM_reg_group rNormal_reg_group simfuncs_group
Low-Level Simulation Pipeline for Bayesian GLMsSimulationPipeline
Summarizing mrglmb Objectsprint.summary.mrglmb summary.mrglmb
Summarizing Bayesian gamma_reg Distribution Functionsprint.summary.rGamma_reg summary.rGamma_reg
Summarizing Bayesian Generalized Linear Model Distribution Functionsprint.summary.rglmb summary.rglmb summary.rlmb