From c583b929425b2a59a78418315c40c5f100645f4d Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Wed, 13 Aug 2025 16:38:02 -0700 Subject: [PATCH 01/12] Update project description, word list, and ignore settings --- .gitignore | 5 +- DESCRIPTION | 2 +- inst/WORDLIST | 38 ++ .../chapter2_correlated_biomarkers.qmd | 585 ++++++++++++++++++ vignettes/articles/references.bib | 9 + 5 files changed, 636 insertions(+), 3 deletions(-) create mode 100644 vignettes/articles/chapter2_correlated_biomarkers.qmd create mode 100644 vignettes/articles/references.bib diff --git a/.gitignore b/.gitignore index 11c16531..a353fda9 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,9 @@ docs serodynamics.Rcheck/ serodynamics*.tar.gz serodynamics*.tgz - inst/doc docs **/.quarto/ - +docsvignettes/*.pdf +vignettes/*.tex +docs/ diff --git a/DESCRIPTION b/DESCRIPTION index 65983bda..1f030c41 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: serodynamics Title: What the Package Does (One Line, Title Case) -Version: 0.0.0.9038 +Version: 0.0.0.9039 Authors@R: c( person("Peter", "Teunis", , "p.teunis@emory.edu", role = c("aut", "cph"), comment = "Author of the method and original code."), diff --git a/inst/WORDLIST b/inst/WORDLIST index 2ab83c3a..e5e08ce4 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -51,3 +51,41 @@ tibble unstratified vectorized wishdf +Beamer +Biomarkers +Cov +Kronecker +ODEs +Sigma +Teunis +Theta +WAIC +al +alpha +b0 +bayesian +boldsymbol +cd +cdots +dt +dy +et +frac +ge +iJ +le +leq +mathbb +mathcal +mu0 +mu1 +otimes +pre +rightarrow +t1 +tau +th +theta +vec +y0 +y1 diff --git a/vignettes/articles/chapter2_correlated_biomarkers.qmd b/vignettes/articles/chapter2_correlated_biomarkers.qmd new file mode 100644 index 00000000..809683ec --- /dev/null +++ b/vignettes/articles/chapter2_correlated_biomarkers.qmd @@ -0,0 +1,585 @@ +--- +title: "Extending the Hierarchical Model for Antibody Kinetics" +author: "Kwan Ho Lee" +institute: "UC Davis" +date: today +format: + html: default + beamer: + theme: Madrid + slide-level: 2 + keep-tex: true + toc: false + incremental: false +engine: knitr +bibliography: references.bib +env: + PAK_CACHE_DISABLE: "true" +--- + +## Overview + +- Incorporates feedback from Dr. Morrison and Dr.Aiemjoy +- Focus exclusively on [@teunis2016] model +- Clarifies model dynamics: growth, clearance, decay +- Uses updated parameter notation: $\mu_y$, $\mu_b$, $\gamma$, $\alpha$, $\rho$ +- Assumes block-diagonal covariance structure across biomarkers + +------------------------------------------------------------------------ + +## Within-Host ODE System [@teunis2016] + +**Two-phase within-host antibody kinetics:** + +$$ +\frac{dy}{dt} = +\begin{cases} +\mu_y y(t), & t \le t_1 \\ +- \alpha y(t)^\rho, & t > t_1 +\end{cases} +\quad \text{with } +\frac{db}{dt} = \mu_b b(t) - \gamma y(t) +$$ {#eq-ode-system} + +**Initial conditions:** $y(0) = y_0$, $b(0) = b_0$\ +**Key transition:** $t_1$ is the time when $b(t_1) = 0$\ +**Derived quantity:** $y_1 = y(t_1)$ + +------------------------------------------------------------------------ + +## Closed-Form Solutions + +**Antibody concentration** $y(t)$ + +- $t \le t_1$:\ + $$ + y(t) = y_0 e^{\mu_y t} + $$ + +- $t > t_1$:\ + $$ + y(t) = y_1 \left(1 + (\rho - 1)\alpha y_1^{\rho - 1}(t - t_1)\right)^{- \frac{1}{\rho - 1}} + $$ + +**Pathogen load** $b(t)$ + +- $t \le t_1$:\ + $$ + b(t) = b_0 e^{\mu_b t} - \frac{\gamma y_0}{\mu_y - \mu_b} \left(e^{\mu_y t} - e^{\mu_b t} \right) + $$ + +- $t > t_1$:\ + $$ + b(t) = 0 + $$ + +------------------------------------------------------------------------ + +## Time of Peak Response + +**Peak Time** $t_1$ + +$$ +t_1 = \frac{1}{\mu_y - \mu_b} \log \left( 1 + \frac{(\mu_y - \mu_b) b_0}{\gamma y_0} \right) +$${#eq-t1} + +**Peak Antibody Level** $y_1$ + +$$ +y_1 = y_0 e^{\mu_y t_1} +$${#eq-y1} + +------------------------------------------------------------------------ + +## Parameter Summary + +| Symbol | Description | +|----------|-----------------------------------------| +| $\mu_y$ | Antibody production rate (growth phase) | +| $\mu_b$ | Pathogen replication rate | +| $\gamma$ | Clearance rate (by antibodies) | +| $\alpha$ | Antibody decay rate | +| $\rho$ | Shape of antibody decay (power-law) | +| $t_1$ | Time of peak response | +| $y_1$ | Peak antibody concentration | + +: Parameter summary for antibody kinetics model. {#tbl-param-summary} + +**Note:** Only the first 6 are typically estimated. $y_1$ is derived from the ODE solution at $t_1$. + +------------------------------------------------------------------------ + +## Model Comparison: [@teunis2016] vs This Presentation + +| Component | [@teunis2016] | This Presentation | +|--------------------|-----------------------------|-----------------------| +| Pathogen ODE | $\mu_0 b(t) - c y(t)$ | $\mu_b b(t) - \gamma y(t)$ | +| Antibody ODE (pre-$t_1$) | $\mu y(t)$ | $\mu_y y(t)$ | +| Antibody ODE (post-$t_1$) | $- \alpha y(t)^r$ | $- \alpha y(t)^\rho$ | +| Antibody growth type | Pathogen-driven | Self-driven exponential | +| Antibody rate name | $\mu$ | $\mu_y$ | +| $t_1$ formula | Uses $\mu_0$, $\mu$, $b_0$, $c$, $y_0$ | Uses $\mu_b$, $\mu_y$, etc. | + +: Comparison of Teunis (2016) model and this presentation’s model assumptions. {#tbl-model-comparison} + +**Note:** + +- [@teunis2016] uses **linear clearance**: $c y(t)$, not bilinear\ +- Antibody production is **driven by pathogen** $b(t)$\ +- Our model simplifies by assuming self-expanding antibody dynamics + +------------------------------------------------------------------------ + +## Full Parameter Model (7 Parameters) + +**Subject-level parameters:** + +$$ +\theta_{ij} \sim \mathcal{N}(\mu_j,\, \Sigma_j), \quad \theta_{ij} = +\begin{bmatrix} +y_{0,ij} \\ +b_{0,ij} \\ +\mu_{b,ij} \\ +\mu_{y,ij} \\ +\gamma_{ij} \\ +\alpha_{ij} \\ +\rho_{ij} +\end{bmatrix} +$$ + +**Hyperparameters – Means:** + +- $\mu_j$: population-level mean vector for biomarker $j$ +- Prior on $\mu_j$: + +$$ +\mu_j \sim \mathcal{N}(\mu_{\text{hyp},j},\, \Omega_{\text{hyp},j}) +$$ + +------------------------------------------------------------------------ + +## Core Parameters Used for Curve Drawing + +In this presentation, we focus on **5 key parameters** required to draw antibody curves: + +- $y_0$: initial antibody level +- $t_1$: time of peak antibody response +- $y_1$: peak antibody level +- $\alpha$: decay rate +- $\rho$: shape of decay + +Note: $t_1$ and $y_1$ are **derived from the full model** - These 5 are sufficient for prediction and plotting + +------------------------------------------------------------------------ + +## Classifying Model Parameters ([@teunis2016] Structure) + +**Estimated Parameters (7 total):** + +- **Core model parameters (5):** $\mu_b$, $\mu_y$, $\gamma$, $\alpha$, $\rho$ + +- **Initial conditions (2):** $y_0$, $b_0$ + +**Derived Quantity (not estimated):** + +- $y_1$: peak antibody level computed as $y(t_1)$ + +------------------------------------------------------------------------ + +## Time of Pathogen Clearance $t_1$ + +**Definition:** $t_1$ is the time when the pathogen is cleared, i.e., $b(t_1) = 0$ + +**Analytic expression:** + +$$ +t_1 = \frac{1}{\mu_y - \mu_b} \log\left(1 + \frac{(\mu_y - \mu_b)b_0}{\gamma y_0}\right) +$$ + +**Key observations:** $t_1$ depends on $\mu_b$, $\mu_y$, $b_0$, $y_0$, and $y_1 = y(t_1)$ is computed based on this time point + +------------------------------------------------------------------------ + +## Why It's a Seven-Parameter Model + +- Our model estimates **7 parameters**: + - 5 biological parameters: $\mu_b$, $\mu_y$, $\gamma$, $\alpha$, $\rho$ + - 2 initial conditions: $y_0$, $b_0$ +- But we often refer to an 8th quantity: $y_1$ +- So why isn’t $y_1$ a parameter? + +[Answer]{.underline}: $y_1$ is a **computed value**, not directly estimated. + +------------------------------------------------------------------------ + +## Why $y_1$ Is Not Fit Directly + +- $y_1$ is the antibody level at the time the pathogen is cleared: + +$$ +y_1 = y(t_1) \quad \text{where } b(t_1) = 0 +$$ + +- $y_1$ is not an “input” — it is **computed** from: + - $\mu_y$, $y_0$, $b_0$, $\mu_b$, $\gamma$ + - via solution of ODEs to find $t_1$ and compute $y(t_1)$ + +In other words: $y_1$ is a **derived output**, not a fit parameter. + +------------------------------------------------------------------------ + +## How $y_1$ Is Computed + +- $y_1$ is computed by solving the ODE system: + +$$ +\frac{dy}{dt} = \mu_y y(t), \quad \frac{db}{dt} = \mu_b b(t) - \gamma y(t) +$$ + +- Evaluate $y(t)$ at $t = t_1$ using ODE solution: + +$$ +y_1 = y(t_1; \mu_y, y_0, b_0, \mu_b, \gamma) +$$ + +------------------------------------------------------------------------ + +## Recap: What We Estimate + +**Seven model parameters (**[7-parameter model for full dynamics]{.underline}**):** + +- $\mu_b$, $\mu_y$, $\gamma$, $\alpha$, $\rho$ (biological process) +- $y_0$, $b_0$ (initial state) + +**Derived quantity:** + +- $y_1 = y(t_1)$ — not directly estimated, computed + +**5-parameter subset for curve visualization:** + +- $y_0$, $y_1$, $t_1$, $\alpha$, $\rho$ + +------------------------------------------------------------------------ + +## Hierarchical Bayesian Structure + +**Individual parameters:** + +$$ +\theta_{ij} = +\begin{bmatrix} + y_{0,ij} \\ + b_{0,ij} \\ + \mu_{b,ij} \\ + \mu_{y,ij} \\ + \gamma_{ij} \\ + \alpha_{ij} \\ + \rho_{ij} +\end{bmatrix} +\sim \mathcal{N}(\mu_j,\, \Sigma_j) +$$ + +**Hyperparameters:** + +- $\mu_j$: population-level means (per biomarker $j$) +- $\Sigma_j$: $7 \times 7$ covariance matrix over parameters + +------------------------------------------------------------------------ + +## Subject-Level Parameters: $\theta_{ij}$ + +$$ +\theta_{ij} \sim \mathcal{N}(\mu_j,\, \Sigma_j), \quad \theta_{ij} \in \mathbb{R}^7 +$$ + +**Where:** + +$$ +\boldsymbol{\theta}_{ij} = +\begin{bmatrix} +y_{0,ij} \\ +b_{0,ij} \\ +\mu_{b,ij} \\ +\mu_{y,ij} \\ +\gamma_{ij} \\ +\alpha_{ij} \\ +\rho_{ij} +\end{bmatrix}, +\quad \Sigma_j \in \mathbb{R}^{7 \times 7} +$$ + +Each subject $i$ has a unique 7-parameter vector per biomarker $j$, capturing individual-level variation in antibody dynamics. + +------------------------------------------------------------------------ + +## Hyperparameters: Priors on Population Means + +**Population-level means:** + +$$ +\boldsymbol{\mu}_j \sim \mathcal{N}(\boldsymbol{\mu}_{\mathrm{hyp},j}, \Omega_{\mathrm{hyp},j}) +$$ + +**Interpretation:** + +- $\boldsymbol{\mu}_j$: average parameter vector for biomarker $j$ +- $\boldsymbol{\mu}_{\mathrm{hyp},j}$: prior guess (e.g., vector of zeros) +- $\Omega_{\mathrm{hyp},j}$: covariance matrix encoding uncertainty + +**Example:** + +$$ +\boldsymbol{\mu}_{\mathrm{hyp},j} = 0, \quad \Omega_{\mathrm{hyp},j} = 100 \cdot I_7 +$$ + +------------------------------------------------------------------------ + +## Hyperparameters: Priors on Covariance + +**Covariance across parameters:** + +$$ +\Sigma_j^{-1} \sim \mathcal{W}(\Omega_j, \nu_j) +$$ + +- $\Sigma_j$: variability/covariance in subject-level parameters +- $\Omega_j$: prior scale matrix +- $\nu_j$: degrees of freedom + +**Example:** + +$$ +\Omega_j = 0.1 \cdot I_7, \quad \nu_j = 8 +$$ + +------------------------------------------------------------------------ + +## Measurement Error and Precision Priors + +**Observed antibody levels:** + +$$ +\log(y_{\text{obs},ij}) \sim \mathcal{N}(\log(y_{\text{pred},ij}), \tau_j^{-1}) +$$ + +**Precision prior:** + +$$ +\tau_j \sim \text{Gamma}(a_j, b_j) +$$ + +- $\tau_j$: shared measurement precision for biomarker $j$ +- Gamma prior allows flexible noise modeling + +------------------------------------------------------------------------ + +## Matrix Algebra Computation + +Let $K = 7$ (parameters), $J$ biomarkers. Then: + +$$ +\Theta_i = +\begin{bmatrix} +\theta_{i1} & \theta_{i2} & \cdots & \theta_{iJ} +\end{bmatrix} +\in \mathbb{R}^{K \times J} +$$ + +Assume: + +$$ +\text{vec}(\Theta_i) \sim \mathcal{N}(\text{vec}(M), \Sigma_K \otimes I_J) +$$ + +------------------------------------------------------------------------ + +## Matrix Algebra – Simplified Structure + +Setup: $\Theta_i \in \mathbb{R}^{7 \times J}$ + +Model: + +$$ +\text{vec}(\Theta_i) \sim \mathcal{N}(\text{vec}(M), \Sigma_K \otimes I_J) +$$ + +- $\Sigma_K$: 7×7 covariance (same across biomarkers) +- $I_J$: biomarkers assumed uncorrelated +- Block-diagonal covariance + +------------------------------------------------------------------------ + +## Understanding $\text{vec}(\Theta_i)$ + +Each $\theta_{ij} \in \mathbb{R}^7$: + +$$ +\theta_{ij} = +\begin{bmatrix} +y_0 \\ +b_0 \\ +\mu_0 \\ +\mu_1 \\ +c \\ +\alpha \\ +r +\end{bmatrix} +$$ + +Flattening: + +$$ +\text{vec}(\Theta_i) \in \mathbb{R}^{7J \times 1} +$$ + +------------------------------------------------------------------------ + +## Understanding $\text{vec}(M)$ + +Let $M = [\mu_1\, \mu_2\, \cdots\, \mu_J] \in \mathbb{R}^{7 \times J}$ + +Example for $J=3$: + +$$ +M = +\begin{bmatrix} +\mu_{1,1} & \mu_{1,2} & \mu_{1,3} \\ +\mu_{2,1} & \mu_{2,2} & \mu_{2,3} \\ +\mu_{3,1} & \mu_{3,2} & \mu_{3,3} \\ +\mu_{4,1} & \mu_{4,2} & \mu_{4,3} \\ +\mu_{5,1} & \mu_{5,2} & \mu_{5,3} \\ +\mu_{6,1} & \mu_{6,2} & \mu_{6,3} \\ +\mu_{7,1} & \mu_{7,2} & \mu_{7,3} +\end{bmatrix} +$$ + +------------------------------------------------------------------------ + +## Covariance Structure: $\Sigma_K \otimes I_J$ + +$$ +\text{Cov}(\text{vec}(\Theta_i)) = \Sigma_K \otimes I_J +$$ + +- $\Sigma_K$: parameter covariance matrix +- $I_J$: biomarker-wise independence +- Kronecker product yields block-diagonal matrix + +------------------------------------------------------------------------ + +## Example: Kronecker Product with $K=2$, $J=3$ + +Let: + +$$ +\Sigma_K = +\begin{bmatrix} +\sigma_{11} & \sigma_{12} \\ +\sigma_{21} & \sigma_{22} +\end{bmatrix},\quad +I_3 = +\begin{bmatrix} +1 & 0 & 0 \\ +0 & 1 & 0 \\ +0 & 0 & 1 +\end{bmatrix} +$$ + +Then: + +$$ +\Sigma_K \otimes I_3 \in \mathbb{R}^{6 \times 6} +$$ + +------------------------------------------------------------------------ + +## Expanded Matrix: $\Sigma_K \otimes I_3$ + +$$ +\Sigma_K \otimes I_3 = +\begin{bmatrix} +\sigma_{11} & 0 & 0 & \sigma_{12} & 0 & 0 \\ +0 & \sigma_{11} & 0 & 0 & \sigma_{12} & 0 \\ +0 & 0 & \sigma_{11} & 0 & 0 & \sigma_{12} \\ +\sigma_{21} & 0 & 0 & \sigma_{22} & 0 & 0 \\ +0 & \sigma_{21} & 0 & 0 & \sigma_{22} & 0 \\ +0 & 0 & \sigma_{21} & 0 & 0 & \sigma_{22} +\end{bmatrix} +$$ + +------------------------------------------------------------------------ + +## Next Steps: Modeling Correlation Across Biomarkers + +Current Limitation: + +- Biomarkers assumed independent: $I_J$ + +Planned Extension: + +- Use full covariance $\Sigma_J$: + +$$ +\text{Cov}(\text{vec}(\Theta_i)) = \Sigma_K \otimes \Sigma_J +$$ + +------------------------------------------------------------------------ + +## Extending to Correlated Biomarkers + +Assume $K=3$, $J=3$ + +Define: + +$$ +\Sigma_K = +\begin{bmatrix} +\sigma_{11} & \sigma_{12} & \sigma_{13} \\ +\sigma_{21} & \sigma_{22} & \sigma_{23} \\ +\sigma_{31} & \sigma_{32} & \sigma_{33} +\end{bmatrix},\quad +\Sigma_J = +\begin{bmatrix} +\tau_{11} & \tau_{12} & \tau_{13} \\ +\tau_{21} & \tau_{22} & \tau_{23} \\ +\tau_{31} & \tau_{32} & \tau_{33} +\end{bmatrix} +$$ + +------------------------------------------------------------------------ + +## Kronecker Product Structure: $\Sigma_K \otimes \Sigma_J$ + +$$ +\Sigma_K \otimes \Sigma_J = +\begin{bmatrix} +\sigma_{11}\Sigma_J & \sigma_{12}\Sigma_J & \sigma_{13}\Sigma_J \\ +\sigma_{21}\Sigma_J & \sigma_{22}\Sigma_J & \sigma_{23}\Sigma_J \\ +\sigma_{31}\Sigma_J & \sigma_{32}\Sigma_J & \sigma_{33}\Sigma_J +\end{bmatrix} +$$ + +Now biomarkers and parameters can be correlated. + +------------------------------------------------------------------------ + +## Expanded Form: $\Sigma_K \otimes \Sigma_J$ (3x3) + +The $9 \times 9$ matrix contains all combinations $\sigma_{ab}\tau_{cd}$ + +Not block-diagonal — includes cross-biomarker correlation + +------------------------------------------------------------------------ + +## Practical To-Do List (for Chapter 2) + +**Model Implementation:** + +- Define full $\Sigma_J$ and prior: $\Sigma_J^{-1} \sim \mathcal{W}(\Psi, \nu)$\ +- Implement $\Sigma_K \otimes \Sigma_J$ in JAGS + +**Simulation + Validation:** + +- Simulate individuals with correlated biomarkers\ +- Fit both block-diagonal and full-covariance models\ +- Compare fit: DIC, WAIC, predictive checks \ No newline at end of file diff --git a/vignettes/articles/references.bib b/vignettes/articles/references.bib new file mode 100644 index 00000000..8ba813b0 --- /dev/null +++ b/vignettes/articles/references.bib @@ -0,0 +1,9 @@ +@article{teunis2016, + author = {Teunis, Peter F. M. and van Eijkeren, J. C. H.}, + title = {Linking the seroresponse to infection to within-host heterogeneity in antibody production}, + journal = {Epidemics}, + volume = {16}, + pages = {33--39}, + year = {2016}, + doi = {10.1016/j.epidem.2016.04.001} +} \ No newline at end of file From 19442ee31f1ae1e99919100435cd7ddbef3f9425 Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Thu, 14 Aug 2025 15:36:49 -0700 Subject: [PATCH 02/12] # Update NEWS.md and WORDLIST for PR #129 - Added entry to NEWS.md for Chapter 2 documentation on correlated biomarker model - Added 'mathrm' to WORDLIST to resolve spellcheck error --- NEWS.md | 1 + inst/WORDLIST | 1 + 2 files changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 4e55480d..8f6f4dfc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ ## New features +* Added Chapter 2 documentation on correlated biomarker model (#129) * Including fitted and residual values as data frame in run_mod output. (#101) * Added `plot_predicted_curve()` with support for faceting by multiple IDs (#68) * Replacing old data object with new run_mod output (#102) diff --git a/inst/WORDLIST b/inst/WORDLIST index e5e08ce4..0e1050cb 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -89,3 +89,4 @@ theta vec y0 y1 +mathrm From 9f757305a2b24c16abfc11142c1540813b02ff9a Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Thu, 14 Aug 2025 15:40:38 -0700 Subject: [PATCH 03/12] # Version update --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1f030c41..d2f1f164 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: serodynamics Title: What the Package Does (One Line, Title Case) -Version: 0.0.0.9039 +Version: 0.0.0.9040 Authors@R: c( person("Peter", "Teunis", , "p.teunis@emory.edu", role = c("aut", "cph"), comment = "Author of the method and original code."), From 7d533deb3d14d228ec5ec192fff6e4e99b43cce4 Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Thu, 14 Aug 2025 17:06:42 -0700 Subject: [PATCH 04/12] # Update version again and some edits --- DESCRIPTION | 2 +- .../chapter2_correlated_biomarkers.qmd | 74 +++++++++++++------ 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d2f1f164..742a6116 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: serodynamics Title: What the Package Does (One Line, Title Case) -Version: 0.0.0.9040 +Version: 0.0.0.9041 Authors@R: c( person("Peter", "Teunis", , "p.teunis@emory.edu", role = c("aut", "cph"), comment = "Author of the method and original code."), diff --git a/vignettes/articles/chapter2_correlated_biomarkers.qmd b/vignettes/articles/chapter2_correlated_biomarkers.qmd index 809683ec..b3bfb8f7 100644 --- a/vignettes/articles/chapter2_correlated_biomarkers.qmd +++ b/vignettes/articles/chapter2_correlated_biomarkers.qmd @@ -27,6 +27,56 @@ env: ------------------------------------------------------------------------ +## Observation Model (Data Level) + +Observed (log-transformed) antibody levels: + +$$ +\log(y_{\text{obs},ij}) \sim \mathcal{N}(\mu_{\log y,ij}, \tau_j^{-1}) +$$ {#eq-1} + +Where: + +- $y_{\text{obs},ij}$: Observed antibody level for subject $i$ and biomarker $j$ +- $\mu_{\log y,ij}$ is the **expected log antibody level**, computed from the two-phase model using subject-level parameters $\theta_{ij}$. +- $\theta_{ij}$: Subject-level latent parameters (e.g., $y_0, \alpha, \rho$) used to define the predicted antibody curve +- $\tau_j$: Measurement precision (inverse of variance) specific to biomarker $j$ + +Measurement precision prior: + +$$ +\tau_j \sim \text{Gamma}(a_j, b_j) +$$ {#eq-2} + +Where: + +- $\tau_j$: Precision (inverse of variance) of the measurement noise for biomarker $j$ +- $(a_j, b_j)$: Shape and rate hyperparameters of the Gamma prior for precision, which control its expected value and variability + +The expression above corresponds to line 75 of `model.jags`: + +``` {.r include="../../inst/extdata/model.jags" start-line="75" end-line="75" code-line-numbers="true"} +prec.logy[cur_antigen_iso] ~ dgamma(prec.logy.hyp[cur_antigen_iso,1], prec.logy.hyp[cur_antigen_iso,2]) +``` + +------------------------------------------------------------------------ + +## Parameter Summary + +| Symbol | Description | +|----------|-----------------------------------------| +| $\mu_y$ | Antibody production rate (growth phase) | +| $\mu_b$ | Pathogen replication rate | +| $\gamma$ | Clearance rate (by antibodies) | +| $\alpha$ | Antibody decay rate | +| $\rho$ | Shape of antibody decay (power-law) | +| $t_1$ | Time of peak response | +| $y_1$ | Peak antibody concentration | + +: Parameter summary for antibody kinetics model. {#tbl-param-summary} + +**Note:** Only the first 6 are typically estimated. $y_1$ is derived from the ODE solution at $t_1$. + ## Within-Host ODE System [@teunis2016] **Two-phase within-host antibody kinetics:** @@ -91,27 +141,9 @@ $${#eq-y1} ------------------------------------------------------------------------ -## Parameter Summary - -| Symbol | Description | -|----------|-----------------------------------------| -| $\mu_y$ | Antibody production rate (growth phase) | -| $\mu_b$ | Pathogen replication rate | -| $\gamma$ | Clearance rate (by antibodies) | -| $\alpha$ | Antibody decay rate | -| $\rho$ | Shape of antibody decay (power-law) | -| $t_1$ | Time of peak response | -| $y_1$ | Peak antibody concentration | - -: Parameter summary for antibody kinetics model. {#tbl-param-summary} - -**Note:** Only the first 6 are typically estimated. $y_1$ is derived from the ODE solution at $t_1$. - ------------------------------------------------------------------------- - -## Model Comparison: [@teunis2016] vs This Presentation +## Model Comparison: [@teunis2016] vs serodynamics -| Component | [@teunis2016] | This Presentation | +| Component | [@teunis2016] | serodynamics | |--------------------|-----------------------------|-----------------------| | Pathogen ODE | $\mu_0 b(t) - c y(t)$ | $\mu_b b(t) - \gamma y(t)$ | | Antibody ODE (pre-$t_1$) | $\mu y(t)$ | $\mu_y y(t)$ | @@ -120,7 +152,7 @@ $${#eq-y1} | Antibody rate name | $\mu$ | $\mu_y$ | | $t_1$ formula | Uses $\mu_0$, $\mu$, $b_0$, $c$, $y_0$ | Uses $\mu_b$, $\mu_y$, etc. | -: Comparison of Teunis (2016) model and this presentation’s model assumptions. {#tbl-model-comparison} +: Comparison of Teunis (2016) model and serodynamic’s model assumptions. {#tbl-model-comparison} **Note:** From f3669559ea326e67e4151e5aca07b648a9c3d5bb Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Thu, 14 Aug 2025 17:48:22 -0700 Subject: [PATCH 05/12] # Revision 1 --- .../chapter2_correlated_biomarkers.qmd | 143 +++++++++--------- 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/vignettes/articles/chapter2_correlated_biomarkers.qmd b/vignettes/articles/chapter2_correlated_biomarkers.qmd index b3bfb8f7..025de2d4 100644 --- a/vignettes/articles/chapter2_correlated_biomarkers.qmd +++ b/vignettes/articles/chapter2_correlated_biomarkers.qmd @@ -131,13 +131,13 @@ $$ {#eq-ode-system} $$ t_1 = \frac{1}{\mu_y - \mu_b} \log \left( 1 + \frac{(\mu_y - \mu_b) b_0}{\gamma y_0} \right) -$${#eq-t1} +$$ {#eq-t1} **Peak Antibody Level** $y_1$ $$ y_1 = y_0 e^{\mu_y t_1} -$${#eq-y1} +$$ {#eq-y1} ------------------------------------------------------------------------ @@ -190,7 +190,17 @@ $$ ------------------------------------------------------------------------ -## Core Parameters Used for Curve Drawing +## From Full 7 Parameters to 5 Latent Parameters + +- Although the model estimates 7 parameters, for modeling antibody kinetics $y(t)$, we focus on **5-parameter subset**: + +$$y_0,\ \ t_1 (\text{derived}),\ \ y_1 (\text{derived}),\ \ \alpha,\ \ \rho$$ + +- These 5 parameters are **log-transformed** into the latent parameters $\theta\_{ij}$ used for modeling. + +------------------------------------------------------------------------ + +## 5 Core Parameters Used for Curve Drawing In this presentation, we focus on **5 key parameters** required to draw antibody curves: @@ -218,29 +228,26 @@ Note: $t_1$ and $y_1$ are **derived from the full model** - These 5 are sufficie ------------------------------------------------------------------------ -## Time of Pathogen Clearance $t_1$ - -**Definition:** $t_1$ is the time when the pathogen is cleared, i.e., $b(t_1) = 0$ +## Subject-Level Parameters (Latent Version = serodynamics) -**Analytic expression:** +Each subject $i$ and biomarker $j$ has latent parameters: $$ -t_1 = \frac{1}{\mu_y - \mu_b} \log\left(1 + \frac{(\mu_y - \mu_b)b_0}{\gamma y_0}\right) -$$ - -**Key observations:** $t_1$ depends on $\mu_b$, $\mu_y$, $b_0$, $y_0$, and $y_1 = y(t_1)$ is computed based on this time point - ------------------------------------------------------------------------- - -## Why It's a Seven-Parameter Model +\theta_{ij} = +\begin{bmatrix} +\log(y_{0,ij}) \\ +\log(y_{1,ij} - y_{0,ij}) \\ +\log(t_{1,ij}) \\ +\log(\alpha_{ij}) \\ +\log(\rho_{ij} - 1) +\end{bmatrix} +$$ {#eq-10} -- Our model estimates **7 parameters**: - - 5 biological parameters: $\mu_b$, $\mu_y$, $\gamma$, $\alpha$, $\rho$ - - 2 initial conditions: $y_0$, $b_0$ -- But we often refer to an 8th quantity: $y_1$ -- So why isn’t $y_1$ a parameter? +Distribution: -[Answer]{.underline}: $y_1$ is a **computed value**, not directly estimated. +$$ +\theta_{ij} \sim \mathcal{N}(\mu_j, \Sigma_j) +$$ ------------------------------------------------------------------------ @@ -293,20 +300,18 @@ $$ ------------------------------------------------------------------------ -## Hierarchical Bayesian Structure +## Hierarchical Bayesian Structure (serodynamics) **Individual parameters:** $$ \theta_{ij} = \begin{bmatrix} - y_{0,ij} \\ - b_{0,ij} \\ - \mu_{b,ij} \\ - \mu_{y,ij} \\ - \gamma_{ij} \\ - \alpha_{ij} \\ - \rho_{ij} +\log(y_{0,ij}) \\ +\log(y_{1,ij} - y_{0,ij}) \\ +\log(t_{1,ij}) \\ +\log(\alpha_{ij}) \\ +\log(\rho_{ij} - 1) \end{bmatrix} \sim \mathcal{N}(\mu_j,\, \Sigma_j) $$ @@ -314,14 +319,14 @@ $$ **Hyperparameters:** - $\mu_j$: population-level means (per biomarker $j$) -- $\Sigma_j$: $7 \times 7$ covariance matrix over parameters +- $\Sigma_j$: $5 \times 5$ covariance matrix over parameters ------------------------------------------------------------------------ ## Subject-Level Parameters: $\theta_{ij}$ $$ -\theta_{ij} \sim \mathcal{N}(\mu_j,\, \Sigma_j), \quad \theta_{ij} \in \mathbb{R}^7 +\theta_{ij} \sim \mathcal{N}(\mu_j,\, \Sigma_j), \quad \theta_{ij} \in \mathbb{R}^5 $$ **Where:** @@ -329,18 +334,16 @@ $$ $$ \boldsymbol{\theta}_{ij} = \begin{bmatrix} -y_{0,ij} \\ -b_{0,ij} \\ -\mu_{b,ij} \\ -\mu_{y,ij} \\ -\gamma_{ij} \\ -\alpha_{ij} \\ -\rho_{ij} +\log(y_{0,ij}) \\ +\log(y_{1,ij} - y_{0,ij}) \\ +\log(t_{1,ij}) \\ +\log(\alpha_{ij}) \\ +\log(\rho_{ij} - 1) \end{bmatrix}, -\quad \Sigma_j \in \mathbb{R}^{7 \times 7} +\quad \Sigma_j \in \mathbb{R}^{5 \times 5} $$ -Each subject $i$ has a unique 7-parameter vector per biomarker $j$, capturing individual-level variation in antibody dynamics. +Each subject $i$ has a unique 5-parameter vector per biomarker $j$, capturing individual-level variation in antibody dynamics. ------------------------------------------------------------------------ @@ -361,7 +364,7 @@ $$ **Example:** $$ -\boldsymbol{\mu}_{\mathrm{hyp},j} = 0, \quad \Omega_{\mathrm{hyp},j} = 100 \cdot I_7 +\boldsymbol{\mu}_{\mathrm{hyp},j} = 0, \quad \Omega_{\mathrm{hyp},j} = 100 \cdot I_5 $$ ------------------------------------------------------------------------ @@ -381,7 +384,7 @@ $$ **Example:** $$ -\Omega_j = 0.1 \cdot I_7, \quad \nu_j = 8 +\Omega_j = 0.1 \cdot I_5, \quad \nu_j = 6 $$ ------------------------------------------------------------------------ @@ -407,36 +410,36 @@ $$ ## Matrix Algebra Computation -Let $K = 7$ (parameters), $J$ biomarkers. Then: +Let $P = 5$ (parameters), $J$ biomarkers. Then: $$ \Theta_i = \begin{bmatrix} -\theta_{i1} & \theta_{i2} & \cdots & \theta_{iJ} +\theta_{i1} & \theta_{i2} & \cdots & \theta_{iB} \end{bmatrix} -\in \mathbb{R}^{K \times J} +\in \mathbb{R}^{P \times B} $$ Assume: $$ -\text{vec}(\Theta_i) \sim \mathcal{N}(\text{vec}(M), \Sigma_K \otimes I_J) +\text{vec}(\Theta_i) \sim \mathcal{N}(\text{vec}(M), \Sigma_P \otimes I_B) $$ ------------------------------------------------------------------------ ## Matrix Algebra – Simplified Structure -Setup: $\Theta_i \in \mathbb{R}^{7 \times J}$ +Setup: $\Theta_i \in \mathbb{R}^{P \times B}$ Model: $$ -\text{vec}(\Theta_i) \sim \mathcal{N}(\text{vec}(M), \Sigma_K \otimes I_J) +\text{vec}(\Theta_i) \sim \mathcal{N}(\text{vec}(M), \Sigma_P \otimes I_B) $$ -- $\Sigma_K$: 7×7 covariance (same across biomarkers) -- $I_J$: biomarkers assumed uncorrelated +- $\Sigma_P$: 5×5 covariance (same across biomarkers) +- $I_B$: biomarkers assumed uncorrelated - Block-diagonal covariance ------------------------------------------------------------------------ @@ -461,16 +464,16 @@ $$ Flattening: $$ -\text{vec}(\Theta_i) \in \mathbb{R}^{7J \times 1} +\text{vec}(\Theta_i) \in \mathbb{R}^{5B \times 1} $$ ------------------------------------------------------------------------ ## Understanding $\text{vec}(M)$ -Let $M = [\mu_1\, \mu_2\, \cdots\, \mu_J] \in \mathbb{R}^{7 \times J}$ +Let $M = [\mu_1\, \mu_2\, \cdots\, \mu_B] \in \mathbb{R}^{5 \times B}$ -Example for $J=3$: +Example for $B=3$: $$ M = @@ -479,37 +482,35 @@ M = \mu_{2,1} & \mu_{2,2} & \mu_{2,3} \\ \mu_{3,1} & \mu_{3,2} & \mu_{3,3} \\ \mu_{4,1} & \mu_{4,2} & \mu_{4,3} \\ -\mu_{5,1} & \mu_{5,2} & \mu_{5,3} \\ -\mu_{6,1} & \mu_{6,2} & \mu_{6,3} \\ -\mu_{7,1} & \mu_{7,2} & \mu_{7,3} +\mu_{5,1} & \mu_{5,2} & \mu_{5,3} \end{bmatrix} $$ ------------------------------------------------------------------------ -## Covariance Structure: $\Sigma_K \otimes I_J$ +## Covariance Structure: $\Sigma_P \otimes I_B$ $$ -\text{Cov}(\text{vec}(\Theta_i)) = \Sigma_K \otimes I_J +\text{Cov}(\text{vec}(\Theta_i)) = \Sigma_P \otimes I_B $$ -- $\Sigma_K$: parameter covariance matrix -- $I_J$: biomarker-wise independence +- $\Sigma_P$: parameter covariance matrix +- $I_B$: biomarker-wise independence - Kronecker product yields block-diagonal matrix ------------------------------------------------------------------------ -## Example: Kronecker Product with $K=2$, $J=3$ +## Example: Kronecker Product with $P=2$, $B=3$ Let: $$ -\Sigma_K = +\Sigma_P = \begin{bmatrix} \sigma_{11} & \sigma_{12} \\ \sigma_{21} & \sigma_{22} \end{bmatrix},\quad -I_3 = +I_B = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ @@ -520,15 +521,15 @@ $$ Then: $$ -\Sigma_K \otimes I_3 \in \mathbb{R}^{6 \times 6} +\Sigma_P \otimes I_B \in \mathbb{R}^{6 \times 6} $$ ------------------------------------------------------------------------ -## Expanded Matrix: $\Sigma_K \otimes I_3$ +## Expanded Matrix: $\Sigma_P \otimes I_B$ $$ -\Sigma_K \otimes I_3 = +\Sigma_P \otimes I_B = \begin{bmatrix} \sigma_{11} & 0 & 0 & \sigma_{12} & 0 & 0 \\ 0 & \sigma_{11} & 0 & 0 & \sigma_{12} & 0 \\ @@ -545,21 +546,21 @@ $$ Current Limitation: -- Biomarkers assumed independent: $I_J$ +- Biomarkers assumed independent: $I_B$ Planned Extension: -- Use full covariance $\Sigma_J$: +- Use full covariance $\Sigma_B$: $$ -\text{Cov}(\text{vec}(\Theta_i)) = \Sigma_K \otimes \Sigma_J +\text{Cov}(\text{vec}(\Theta_i)) = \Sigma_P \otimes \Sigma_B $$ ------------------------------------------------------------------------ ## Extending to Correlated Biomarkers -Assume $K=3$, $J=3$ +Assume $P=3$, $B=3$ Define: @@ -614,4 +615,4 @@ Not block-diagonal — includes cross-biomarker correlation - Simulate individuals with correlated biomarkers\ - Fit both block-diagonal and full-covariance models\ -- Compare fit: DIC, WAIC, predictive checks \ No newline at end of file +- Compare fit: DIC, WAIC, predictive checks From 4802cfa59b47739f1ee270e1ce24de75df693d7e Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Mon, 18 Aug 2025 09:11:56 -0700 Subject: [PATCH 06/12] # Minor revision --- vignettes/articles/chapter2_correlated_biomarkers.qmd | 6 ------ 1 file changed, 6 deletions(-) diff --git a/vignettes/articles/chapter2_correlated_biomarkers.qmd b/vignettes/articles/chapter2_correlated_biomarkers.qmd index 025de2d4..08559319 100644 --- a/vignettes/articles/chapter2_correlated_biomarkers.qmd +++ b/vignettes/articles/chapter2_correlated_biomarkers.qmd @@ -53,12 +53,6 @@ Where: - $\tau_j$: Precision (inverse of variance) of the measurement noise for biomarker $j$ - $(a_j, b_j)$: Shape and rate hyperparameters of the Gamma prior for precision, which control its expected value and variability -The expression above corresponds to line 75 of `model.jags`: - -``` {.r include="../../inst/extdata/model.jags" start-line="75" end-line="75" code-line-numbers="true"} -prec.logy[cur_antigen_iso] ~ dgamma(prec.logy.hyp[cur_antigen_iso,1], prec.logy.hyp[cur_antigen_iso,2]) -``` - ------------------------------------------------------------------------ ## Parameter Summary From ab16eb60f61b5d86ba696cc281e61533c0b88e84 Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Mon, 18 Aug 2025 09:44:01 -0700 Subject: [PATCH 07/12] # Minor revision (notation1) --- .../articles/chapter2_correlated_biomarkers.qmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vignettes/articles/chapter2_correlated_biomarkers.qmd b/vignettes/articles/chapter2_correlated_biomarkers.qmd index 08559319..bf371037 100644 --- a/vignettes/articles/chapter2_correlated_biomarkers.qmd +++ b/vignettes/articles/chapter2_correlated_biomarkers.qmd @@ -161,7 +161,7 @@ $$ {#eq-y1} **Subject-level parameters:** $$ -\theta_{ij} \sim \mathcal{N}(\mu_j,\, \Sigma_j), \quad \theta_{ij} = +\theta_{ij} \sim \mathcal{N}(\mu_j,\, \Sigma_{P,j}), \quad \theta_{ij} = \begin{bmatrix} y_{0,ij} \\ b_{0,ij} \\ @@ -240,7 +240,7 @@ $$ {#eq-10} Distribution: $$ -\theta_{ij} \sim \mathcal{N}(\mu_j, \Sigma_j) +\theta_{ij} \sim \mathcal{N}(\mu_j, \Sigma_{P,j}) $$ ------------------------------------------------------------------------ @@ -307,7 +307,7 @@ $$ \log(\alpha_{ij}) \\ \log(\rho_{ij} - 1) \end{bmatrix} -\sim \mathcal{N}(\mu_j,\, \Sigma_j) +\sim \mathcal{N}(\mu_j,\, \Sigma_{P,j}) $$ **Hyperparameters:** @@ -320,7 +320,7 @@ $$ ## Subject-Level Parameters: $\theta_{ij}$ $$ -\theta_{ij} \sim \mathcal{N}(\mu_j,\, \Sigma_j), \quad \theta_{ij} \in \mathbb{R}^5 +\theta_{ij} \sim \mathcal{N}(\mu_j,\, \Sigma_{P,j}), \quad \theta_{ij} \in \mathbb{R}^5 $$ **Where:** @@ -334,7 +334,7 @@ $$ \log(\alpha_{ij}) \\ \log(\rho_{ij} - 1) \end{bmatrix}, -\quad \Sigma_j \in \mathbb{R}^{5 \times 5} +\quad \Sigma_{P,j} \in \mathbb{R}^{5 \times 5} $$ Each subject $i$ has a unique 5-parameter vector per biomarker $j$, capturing individual-level variation in antibody dynamics. @@ -368,7 +368,7 @@ $$ **Covariance across parameters:** $$ -\Sigma_j^{-1} \sim \mathcal{W}(\Omega_j, \nu_j) +\Sigma_{P,j}^{-1} \sim \mathcal{W}(\Omega_j, \nu_j) $$ - $\Sigma_j$: variability/covariance in subject-level parameters From 6ee0b566ff8f9907c9b755927e5eaea8a347baf0 Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Mon, 18 Aug 2025 11:04:50 -0700 Subject: [PATCH 08/12] # Revision (notation) --- .../chapter2_correlated_biomarkers.qmd | 157 +++++++++++------- 1 file changed, 93 insertions(+), 64 deletions(-) diff --git a/vignettes/articles/chapter2_correlated_biomarkers.qmd b/vignettes/articles/chapter2_correlated_biomarkers.qmd index bf371037..2dffb57d 100644 --- a/vignettes/articles/chapter2_correlated_biomarkers.qmd +++ b/vignettes/articles/chapter2_correlated_biomarkers.qmd @@ -1,5 +1,5 @@ --- -title: "Extending the Hierarchical Model for Antibody Kinetics" +title: "Modeling Correlation in Antibody Kinetics: A Hierarchical Bayesian Approach" author: "Kwan Ho Lee" institute: "UC Davis" date: today @@ -19,11 +19,12 @@ env: ## Overview -- Incorporates feedback from Dr. Morrison and Dr.Aiemjoy -- Focus exclusively on [@teunis2016] model -- Clarifies model dynamics: growth, clearance, decay -- Uses updated parameter notation: $\mu_y$, $\mu_b$, $\gamma$, $\alpha$, $\rho$ -- Assumes block-diagonal covariance structure across biomarkers +- Incorporates feedback from Dr. Morrison and Dr. Aiemjoy\ +- Builds on [@teunis2016] framework for antibody kinetics\ +- Focus on covariance structure: parameter covariance within each biomarker ($\Sigma_{P,j}$, 5×5 per biomarker) and biomarker covariance across $j$ ($\Sigma_B$, across biomarkers)\ +- Uses updated parameterization: $\log(y_0)$, $\log(y_1 - y_0)$, $\log(t_1)$, $\log(\alpha)$, $\log(\rho-1)$\ +- Current stage: block-diagonal covariance (independent biomarkers)\ +- Planned extension: full $\Sigma_B$ to capture correlation between biomarkers ------------------------------------------------------------------------ @@ -138,7 +139,7 @@ $$ {#eq-y1} ## Model Comparison: [@teunis2016] vs serodynamics | Component | [@teunis2016] | serodynamics | -|--------------------|-----------------------------|-----------------------| +|------------------------|------------------------|------------------------| | Pathogen ODE | $\mu_0 b(t) - c y(t)$ | $\mu_b b(t) - \gamma y(t)$ | | Antibody ODE (pre-$t_1$) | $\mu y(t)$ | $\mu_y y(t)$ | | Antibody ODE (post-$t_1$) | $- \alpha y(t)^r$ | $- \alpha y(t)^\rho$ | @@ -171,12 +172,15 @@ b_{0,ij} \\ \alpha_{ij} \\ \rho_{ij} \end{bmatrix} -$$ +$$ **Where:** -**Hyperparameters – Means:** +- $\theta_{ij}$: parameter vector for subject $i$, biomarker $j$\ +- $\mu_j$: population-level mean vector for biomarker $j$\ +- $\Sigma_{P,j} \in \mathbb{R}^{7 \times 7}$: covariance matrix **across parameters** for biomarker $j$ + - Subscript $P$: denotes that this is covariance over the **P parameters**\ + - Subscript $j$: indicates the biomarker index -- $\mu_j$: population-level mean vector for biomarker $j$ -- Prior on $\mu_j$: +**Hyperparameters – Means:** $$ \mu_j \sim \mathcal{N}(\mu_{\text{hyp},j},\, \Omega_{\text{hyp},j}) @@ -235,13 +239,17 @@ $$ \log(\alpha_{ij}) \\ \log(\rho_{ij} - 1) \end{bmatrix} +\in \mathbb{R}^5 $$ {#eq-10} Distribution: $$ \theta_{ij} \sim \mathcal{N}(\mu_j, \Sigma_{P,j}) -$$ +$$ **Where:** + +- $\mu_j$: population-level mean vector for biomarker $j$\ +- $\Sigma_{P,j} \in \mathbb{R}^{5 \times 5}$: covariance matrix **across the** $P=5$ parameters for biomarker $j$ ------------------------------------------------------------------------ @@ -312,8 +320,8 @@ $$ **Hyperparameters:** -- $\mu_j$: population-level means (per biomarker $j$) -- $\Sigma_j$: $5 \times 5$ covariance matrix over parameters +- $\mu_j$: population-level mean vector for biomarker $j$\ +- $\Sigma_{P,j} \in \mathbb{R}^{P \times P}, \; P=5$: covariance matrix **across the parameters** for biomarker $j$ ------------------------------------------------------------------------ @@ -334,7 +342,7 @@ $$ \log(\alpha_{ij}) \\ \log(\rho_{ij} - 1) \end{bmatrix}, -\quad \Sigma_{P,j} \in \mathbb{R}^{5 \times 5} +\quad \Sigma_{P,j} \in \mathbb{R}^{P \times P}, \; P=5 $$ Each subject $i$ has a unique 5-parameter vector per biomarker $j$, capturing individual-level variation in antibody dynamics. @@ -371,8 +379,8 @@ $$ \Sigma_{P,j}^{-1} \sim \mathcal{W}(\Omega_j, \nu_j) $$ -- $\Sigma_j$: variability/covariance in subject-level parameters -- $\Omega_j$: prior scale matrix +- $\Sigma_{P,j}$: $5 \times 5$ covariance matrix of subject-level parameters for biomarker $j$\ +- $\Omega_j$: prior scale matrix (dimension $5 \times 5$)\ - $\nu_j$: degrees of freedom **Example:** @@ -404,7 +412,7 @@ $$ ## Matrix Algebra Computation -Let $P = 5$ (parameters), $J$ biomarkers. Then: +Let $P = 5$ (parameters), $B$ biomarkers. Then: $$ \Theta_i = @@ -440,18 +448,16 @@ $$ ## Understanding $\text{vec}(\Theta_i)$ -Each $\theta_{ij} \in \mathbb{R}^7$: +Each $\theta_{ij} \in \mathbb{R}^5$: $$ \theta_{ij} = \begin{bmatrix} -y_0 \\ -b_0 \\ -\mu_0 \\ -\mu_1 \\ -c \\ -\alpha \\ -r +\log(y_{0,ij}) \\ +\log(y_{1,ij} - y_{0,ij}) \\ +\log(t_{1,ij}) \\ +\log(\alpha_{ij}) \\ +\log(\rho_{ij} - 1) \end{bmatrix} $$ @@ -494,16 +500,20 @@ $$ ------------------------------------------------------------------------ -## Example: Kronecker Product with $P=2$, $B=3$ +## Example: Kronecker Product with $P = 5$, $B = 3$ Let: $$ \Sigma_P = \begin{bmatrix} -\sigma_{11} & \sigma_{12} \\ -\sigma_{21} & \sigma_{22} -\end{bmatrix},\quad +\sigma_{y_0,y_0} & \sigma_{y_0,y_1-y_0} & \sigma_{y_0,t_1} & \sigma_{y_0,\alpha} & \sigma_{y_0,\rho-1} \\ +\sigma_{y_1-y_0,y_0} & \sigma_{y_1-y_0,y_1-y_0} & \sigma_{y_1-y_0,t_1} & \sigma_{y_1-y_0,\alpha} & \sigma_{y_1-y_0,\rho-1} \\ +\sigma_{t_1,y_0} & \sigma_{t_1,y_1-y_0} & \sigma_{t_1,t_1} & \sigma_{t_1,\alpha} & \sigma_{t_1,\rho-1} \\ +\sigma_{\alpha,y_0} & \sigma_{\alpha,y_1-y_0} & \sigma_{\alpha,t_1} & \sigma_{\alpha,\alpha} & \sigma_{\alpha,\rho-1} \\ +\sigma_{\rho-1,y_0} & \sigma_{\rho-1,y_1-y_0} & \sigma_{\rho-1,t_1} & \sigma_{\rho-1,\alpha} & \sigma_{\rho-1,\rho-1} +\end{bmatrix}, +\quad I_B = \begin{bmatrix} 1 & 0 & 0 \\ @@ -515,7 +525,7 @@ $$ Then: $$ -\Sigma_P \otimes I_B \in \mathbb{R}^{6 \times 6} +\Sigma_P \otimes I_B \in \mathbb{R}^{15 \times 15} $$ ------------------------------------------------------------------------ @@ -525,12 +535,21 @@ $$ $$ \Sigma_P \otimes I_B = \begin{bmatrix} -\sigma_{11} & 0 & 0 & \sigma_{12} & 0 & 0 \\ -0 & \sigma_{11} & 0 & 0 & \sigma_{12} & 0 \\ -0 & 0 & \sigma_{11} & 0 & 0 & \sigma_{12} \\ -\sigma_{21} & 0 & 0 & \sigma_{22} & 0 & 0 \\ -0 & \sigma_{21} & 0 & 0 & \sigma_{22} & 0 \\ -0 & 0 & \sigma_{21} & 0 & 0 & \sigma_{22} +\Sigma_P & 0 & 0 \\ +0 & \Sigma_P & 0 \\ +0 & 0 & \Sigma_P +\end{bmatrix} +\in \mathbb{R}^{15 \times 15} +$$ + +where each block $\Sigma_P$ is the $5 \times 5$ covariance across parameters: + +$$ +\Sigma_P = +\begin{bmatrix} +\sigma_{y_0,y_0} & \cdots & \sigma_{y_0,\rho-1} \\ +\vdots & \ddots & \vdots \\ +\sigma_{\rho-1,y_0} & \cdots & \sigma_{\rho-1,\rho-1} \end{bmatrix} $$ @@ -554,18 +573,21 @@ $$ ## Extending to Correlated Biomarkers -Assume $P=3$, $B=3$ +Assume $P=5$, $B=3$ Define: $$ -\Sigma_K = +\Sigma_P = \begin{bmatrix} -\sigma_{11} & \sigma_{12} & \sigma_{13} \\ -\sigma_{21} & \sigma_{22} & \sigma_{23} \\ -\sigma_{31} & \sigma_{32} & \sigma_{33} -\end{bmatrix},\quad -\Sigma_J = +\sigma_{y_0,y_0} & \sigma_{y_0,y_1-y_0} & \sigma_{y_0,t_1} & \sigma_{y_0,\alpha} & \sigma_{y_0,\rho-1} \\ +\sigma_{y_1-y_0,y_0} & \sigma_{y_1-y_0,y_1-y_0} & \sigma_{y_1-y_0,t_1} & \sigma_{y_1-y_0,\alpha} & \sigma_{y_1-y_0,\rho-1} \\ +\sigma_{t_1,y_0} & \sigma_{t_1,y_1-y_0} & \sigma_{t_1,t_1} & \sigma_{t_1,\alpha} & \sigma_{t_1,\rho-1} \\ +\sigma_{\alpha,y_0} & \sigma_{\alpha,y_1-y_0} & \sigma_{\alpha,t_1} & \sigma_{\alpha,\alpha} & \sigma_{\alpha,\rho-1} \\ +\sigma_{\rho-1,y_0} & \sigma_{\rho-1,y_1-y_0} & \sigma_{\rho-1,t_1} & \sigma_{\rho-1,\alpha} & \sigma_{\rho-1,\rho-1} +\end{bmatrix}, +\quad +\Sigma_B = \begin{bmatrix} \tau_{11} & \tau_{12} & \tau_{13} \\ \tau_{21} & \tau_{22} & \tau_{23} \\ @@ -573,40 +595,47 @@ $$ \end{bmatrix} $$ +Here: + +- $\Sigma_P$: covariance across the 5 parameters (size $5 \times 5$)\ +- $\Sigma_B$: covariance across the $B$ biomarkers (size $B \times B$) + ------------------------------------------------------------------------ -## Kronecker Product Structure: $\Sigma_K \otimes \Sigma_J$ +## Kronecker Product Structure: $\Sigma_P \otimes \Sigma_B$ $$ -\Sigma_K \otimes \Sigma_J = -\begin{bmatrix} -\sigma_{11}\Sigma_J & \sigma_{12}\Sigma_J & \sigma_{13}\Sigma_J \\ -\sigma_{21}\Sigma_J & \sigma_{22}\Sigma_J & \sigma_{23}\Sigma_J \\ -\sigma_{31}\Sigma_J & \sigma_{32}\Sigma_J & \sigma_{33}\Sigma_J -\end{bmatrix} +\text{Cov}(\text{vec}(\Theta_i)) = \Sigma_P \otimes \Sigma_B $$ -Now biomarkers and parameters can be correlated. +- $\Sigma_P$: $5 \times 5$ covariance across parameters\ +- $\Sigma_B$: $B \times B$ covariance across biomarkers\ +- The Kronecker product expands to a $(5B) \times (5B)$ covariance matrix\ +- Not block-diagonal — allows both parameter correlations *and* cross-biomarker correlations ------------------------------------------------------------------------ -## Expanded Form: $\Sigma_K \otimes \Sigma_J$ (3x3) +## Practical To-Do List (for Chapter 2) -The $9 \times 9$ matrix contains all combinations $\sigma_{ab}\tau_{cd}$ +**Model Implementation:** -Not block-diagonal — includes cross-biomarker correlation +- Define parameter covariance $\Sigma_{P,j}$ (within each biomarker $j$)\ +- Define biomarker covariance $\Sigma_B$ (across biomarkers)\ +- Full covariance structure: $\text{Cov}(\text{vec}(\theta_i)) = \Sigma_P \otimes \Sigma_B$\ +- Priors: $\Sigma_{P,j}^{-1} \sim \mathcal{W}(\Omega_j, \nu_j)$, $\Sigma_B^{-1} \sim \mathcal{W}(\Omega_B, \nu_B)$ ------------------------------------------------------------------------- +**Simulation Study (first step):** -## Practical To-Do List (for Chapter 2) +- Generate fake longitudinal data with known $\Sigma_P$ and $\Sigma_B$\ +- Fit independence model ($I_B$) vs. correlated model ($\Sigma_B$)\ +- Evaluate recovery of true covariance structure -**Model Implementation:** +**Validation on Real Data (next step):** -- Define full $\Sigma_J$ and prior: $\Sigma_J^{-1} \sim \mathcal{W}(\Psi, \nu)$\ -- Implement $\Sigma_K \otimes \Sigma_J$ in JAGS +- Apply to Shigella longitudinal data\ +- Compare independence vs. correlated models (DIC, WAIC, posterior predictive checks)\ +- Summarize implications for epidemiologic utility -**Simulation + Validation:** +**Deliverable:** -- Simulate individuals with correlated biomarkers\ -- Fit both block-diagonal and full-covariance models\ -- Compare fit: DIC, WAIC, predictive checks +- Simulation + model comparison documented in a vignette for the serodynamics package From 9c82e8705dcd74267affd65e12f4f8e8a5ba92ed Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Mon, 18 Aug 2025 11:08:54 -0700 Subject: [PATCH 09/12] # update WORDLIST --- inst/WORDLIST | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/inst/WORDLIST b/inst/WORDLIST index 0e1050cb..162b1383 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -90,3 +90,9 @@ vec y0 y1 mathrm +ddots +epidemiologic +iB +serodynamic’s +Shigella +vdots \ No newline at end of file From 98a54ee8726f633c7b14694599c74f0f3117c142 Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Thu, 11 Sep 2025 14:14:48 -0700 Subject: [PATCH 10/12] =?UTF-8?q?#=20Add=20detailed=20Bayesian=20hierarchi?= =?UTF-8?q?cal=20model=20explanation=20with=20color-coded=20Bayes=E2=80=99?= =?UTF-8?q?=20rule=20equations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chapter2_correlated_biomarkers.qmd | 159 +++++++++++++++++- 1 file changed, 155 insertions(+), 4 deletions(-) diff --git a/vignettes/articles/chapter2_correlated_biomarkers.qmd b/vignettes/articles/chapter2_correlated_biomarkers.qmd index 2dffb57d..93c9e048 100644 --- a/vignettes/articles/chapter2_correlated_biomarkers.qmd +++ b/vignettes/articles/chapter2_correlated_biomarkers.qmd @@ -3,18 +3,23 @@ title: "Modeling Correlation in Antibody Kinetics: A Hierarchical Bayesian Appro author: "Kwan Ho Lee" institute: "UC Davis" date: today -format: - html: default +format: + html: + toc: true + toc-depth: 3 + toc-location: left + highlight-style: tango + number-sections: false + embed-resources: true # <- pack images/CSS/JS into the HTML beamer: theme: Madrid slide-level: 2 keep-tex: true toc: false incremental: false + highlight-style: tango engine: knitr bibliography: references.bib -env: - PAK_CACHE_DISABLE: "true" --- ## Overview @@ -410,6 +415,152 @@ $$ ------------------------------------------------------------------------ +------------------------------------------------------------------------ + +## Intuition: Full Walkthrough of the Hierarchical Model + +### 1) The three “levels” in our hierarchical model + +Think of one biomarker (one antigen–isotype) at a time; call it biomarker $j$. + +**Level A — population (hyper-parameters):** - Mean vector across people: $\mu_j$ - Between-person covariance for that biomarker’s kinetics parameters: $\Sigma_{p,j}$ + +These say how people’s true kinetic parameters vary in the population. + +**Level B — person-specific (random effects):** - For person $i$, their true parameter vector: $\theta_{ij}$ - Assumed distribution: $$ + \theta_{ij} \mid \mu_j, \Sigma_{p,j} \sim \mathcal{N}(\mu_j, \Sigma_{p,j}) + $$ + +This is how a person’s latent kinetics (e.g., $y_0, y_1, t_1, r, \alpha$) are drawn from the population. + +**Level C — observed data (measurement model):** - At each visit $t_{i\ell}$ for person $i$ we observe $x_{i\ell j}$. - The model says the observation is the true kinetics curve at that time plus noise: $$ + x_{i\ell j} = \mu_x(\theta_{ij}, t_{i\ell}) + \varepsilon_{i\ell j}, \qquad + \varepsilon_{i\ell j} \sim \mathcal{N}(0, \sigma_j) + $$ + +Here $\mu_x(\cdot)$ is your antibody kinetics function (rise/decay, etc.). Noise $\sigma_j$ is assay/measurement variability. + +------------------------------------------------------------------------ + +### 2) What we learn from the data (Bayes’ rule) + +Let $X_j$ denote all the observed measurements for biomarker $j$ (every person, every timepoint). + +Bayes gives the posterior for the *population* parameters: + +$$ +{\color{red}{p(\mu_j, \Sigma_{p,j} \mid X_j)}} +\;\propto\; +{\color{blue}{p(X_j \mid \mu_j, \Sigma_{p,j})}}\; +{{p(\mu_j, \Sigma_{p,j})}} +$$ + +- **Posterior (red)** = **marginal likelihood (blue)** $\times$ **prior** + +The “marginal likelihood” (blue) means: + +1. **The product over people:** $$ + {\color{blue}{p(X_j \mid \mu_j, \Sigma_{p,j})}} + \;=\; + \prod_{i=1}^n {\color{green}{p(X_{ij} \mid \mu_j, \Sigma_{p,j})}} + $$ + +2. **For each person, we integrate out their latent** $\theta_{ij}$ (green with orange observation term): $$ + {\color{green}{p(X_{ij} \mid \mu_j, \Sigma_{p,j})}} + \;=\; + \int {\color{orange}{p(X_{ij} \mid \theta_{ij})}}\; + p(\theta_{ij} \mid \mu_j, \Sigma_{p,j})\; d\theta_{ij} + $$ + +The orange bit ${\color{orange}{p(X_{ij}\mid \theta_{ij})}}$ is the observation model above. + +**Plain-English translation:** to evaluate how plausible ${{(\mu_j,\Sigma_{p,j})}}$ is, we ask:\ +*“If the population mean/covariance were* ${{(\mu_j,\Sigma_{p,j})}}$*, how likely are the data we saw?”* + +Because each person has their own unknown $\theta_{ij}$, we average (integrate) over all plausible $\theta_{ij}$ values.\ +That’s what the integral means: **average over person-level uncertainty.** + +Those integrals are rarely doable by hand, which is why we use **MCMC**: JAGS/Stan numerically “do the integrals” by sampling. + +------------------------------------------------------------------------ + +### 3) “New person” vs “Population”: what are they? + +These two are *predictive* objects we care about **after** we’ve learned from the data. + +#### A. “New person” (what Teunis calls *newperson*) + +This is the posterior predictive distribution of the parameters for a hypothetical new subject with no observed data, given what we learned about the population: + +$$ +p(\theta_{\text{new},j} \mid X_j) += +\int p(\theta_{\text{new},j} \mid \mu_j, \Sigma_{p,j}) +\; p(\mu_j, \Sigma_{p,j} \mid X_j) \; d\mu_j \, d\Sigma_{p,j} +$$ + +Key points: - **Independence given the population:** once you condition on $(\mu_j,\Sigma_{p,j})$, a brand-new person is independent of the existing data. $$ + p(\theta_{\text{new},j}\mid \mu_j,\Sigma_{p,j}, X_j) + = p(\theta_{\text{new},j}\mid \mu_j,\Sigma_{p,j}) + $$ - **Two sources of uncertainty included:** 1. *Population uncertainty*: we don’t know the exact $\mu_j$ or $\Sigma_{p,j}$; we have a posterior over them.\ +2. *Individual-to-individual variability*: even if $(\mu_j, \Sigma_{p,j})$ were known, a random person’s $\theta_{\text{new},j}$ varies around $\mu_j$ with covariance $\Sigma_{p,j}$. + +So “new person” is **wider** than “just the mean” because it includes both. + +**How to actually sample new person from MCMC draws:** 1. From posterior draws $s=1,\dots,S$: take $\mu_j^{(s)}, \Sigma_{p,j}^{(s)}$.\ +2. Draw a personal parameter: $\theta_{\text{new},j}^{(s)} \sim \mathcal{N}(\mu_j^{(s)}, \Sigma_{p,j}^{(s)})$.\ +3. Optionally simulate data: $x_{\text{new}}^{(s)}(t) = \mu_x(\theta_{\text{new},j}^{(s)}, t) + \varepsilon^{(s)}$. + +------------------------------------------------------------------------ + +#### B. “Population” + +When you show the *population* summary, you are typically visualizing $\mu_j$ (and maybe an uncertainty band for $\mu_j$ itself). This reflects uncertainty in the mean but **does not** add the between-person scatter $\Sigma_{p,j}$. + +- **Population curve:** plug $\mu_j$ into kinetics function: $t \mapsto \mu_x(\mu_j, t)$\ +- **Population uncertainty band:** variation across posterior draws of $\mu_j$ only\ +- **No person-to-person wiggle:** you don’t add $\Sigma_{p,j}$ here + +**Rule of thumb:** - Use *population* when you want the **typical (mean) kinetics**.\ +- Use *new person* when you want what you’d expect for a **random individual**. + +------------------------------------------------------------------------ + +### 4) Why the posterior for $(\mu_j, \Sigma_{p,j})$ isn’t “just the average of individual fits” + +A common misconception: if you fit each person separately and then average, you do **not** recover the hierarchical posterior. + +Why not? - **Shrinkage:** noisy individual estimates are “pulled” toward the group mean.\ +- **Priors matter:** the hierarchical prior interacts with the likelihood.\ +- **Nonlinearity:** averaging nonlinear fits ≠ hierarchical inference. + +------------------------------------------------------------------------ + +### 5) Where MCMC actually happens (and why “new person” doesn’t need more MCMC) + +The hard part is sampling: + +$$ +p(\mu_j, \Sigma_{p,j}, \{\theta_{ij}\}_{i=1}^n \mid X_j) +$$ + +- The integrals over $\theta_{ij}$ and the denominator $p(X_j)$ are what MCMC approximates.\ +- Once we have posterior draws of $(\mu_j, \Sigma_{p,j})$, sampling a “new person” is **independent Monte Carlo**: $$ + \theta_{\text{new},j}^{(s)} \sim \mathcal{N}(\mu_j^{(s)}, \Sigma_{p,j}^{(s)}) + $$ No further Markov chain needed. + +------------------------------------------------------------------------ + +### 6) Connecting colors in the figure to the story + +- **Black (top):** $p(\theta_{\text{new},j}\mid X_j)$ = new person posterior predictive\ +- **Red:** $\color{red}{p(\mu_j,\Sigma_{p,j}\mid X_j)}$ = posterior for population parameters\ +- **Blue:** $\color{blue}{p(X_j\mid\mu_j,\Sigma_{p,j})} = \prod_i p(X_{ij}\mid\mu_j,\Sigma_{p,j})$ = product over people\ +- **Green:** $\color{green}{p(X_{ij}\mid\mu_j,\Sigma_{p,j})} = \int \color{orange}{p(X_{ij}\mid \theta_{ij})} p(\theta_{ij}\mid\mu_j,\Sigma_{p,j}) d\theta_{ij}$ = integrate out each person\ +- **Orange:** $\color{orange}{p(X_{ij}\mid\theta_{ij})}$ = observation model + +------------------------------------------------------------------------ + ## Matrix Algebra Computation Let $P = 5$ (parameters), $B$ biomarkers. Then: From 841325ebbc882a88c921d783fa07038bb9df88b1 Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Thu, 11 Sep 2025 14:18:07 -0700 Subject: [PATCH 11/12] # minor --- .../articles/chapter2_correlated_biomarkers.qmd | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vignettes/articles/chapter2_correlated_biomarkers.qmd b/vignettes/articles/chapter2_correlated_biomarkers.qmd index 93c9e048..5329f2fa 100644 --- a/vignettes/articles/chapter2_correlated_biomarkers.qmd +++ b/vignettes/articles/chapter2_correlated_biomarkers.qmd @@ -438,7 +438,7 @@ This is how a person’s latent kinetics (e.g., $y_0, y_1, t_1, r, \alpha$) are \varepsilon_{i\ell j} \sim \mathcal{N}(0, \sigma_j) $$ -Here $\mu_x(\cdot)$ is your antibody kinetics function (rise/decay, etc.). Noise $\sigma_j$ is assay/measurement variability. +Here $\mu_x(\cdot)$ is our antibody kinetics function (rise/decay, etc.). Noise $\sigma_j$ is assay/measurement variability. ------------------------------------------------------------------------ @@ -499,7 +499,7 @@ p(\theta_{\text{new},j} \mid X_j) \; p(\mu_j, \Sigma_{p,j} \mid X_j) \; d\mu_j \, d\Sigma_{p,j} $$ -Key points: - **Independence given the population:** once you condition on $(\mu_j,\Sigma_{p,j})$, a brand-new person is independent of the existing data. $$ +Key points: - **Independence given the population:** once we condition on $(\mu_j,\Sigma_{p,j})$, a brand-new person is independent of the existing data. $$ p(\theta_{\text{new},j}\mid \mu_j,\Sigma_{p,j}, X_j) = p(\theta_{\text{new},j}\mid \mu_j,\Sigma_{p,j}) $$ - **Two sources of uncertainty included:** 1. *Population uncertainty*: we don’t know the exact $\mu_j$ or $\Sigma_{p,j}$; we have a posterior over them.\ @@ -515,20 +515,20 @@ So “new person” is **wider** than “just the mean” because it includes bo #### B. “Population” -When you show the *population* summary, you are typically visualizing $\mu_j$ (and maybe an uncertainty band for $\mu_j$ itself). This reflects uncertainty in the mean but **does not** add the between-person scatter $\Sigma_{p,j}$. +When we show the *population* summary, we are typically visualizing $\mu_j$ (and maybe an uncertainty band for $\mu_j$ itself). This reflects uncertainty in the mean but **does not** add the between-person scatter $\Sigma_{p,j}$. - **Population curve:** plug $\mu_j$ into kinetics function: $t \mapsto \mu_x(\mu_j, t)$\ - **Population uncertainty band:** variation across posterior draws of $\mu_j$ only\ -- **No person-to-person wiggle:** you don’t add $\Sigma_{p,j}$ here +- **No person-to-person wiggle:** we don’t add $\Sigma_{p,j}$ here -**Rule of thumb:** - Use *population* when you want the **typical (mean) kinetics**.\ -- Use *new person* when you want what you’d expect for a **random individual**. +**Rule of thumb:** - Use *population* when we want the **typical (mean) kinetics**.\ +- Use *new person* when we want what we’d expect for a **random individual**. ------------------------------------------------------------------------ ### 4) Why the posterior for $(\mu_j, \Sigma_{p,j})$ isn’t “just the average of individual fits” -A common misconception: if you fit each person separately and then average, you do **not** recover the hierarchical posterior. +A common misconception: if we fit each person separately and then average, we do **not** recover the hierarchical posterior. Why not? - **Shrinkage:** noisy individual estimates are “pulled” toward the group mean.\ - **Priors matter:** the hierarchical prior interacts with the likelihood.\ From 5af2d4b6dd126d9f1e504ccb6725c8d6794df920 Mon Sep 17 00:00:00 2001 From: Kwan Ho Lee Date: Thu, 11 Sep 2025 14:20:37 -0700 Subject: [PATCH 12/12] # minor2 --- vignettes/articles/chapter2_correlated_biomarkers.qmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/articles/chapter2_correlated_biomarkers.qmd b/vignettes/articles/chapter2_correlated_biomarkers.qmd index 5329f2fa..a4a6b748 100644 --- a/vignettes/articles/chapter2_correlated_biomarkers.qmd +++ b/vignettes/articles/chapter2_correlated_biomarkers.qmd @@ -555,8 +555,8 @@ $$ - **Black (top):** $p(\theta_{\text{new},j}\mid X_j)$ = new person posterior predictive\ - **Red:** $\color{red}{p(\mu_j,\Sigma_{p,j}\mid X_j)}$ = posterior for population parameters\ -- **Blue:** $\color{blue}{p(X_j\mid\mu_j,\Sigma_{p,j})} = \prod_i p(X_{ij}\mid\mu_j,\Sigma_{p,j})$ = product over people\ -- **Green:** $\color{green}{p(X_{ij}\mid\mu_j,\Sigma_{p,j})} = \int \color{orange}{p(X_{ij}\mid \theta_{ij})} p(\theta_{ij}\mid\mu_j,\Sigma_{p,j}) d\theta_{ij}$ = integrate out each person\ +- **Blue:** ${\color{blue}{p(X_j\mid\mu_j,\Sigma_{p,j})}} = \prod_i p(X_{ij}\mid\mu_j,\Sigma_{p,j})$ = product over people\ +- **Green:** ${\color{green}{p(X_{ij}\mid\mu_j,\Sigma_{p,j})}} = \int {\color{orange}{p(X_{ij}\mid \theta_{ij})}} p(\theta_{ij}\mid\mu_j,\Sigma_{p,j}) d\theta_{ij}$ = integrate out each person\ - **Orange:** $\color{orange}{p(X_{ij}\mid\theta_{ij})}$ = observation model ------------------------------------------------------------------------