No articles match
Chapter A07: Accept–Reject Sampling for gaussian Regression models with independent normal-gamma priors8 days ago
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)
Chapter A10: Accelerated EnvelopeBuild Implementation using OpenCL8 days ago
1. Introduction | 2. Architecture Overview | 2.1 Call Path | 3. Program Construction | 3.1 Assembly order (production) | 3.2 opencltools loaders | 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
Chapter 12: The nmathopencl R API --- Distribution Functions on the GPU1 months ago
Overview | Checking availability | Normal distribution | Distribution families | Gamma | Binomial | Poisson | Beta | Additional families | Noncentral distributions | Special functions and math support | R extension utilities (R_ext) | RNG core | Fallback behavior in detail | Performance notes
Chapter 00: nmathopencl --- Package Overview1 months ago
What is nmathopencl? | Three-layer architecture | C++ layout inside the package DLL | Related packages | R-side API families | Checking OpenCL availability | Vignette guide
Chapter 01: Setting Up OpenCL and Enabling GPU Acceleration1 months ago
Overview | When you load nmathopencl | What the message means | opencltools as imported dependency | What "compiling with OpenCL" means | Enabling OpenCL for nmathopencl | Step 1: Read the load message | Step 2: If OpenCL is not enabled at all | Step 3: If opencltools is enabled but nmathopencl is not | Verifying the setup | Validating GPU calls with the exported wrappers | Troubleshooting common failures | nmathopencl_has_opencl() returns FALSE after driver installation | Compilation fails with CL/cl.h: No such file or directory | Runtime error: clGetPlatformIDs: CL_PLATFORM_NOT_FOUND_KHR | PATH warnings from opencltools::diagnose_glmbayes() | For package developers: next steps
Chapter 03: Structure of nmath Kernel Programs1 months ago
Why "programs" rather than compiled objects | No #include on the device | The four-layer program structure | Layer 0: OPENCL.cl --- the global configuration header | Layer 1: The upstream shim layer | Type stubs | Capability macros | Runtime no-ops | Math declarations | The design principle | Layer 2: The nmath library and its annotation scheme | @provides and @depends annotations | Only the required subset is loaded | Layer 3: The kernel function | Assembling the program in C++ | What this means for downstream developers
Chapter 05: Kernels, Kernel Runners, and Kernel Wrappers1 months ago
Introduction | How this chapter is organized | The computation in the example: GLM log-posterior over a grid | Serial vs. parallel execution: the fundamental concept | The serial (CPU) mental model | The parallel (GPU) mental model | When OpenCL is not available | Summary | The kernel wrapper | General description | Example: f2_f3_opencl from ex_glmbayes | Step 1 — Convert C++ input types to flat std::vector | Step 2 — Allocate output buffers | Step 3 — Select the kernel and assemble the program string | Step 4 — Dispatch to the runner | Step 5 — Convert outputs from plain C++ back to the required return types | The kernel runner | Example: f2_f3_kernel_runner from ex_glmbayes | Step 1 — Select a device | Step 2 — Create a context and command queue | Step 3 — Compile the program on-device | Step 4 — Allocate device buffers and transfer input data | Step 5 — Bind kernel arguments | Step 6 — Launch the kernel | Step 7 — Read results back to the host (blocking) | Step 8 — Release all resources | The kernel (*.cl) | Example: f2_f3_binomial_logit from ex_glmbayes | The kernel signature | The parallel execution body | The complete call chain | CRAN safety: how the architecture prevents build failures | Applying the pattern in your package | File layout | Type conversion reference | Headers and DESCRIPTION
Chapter 06: Integrating Kernel Wrappers into Your Codebase1 months ago
Introduction | The two integration patterns | Pattern 1: wrapper with a direct R interface | Pattern 2: wrapper as an internal C++ component | Pattern 1 in detail: dnorm_opencl | The R wrapper | The .opencl_try_or_fallback helper | The C++ kernel wrapper | Pattern 2 in detail: f2_f3_opencl | The exported R function | The C++ dispatcher | Why a dedicated CPU implementation? | Choosing between the two patterns | Naming conventions | Summary
Chapter 09: Generic OpenCL Kernel Runners (openclPort layer)1 months ago
The openclPort namespace | opencl_dbl_scalar_kernel_runner | Declaration | Arguments | What it does | Argument layout contract | Example: calling the runner from a kernel wrapper | Error-handling utilities | opencl_status_name | opencl_status_hint | opencl_read_platform_info_str / opencl_read_device_info_str | opencl_make_context_error | Other utilities in openclPort | Rcpp -> std::vector conversion | Device probing (C++ / openclPort) | OpenCL build configuration | Using openclPort from a downstream package
Chapter 10: Case Study --- Building Custom GLM Kernels (ex_glmbayes)1 months ago
Overview | Step 1 --- Identify the nmath functions your kernel needs | Step 2 --- Extract the minimal nmath subset | Step 3 --- Write the kernel files | Step 4 --- Write the kernel runner (C++) | Step 5 --- Write the kernel wrapper (C++) | Why load_library_for_kernel() rather than load_kernel_library()? | Step 6 --- Write the Rcpp export wrappers (C++ and R) | Step 7 --- Implement the CPU fallback | File inventory | OpenCL source (inst/cl/) | C++ source (src/) | C++ headers (src/) | R source (R/) | Adapting this pattern for a new package
Chapter 11: Testing, Debugging, and Benchmarking GPU Kernels1 months ago
Correctness testing | Debugging kernel failures | Benchmarking
Chapter 02: Adding USE_OPENCL and has_opencl() to Your Package1 months ago
Overview | Why a static src/Makevars breaks CRAN | The configure → USE_OPENCL → has_opencl() chain | Adding has_opencl() to your package | C++ side | R side | Case 1: New package with no existing src/Makevars | Case 2: Existing package with a static src/Makevars | What is preserved | Caveats | Guarding OpenCL code in C++ | Testing the CPU-only path before CRAN submission | DESCRIPTION dependencies | Migration note
Chapter 04: The nmath OpenCL Library1 months ago
What is inst/cl/nmath/? | Annotation scheme | File families | Infrastructure / header files | Core math helpers | Density functions (d*) | CDF functions (p*) | Quantile functions (q*) | Random-variate generators (r*) | Special functions | Additional utilities | Cycle-breaking artifacts | The ex_glmbayes_nmath/ subset | Porting fidelity
Chapter 07: Kernels --- Writing and Using OpenCL Kernel Files1 months ago
What is a kernel? | Anatomy of a simple kernel | Standard argument layout | The *_ex_kernel.cl variants | Kernel file index | Density kernels | CDF kernels | Quantile kernels | Random-variate kernels | Special function kernels | Math support kernels | RNG core kernels | Utility kernels | Bessel kernels (standard and extended) | Program assembly | Writing a custom kernel
Chapter 08: Kernel Loading --- load_kernel_source and load_kernel_library1 months ago
The assembly problem | opencltools::load_kernel_source() | opencltools::load_kernel_library() | The annotation format | The topological sort algorithm | Verbose output | Cycle detection and breaking | Assembling a complete program | Using libraries from another package | Dependency index --- faster, kernel-specific loading | Building the index --- write_kernel_dependency_index() | Loading with the index --- load_library_for_kernel() (R) | Extracting a subset --- extract_library_subset() | C++ equivalent --- openclPort::load_library_for_kernel() | Error messages
Chapter 00: Introduction2 months ago
Part 1: An Introduction | Part 2: Bayesian regression models | Part 3: Generalized Linear Models | Part 4: Advanced Topics | Part 5: Simulation Methods and Technical Implementation | Companion textbooks
Chapter 05: Model predictions and posterior predictive checks (+ bayesplot ppc_*)2 months ago
Introduction | Reviewing Model Predictions | Predictions for Actual Data | Predictions for "New" Data | Reviewing Model Residuals | Posterior predictive checks with 'bayesplot' (optional) | Using the DIC Statistic | Running The Probit Model | Running The Clog-Log Model | Running The Reverse Clog-Log Model | Comparing the DIC Statistics | Plotting Predictions and Residuals For the Additional Models | Probit Model | clog-log Model | Reverse clog-log Model
Chapter 06: Deviance residuals, model statistics and posterior inference (+ bayestestR)2 months ago
Introduction | Reviewing Model Predictions | Predictions for Actual Data | Predictions for "New" Data | Reviewing Model Residuals | Posterior predictive checks with 'bayesplot' (optional) | Using the DIC Statistic | Running The Probit Model | Running The Clog-Log Model | Running The Reverse Clog-Log Model | Comparing the DIC Statistics | Plotting Predictions and Residuals For the Additional Models | Probit Model | clog-log Model | Reverse clog-log Model
Chapter 12: Visualizing posteriors with bayesplot2 months ago
1. Purpose | 2. Minimal binomial fit (Menarche) | 3. Coefficient trace and density overlays | 4. Posterior predictive checks | See also
Chapter 13: Bayesian inference and decision making with bayestestR2 months ago
1. Purpose | 2. Example: logistic regression posterior for coefficients | 3. Point and interval summaries | See also
Chapter 02-S02: Normal–Normal Conjugacy for One Mean2 months ago
1. The model | 1.1 Likelihood | 1.2 Prior | 1.3 Posterior derivation | 2. bayesrules illustration | 3. Real data: Old Faithful waiting times | 3.1 Fitting with lmb() | 4. Connection to glmbayes | See also
Chapter 02-S03: Beta–Binomial Conjugacy for One Proportion2 months ago
1. The model | 1.1 Likelihood | 1.2 Prior | 1.3 Posterior derivation | 1.4 The posterior mean as a compromise | 2. bayesrules illustration | 3. Real data: the Bechdel test | 3.1 Fitting with glmb() using dBeta() | 4. Connection to glmbayes | See also
Chapter 02-S04: Gamma–Poisson Conjugacy for One Count Rate2 months ago
1. The model | 1.1 Likelihood | 1.2 Prior | 1.3 Posterior derivation | 2. bayesrules illustration | 3. Fitting with glmb() | 4. Connection to glmbayes | Appendix A. Heart transplant mortality (@Albert2009) | A.1 Fitting with glmb() | See also
Chapter 02-S05: Gamma–Gamma Conjugacy for One Response Rate2 months ago
1. The model | 1.1 Likelihood | 1.2 Prior | 1.3 Posterior derivation | 2. Illustration with base-R plots | 3. Real data: Boston Marathon finishing times | 3.1 Fitting with glmb() | 4. Connection to glmbayes | See also
Chapter 10: Models for the Poisson family2 months ago
1. Introductory Discussion | 2. Poisson Likelihood and Model Structure | 2.1 Weighted Poisson Log‑Likelihood | [\ell(\beta) | \sum_{i=1}^n\left[w_i y_i \log(\mu_i) | \sum_{i=1}^n\left[w_i y_i \eta_i | 2.2 Exponential‑Family Representation | 2.3 Log Link and Its Properties | 2.4 Likelihood, Prior, and Posterior (Normal Prior on beta) | [\log p(\beta) | [\log p(\beta \mid y) | w_i e^{\eta_i}\right] | 3. Data Setup | 4. Classical Poisson Regression | 4.1 Interpretation of the Classical Output | 5. Bayesian Poisson Regression with glmb() | 5.1 Setting the Prior | 5.2 Calling glmb() | 6. Printing and Summarizing the Bayesian Output | 6.1 Posterior Mean Coefficients | 6.2 Effective Number of Parameters | 6.3 DIC | 7. Comparison of Classical and Bayesian Estimates | 8. Credible Intervals and Posterior Interpretation | 9. Concluding Remarks | Appendix A. Bayes Rules! companion — equality_index Poisson regression
Chapter 01: Getting started — Setting up OpenCL2 months ago
Introduction | 1. Download and install build tools | 1.1 Windows: Install Rtools | 1.2 Linux: Install compiler toolchain and R development headers | Installing the latest R on Ubuntu/Debian (optional but recommended) | 1.3 macOS: Install Xcode Command Line Tools and GCC | 2. Install OpenCL components | 2.1 Windows | 2.2 Linux | 2.2.1 OpenCL implementation (vendor runtime) | 2.2.2 OpenCL header files | 2.2.3 OpenCL runtime (ICD loader) | 2.2.4 OpenCL development library (linker symlink) | 2.2.5 Verify OpenCL platforms with clinfo (Linux, recommended) | 2.3 macOS | 3. Install opencltools from source (for OpenCL) | 4. Load the package | 5. Check for OpenCL availability | 5.1 Full diagnostic | 6. Verify the kernel-loading path | Appendix A: AMD GPUs on Linux (ROCm OpenCL recommended) | Install ROCm OpenCL (Ubuntu LTS) | Supported AMD GPUs | Other AMD OpenCL stacks | References
Chapter 02: Using a ported library — assembling kernel programs2 months ago
Introduction | 1. Anatomy of a ported library | 1.1 Shard annotations | 2. The nmath module | 3. Loading kernel source files | 3.1 Single file | 3.2 A whole library directory | 4. Program assembly | 5. Minimal subsetting — loading only the nmath shards a kernel needs | 6. Annotating your kernel files | 6.1 Declare the library (one line, written by you) | 6.2 Step 1 — scan source, write direct-call tags | 6.3 Step 2 — compute transitive closure | 7. Verifying portability | 8. Maintaining a library index | Cross-references
Chapter 03: Kernel runners and wrappers — the glmbayes pattern2 months ago
Introduction | 1. Architecture overview | Call path | 2. Kernel structure | Step 1 — Work-item mapping | Step 2 — Prior term | Step 3 — Prior gradient | Step 4 — Data loop | Step 5 — Write outputs | 2.1 Supported family/link kernels in glmbayes | 3. The kernel wrapper | Linking against opencltools | 4. The kernel runner | 5. Fail gracefully — the dispatch pattern | 6. The pilot pattern | 7. Setting up OpenCL before first use | Cross-references | References
Chapter 01: Getting started with glmbayes2 months ago
1. Introductory Discussion | 2. Preparing a dataframe | 3. Calling the two functions | 3.1 Using the classical glm function | 3.1.1 Calling the classical glm function | 3.2 Setting the Prior and Calling the glmb function | 3.2.1 Setting the prior | 3.2.2 Calling the glmb function | 4. Printing the output | 4.1 Printed glm output | 4.1.1 Coefficients | 4.1.2 Null and Residual Degrees of Freedom | 4.1.3 Residual Deviance | 4.1.4 AIC | 4.2 Printed glmb output | 4.2.1 Posterior Mean Coefficients | 4.2.2 Effective Number of Parameters | 4.2.3 Expected Residual Deviance | 4.2.4 DIC | 5. Textbook Content Mappings | 5.1 Agresti - Foundations of Linear and Generalized Linear Models
Chapter 02-S01: Conjugate Models — Introduction and Overview2 months ago
1. What is Bayesian inference, and why does it matter? | 1.1 The big picture | 1.2 Bayes' theorem | 1.3 Why conjugacy is a gift | 2. Three principles that run through all conjugate models | 2.1 The posterior is always a compromise | 2.2 Credible intervals mean what you think they mean | 2.3 The conjugate prototype and the regression generalization | 3. Putting it all together: from simple models to regression | 3.1 Roadmap | 3.2 What conjugacy gives you — and what it does not | See also
Chapter 03: Estimating Bayesian linear models2 months ago
1. Introductory discussion | 2. Linear Model Structure and Gaussian Likelihood (Fixed Dispersion) | 2.1 Gaussian Log‑Likelihood (Fixed Dispersion) | [\ell(\beta) | 2.2 Normal Prior on (\beta) | 2.3 Log‑Posterior and Conjugate Updating | [\Sigma_ | [\mu_ | 2.4 Why Fixing Dispersion Matters | 3. Sample Data - Dobson's Plant weight data | 4. Calling the two functions | 4.1 Using the classical lm function | 4.1.1 Calling the classical lm function | 4.2 Setting the prior and calling the lmb function | 4.2.1 Setting the prior | 4.2.2 Calling the lmb function | 5. Summarizing the output | 5.1 Summarizing the lm output | 5.1.1 Residual summary | 5.1.2 Coefficient Estimates and Hypothesis Tests | 5.1.3 Model fit statistics | 5.2 Summarizing the lmb output | 5.2.1 Prior and maximum‐likelihood estimates | 5.2.2 Posterior estimates | 5.2.3 Directional Prior-Posterior Summaries | 5.2.4 Distribution percentiles
Chapter 08: Estimating Bayesian generalized linear models2 months ago
General Discussion | The Age of Menarche Data | Variable Transformation and Preliminary Setup | Setting prior point estimates, associated credible intervals, and correlation | Mapping the prior to the link scale | Running the Model | Appendix A. Bayes Rules! companion — logistic priors on weather_perth | Concluding Discussion
Chapter 09: Models for the Binomial family2 months ago
1. Introductory Discussion | 2. Binomial Likelihood and Weighted Formulation | 2.1 Linear predictor and mean structure | 2.2 Weighted binomial log‑likelihood | [\ell(\beta) | 2.3 Exponential‑family representation | The binomial likelihood belongs to the exponential family [@McCullagh1989; @Agresti2015].For a model with linear predictor[\eta_i = x_i^\top \beta,]and mean[\mu_i = g^{-1}(\eta_i),]the contribution of observation (i) to the log‑likelihood can be written as[\ell_i(\beta) | 2.4 Link functions | 3. Specifying Binomial Models in glmbayes | 3.1 Prior Specification | 4. Logit Link: Likelihood, Prior, Posterior | Weighted Log-Likelihood | [\ell_{\text{logit}}(\beta) | Normal Prior | [\log p(\beta) | Log-Posterior | [\log p(\beta \mid y) | \sum_{i=1}^nw_i\Big[y_i,\eta_i - \log(1+e^{\eta_i})\Big] | 4.1 Example Data | 4.2 Prior Setup | 4.3 Fit the Model | 4.4 Summary | 5. Probit Link: Likelihood, Prior, Posterior | [\ell_{\text{probit}}(\beta) | \sum_{i=1}^nw_i\Big[y_i \log\Phi(\eta_i)+(1-y_i)\log\big(1-\Phi(\eta_i)\big)\Big] | 5.1 Prior Setup | 5.2 Fit the Model | 5.3 Summary | 6. Complementary Log-Log (cloglog) Link: Likelihood, Prior, Posterior | [\ell_{\text{cloglog}}(\beta) | \sum_{i=1}^nw_i\Big[y_i \log!\big(1 - e^{-e^{\eta_i}}\big)+(1-y_i)\big(-e^{\eta_i}\big)\Big] | 6.1 Prior Setup | 6.2 Fit the Model | 6.3 Summary | 7. Comparing Link Functions | 8. Concluding Discussion | Appendix A. Bayes Rules! companion — Perth rain (weather_perth)
Chapter 11: Models for the Gamma family2 months ago
1. Introductory Discussion | 2. Gamma Likelihood and Model Structure (Log Link, Fixed Dispersion) | 2.1 Weighted Gamma Log-Likelihood (Log Link) | [\ell(\beta) | \sum_{i=1}^nw_i\left[-\frac{1}{\phi},\eta_i | 2.2 Exponential-Family Representation | 2.3 Log Link and Its Properties | 2.4 Likelihood, Prior, and Posterior (Normal Prior on (\beta)) | [\log p(\beta) | [\log p(\beta \mid y) | \frac{1}{\phi},y_i e^{-\eta_i}\right] | 3. Link Functions for Gamma GLMs | 4. Gamma Regression Example: Insurance Claims | 4.1 Data Setup | 4.2 Classical Gamma Regression Using glm() | 5. Bayesian Gamma Regression (fixed dispersion) with glmb() | 5.1 Estimating Dispersion via gamma.dispersion() | 5.2 Prior Setup Using Prior_Setup() | 5.3 Fitting the Bayesian Gamma Model | 5.4 Summarizing the Bayesian Model | 6. Interpretation and Model Diagnostics | 6.1 Coefficients | 6.2 Dispersion | 6.3 DIC and Model Fit | 7. Concluding Discussion | Appendix A. Bayes Rules! companion
Chapter 04: Tailoring priors — leveraging the Prior_Setup function2 months ago
1. Introductory Discussion | 2. The default prior specification | 2.1 Identifiability and Full–Rank Likelihood Covariance | 2.2 Canonical Precision Definitions and Scaling | 2.3 Posterior Mean via Precision Matrices | 2.4 The impact of the "null_model" and "null_effects" defaults for the interpretation of model diagnostics | 3. Adjusting the strength of priors using pwt, n_prior, and sd | 3.1 Data Setup and Visualization | 3.2 Using the pwt argument to adjust the Zellner g-prior | 3.3 Using n_prior as an alternative | 3.4 Directly Specifying Prior Standard Deviations with sd | 4. Adjusting the prior means using intercept_source, effects_source, and mu | 4.1 Using intercept_source and effects_source | 4.2 The role of the intercept_source in setting the prior mean for the intercept | 4.2.1 Intercept Prior: Centered at Full Model MLE | 4.2.2 Effect Priors: Centered at Zero | 4.2.3 Summary | 4.3 The role of the effects_source in setting the prior mean for the model effects | 4.4 Manually Setting Prior Means Using mu | 4.4.1 How mu interacts with the other arguments | 4.4.2 Requirements for user‑specified mu | 4.4.3 When manual mu is useful | 4.4.4 Example: specifying a custom prior mean | 4.4.5 Relationship between mu and prior strength | 4.4.6 Summary | 5. Practical Considerations for Prior Means and Prior Strength | 5.1 Centering and Scaling of Predictors | 5.2 Choosing the Prior Mean for the Intercept | 5.3 Choosing the Prior Means for the Effects | 5.4 When to Specify mu Directly | 5.5 Choosing the Strength of the Prior | 5.6 Interaction Between Prior Location and Prior Strength | 5.7 Summary
Chapter 07: Foundations of GLMs — families, links, and log-concave likelihoods2 months ago
1. Conceptual Overview | 1.1 Exponential Families: A Unifying Framework | 1.2 Canonical Link Functions | 1.3 Why Log-Concavity Matters | (a) Existence of gradients and subgradients | (b) Any local maximum is a global maximum | (c) Validity of envelope construction methods | (d) Simplified Bayesian computation | 2. Generalized Linear Models in Practice: Formulas, Families, and Links | 2.1 The Formula Interface and the Linear Predictor | 2.2 Family Objects: How glm Receives the Distribution and Link | Specifying a non‑default link | Binomial response formats | Quasi‑families | 2.3 Link Functions: Connecting Means to Linear Predictors | 2.4 How glm Combines Formulas, Families, and Links | A critical example: how glm receives formula, family, and link | 2.5 Transition to the Complete Family–Link Reference | 3. Families and Link Functions in glm() | 3.1 Families and Link Functions in Base R | Notes | 3.2 How Families and Links Fit the Exponential‑Family Structure | 3.3 Where to Find the Full Mathematical Forms | 3.4 Why This Matters for Bayesian GLMs | 4. Bayesian GLMs with glmb() | 4.1 Relationship to Classical GLMs | 4.2 The pfamily Argument: Specifying Priors | 4.3 Supported Likelihood Families | 4.4 A Direct Illustration: Calling glmb() with Formulas, Families, and Priors | 4.5 Posterior Sampling | 4.6 Returned Object | 4.7 Related Functions | 5. Log‑Concavity, Envelopes, and Posterior Computation | 5.1 Why Log‑Concavity Matters | 5.2 Envelope Construction | 5.3 Posterior Computation Strategy | 5.4 Summary | Appendix A. Full Exponential‑Family Forms for All glm() Families and Links | Appendix A. Exponential-family and link reference tables | A.1 Gaussian Family | A.2 Binomial Family | A.3 Poisson Family | A.4 Gamma Family | A.5 Inverse Gaussian Family | A.6 Quasi Families
Chapter 15: Estimating models with unknown dispersion parameters2 months ago
1. Introduction | 2. Exponential-Family Background and Log-Concavity | [\ell(\beta,\phi) | 2.2 Special Case: Weighted Gaussian Linear Regression | Weighted log-likelihood | [\ell(\beta,\tau) | Exponential-family identification | [c(y_i,\phi) | Weighted least squares representation | Log-Concavity Properties in the Weighted Gaussian Case | Concavity in ( \beta )For fixed ( \phi ), the negative weighted log-likelihood is[-\ell(\beta \mid \phi) | Concavity in precision ( \tau = 1/\phi )Rewriting the weighted likelihood in terms of ( \tau ):[\ell(\beta,\tau) | 2.3 Special Case: Gamma Regression With a Log Link | Log‑concavity | Implications for Bayesian GLMs | 3. Gaussian Model With Unknown Dispersion | 3. Priors for Gaussian Models With Unknown Dispersion | [\mathrm{RSS}(\beta) | 3.1 Prior on the Dispersion Only (Gamma Prior on Precision) | [\log p(\tau) | 3.2 Joint Conjugate Normal–Gamma Prior | Log-prior | [\log p(\beta,\tau) | Log-posterior | [\log p(\beta,\tau \mid y) | 3.3 Independent Normal–Gamma Prior | 3.3.1 Independent Normal Gamma Prior in glmbayes | 3.3.2 Two-Block Gibbs Sampling using glmbayes | 3.3.3 Comparison of the Two Samplers | 4. Gamma Regression Models With Unknown Dispersion | 4.1 Prior on the Dispersion Only (Gamma Prior on Precision) | [\log p(\tau \mid \beta,y) | 4.2 Independent Normal–Gamma Prior | Log‑prior | Log‑posterior | 4.3 Conditional Sampling for the Dispersion Parameter | 8. Summary | A1: Posterior Distribution Details for Conjugate Normal-Gamma prior | A1.1 Marginal Posterior for ( \tau ) | [S_ | Equivalently, expanding ( (I + X\Sigma_{0}X^{\mathsf T})^{-1} ) with theSherman--Morrison--Woodbury formula gives the same middle matrix in theprecision form[G - G\left(\Sigma_{0}^{-1} + G\right)^{-1}G | A1.2 Conditional Posterior for ( \beta ) | [V_ | \left(\Sigma_ | A1.3 Sampling the Posterior | Step 1: Draw the marginal posterior for ( \tau ) | Step 2: Draw ( \beta ) conditionally on each sampled ( \tau ) | [V_ | [m_ | Result: Pure i.i.d. Monte Carlo Sampling | A2. Detailed sampling procedured for the Independent Normal-Gamma prior | A2.1 iid Sampling Under Truncated Gamma Priors | A3. Posterior mean of ( \beta ) and marginal covariance (Zellner-type prior) | A3.1 Weighted likelihood and prior precision | [\mathrm | A3.2 Posterior mean of ( \beta ) | [\tau G + \tau \frac{pwt}{1-pwt} G | [\mathrm{Cov}(\beta \mid \tau, y) | \frac | [\boxed{E(\beta \mid y) | (1-pwt),\hat\beta + pwt,\mu_ | A3.3 Marginal covariance of ( \beta ) and the Gamma parameters | [V_ | [\boxed{\mathrm{Cov}(\beta \mid y) | E(\tau^ | [S_ | This is the same scalar as the augmented residual sum of squares S produced byrNormal_reg.wfit() (Section A1).Under the Zellner (g)-prior of A3.1, the prior covariance is(\Sigma_ | Limit (pwt\to 0) and coefficient covariance.Under the Zellner decomposition above, (pwt\to 0^{+}) forces(S_{\mathrm{marg}}\to \mathrm{RSS}) (for fixed data and (\mu_{0}), with afinite mismatch quadratic), not only when (\mu_{0}=\hat\beta).Since (b_{n} = b_{0} + \tfrac{1}{2} S_{\mathrm{marg}}), the marginal Gamma ratethen limits to (b_{0} + \tfrac{1}{2}\mathrm{RSS}) whenever (b_{0}) is heldfixed along the path; (E(\tau^{-1}\mid y)=b_{n}/(a_{n}-1)) therefore ties toRSS through (b_{n}) in the same limit.At the same time, ((1-pwt),G^{-1}\to G^{-1}) from A3.2--A3.3.Thus (\mathrm{Cov}(\beta \mid \tau,y) = \tau^{-1}(1-pwt),G^{-1}) tends to(\tau^{-1}G^{-1}) (likelihood-only WLS covariance given (\tau)), and[\mathrm{Cov}(\beta \mid y) | Prior_Setup() dispersion and the Gamma rates (b_{0}), (b_{n}) | Special case: (b_{0} = \frac{1}{2}(n_{\mathrm{prior}}/n_{w}),S_{\mathrm{marg}}) | [\frac | \frac | Growth of (n_ | \frac | dGamma posterior with fixed (\beta): general form and special choices | Hence, for (n_{\mathrm{prior}}+n_w>2),[E(\tau^{-1}\mid y,\beta) | \frac | Choice (\beta=\beta_\star) (posterior mode from dNormal_Gamma) and weak-prior limit | Using the weighted least-squares decomposition:[\mathrm{RSS}_w(\beta) | \mathrm{RSS}_w(\hat\beta)+(\beta-\hat\beta)^\top G(\beta-\hat\beta),\qquadG=X^\top W X,]so[\mathrm{RSS}w(\beta\star) | Under scalar Zellner weighting, (\beta_\star=(1-pwt)\hat\beta+pwt,\mu_0), giving[\mathrm{RSS}w(\beta\star)
Chapter A01: A detailed overview of the glmbayes package2 months ago
Introduction | Loading the package | Accessing package information, general documentation, and demos | Using the lmb and glmb functions and their methods | The lmb and glmb functions | Specifying Priors | Prior Family Functions | Other Prior Related Functions | Method functions | The rlmb and rglmb functions and their summary functions | Calling the rlmb and rglmb functions | Methods for The rlmb, rglmb, and their summary functions | Advanced Topics | Simulation Functions | Normal_ct Functions | Envelope Related Functions | Utility Functions
Chapter A12: Technical Derivations for Priors Returned by `Prior_Setup()2 months ago
Chapter A12: 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)
Chapter 14: Informative priors — centering and differential prior weights2 months ago
General Discussion | The Age of Menarche Data | Variable Transformation and Preliminary Setup | Setting prior point estimates, associated credible intervals, and correlation | Mapping the prior to the link scale | Running the Model | Concluding Discussion
Chapter 16: Large models — GPU acceleration using OpenCL2 months ago
Introduction | What you see when you load glmbayes | Enabling GPU acceleration: three steps | Step 1: Check whether OpenCL is already enabled | Step 2: Ensure 'opencltools' is OpenCL-ready | Step 3: Reinstall glmbayes from source | Windows | Linux / macOS | After the install | Verifying the setup | Running a GPU-accelerated model | Appendix A: AMD GPUs on Linux (ROCm OpenCL)
Chapter 17: Linear mixed-effects models2 months ago
1. Use Case 1: Dispersion and Regression Coefficients (Gaussian) | 2. Use Case 2: Hierarchical (Random Effects) Models | 2.1 Eight Schools with dNormal_Gamma Prior (Gibbs-suitable) | 2.2 Eight Schools with dIndependent_Normal_Gamma Prior | 3. Summary
Chapter 18: Generalized linear mixed-effects models2 months ago
1. Model Structure | 2. Data and Setup | 3. Two-Block Gibbs Sampler | 4. CODA Diagnostics | 5. Out-of-Sample Prediction | 6. Summary
Chapter A11: Implementation Companion for Independent Normal-Gamma3 months ago
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
Chapter A02: Overview of Estimation Procedures3 months ago
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
Chapter A04: Directional Tail Diagnostics for Prior-Posterior Disagreement4 months ago
Directional tail diagnostic (current implementation) | Theoretical interpretation and relation to t and F | Relation to univariate t statistics | Relation to multivariate Wald/F-style tests | Interpretation: what probability is being assessed? | Univariate connection to known Bayesian tail/sign summaries | How magnitude compares to classical tests | Strong-prior regime | Weak-prior (data-dominant) limit | Scalar decomposition (normal-gamma heuristic) | Incorporating the package example (Ex_directional_tail.R) | Illustrative plots from Ex_directional_tail.R | How directional_tail() is called | How summary.glmb() uses directional tail | Minimal reproducible workflow | Supplementary notes: why the Bayesian tail can be smaller | 1.3 Different centering (posterior mean vs. OLS) and prior shrinkage
Chapter A06: Accept–Reject Sampling for Dispersion in Gamma Regression4 months ago
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
Chapter A03: Methods available in glmbayes4 months ago
Chapter A05: Simulation Methods - Likelihood Subgradient Densities4 months ago
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)
Chapter A08: Overview of Envelope Related Functions4 months ago
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
Chapter A09: Parallel Sampling Implementation using RcppParallel4 months ago
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