All projects

Fast Bayesian Survival Inference

Fast Variational Bayesian Inference for the Weibull AFT Model

Mean-field variational Bayes for right-censored Weibull AFT models, using 100-segment piecewise approximations for closed-form coordinate-ascent updates.

Type
Research
Context
MSc research project · Western University
Focus
Bayesian inference · Survival analysis · R · Stan
Highlight
453× faster fits vs. MCMC · 3,000 simulations

#My contribution

Independently extended a piecewise-conjugate variational framework to derive and implement a mean-field variational Bayes algorithm in R for right-censored Weibull AFT models, using 100-segment linear and quadratic approximations for closed-form coordinate-ascent updates.

This work was completed as my MSc research project in the Department of Statistical and Actuarial Sciences at Western University (supervised by Dr. Camila P. E. de Souza), with planned incorporation into the survregVB R package.

#Method and derivation

On the log-time scale, the Weibull accelerated failure time (AFT) model writes

Yi=log⁡(Ti)=xi⊤β+bziY_i = \log(T_i) = x_i^\top \beta + b z_i

where ziz_i follows the standard minimum extreme-value distribution and b>0b > 0 is the log-time error scale (equivalent to Weibull shape k=1/bk = 1/b). Under right censoring, the log-likelihood contains the nonlinear term exp⁡ ⁣((yi−xi⊤β)/b)\exp\!\left((y_i - x_i^\top \beta) / b\right) for every observation, which couples β\beta and bb and prevents conjugate conditional updates.

Extending the piecewise-conjugate strategy originally introduced for log-logistic AFT models, I placed independent priors on (β,b)(\beta, b) and adopted a mean-field variational family:

Priors:β∼N(μ0, v0−1I),b∼Inverse-Gamma⁡(α0, ω0)Variational family:q(β,b)=q(β) q(b),q(β)=N(μ,Σ),q(b)=Inverse-Gamma⁡(α,ω)\begin{aligned} \text{Priors:} &\quad \beta \sim \mathcal{N}(\mu_0,\, v_0^{-1} I), \quad b \sim \operatorname{Inverse-Gamma}(\alpha_0,\, \omega_0) \\ \text{Variational family:} &\quad q(\beta, b) = q(\beta)\,q(b), \quad q(\beta) = \mathcal{N}(\mu, \Sigma), \quad q(b) = \operatorname{Inverse-Gamma}(\alpha, \omega) \end{aligned}
  • Piecewise polynomial grid: partitioned the standardized residual domain [−10,3][-10, 3] into 100 equal-width segments, precomputing least-squares linear and quadratic approximations to exp⁡(z)\exp(z) over 300 equally spaced points per segment (clamping out-of-range residuals to the nearest endpoint segment).

  • Closed-form CAVI updates: before each coordinate step, each observation selects its active segment from the expected standardized residual

    zˉi=αω(yi−xi⊤μ)\bar{z}_i = \frac{\alpha}{\omega}\left(y_i - x_i^\top \mu\right)

    The quadratic approximation yields a Gaussian precision-and-mean update for q(β)q(\beta), while the linear approximation retains only log⁡b\log b and 1/b1/b terms to produce an Inverse-Gamma update for q(b)q(b).

  • Convergence monitoring: derived the corresponding approximate ELBO (retaining quadratic intercepts for ELBO evaluation) and stopped coordinate ascent when either the absolute ELBO change or the L1L_1 change in μ\mu fell within tolerance Δ\Delta.

#Simulation study

I implemented the solver, simulation drivers, and diagnostics in R and ran two paired simulation studies against maximum likelihood (survival::survreg) and Stan MCMC (4 chains, 2,000 iterations with 1,000 warmup; 4,000 retained posterior draws).

#Accuracy, calibration, and speed (3,000 datasets)

The primary study crossed sample sizes n∈{300,600}n \in \{300, 600\} with target censoring rates of 0%, 15%, and 30% (six scenarios, 500 retained datasets each):

Scenario (nn, censoring) VB time (s) Stan MCMC time (s) MCMC / VB
n=300n = 300, 0% 1.023 341.38 334×
n=300n = 300, 15% 0.907 338.02 373×
n=300n = 300, 30% 0.758 330.20 436×
n=600n = 600, 0% 1.303 610.88 469×
n=600n = 600, 15% 1.199 611.41 510×
n=600n = 600, 30% 1.025 612.69 598×
  • Speed-up scope: cumulative fitting times across 500 retained datasets yielded an average 453× success-only fitting-time speed-up over Stan MCMC (range 334×–598×). This measures successful fitting calls only—excluding unsuccessful VB attempts, interval construction, diagnostics, and Stan's 17.35 s compilation—rather than end-to-end wall-clock runtime.
  • Point accuracy: across all 24 scenario–parameter combinations, VB closely matched MCMC and survreg; the largest absolute difference between VB and MCMC empirical SDs was 0.0017, and the largest absolute MSE difference was 0.0010.
  • Interval calibration: nominal 95% credible intervals for regression coefficients achieved 93.4%–96.4% empirical coverage across all three methods. For the scale parameter bb, VB's mean-field intervals were 24%–28% wider than MCMC's, yielding conservative coverage of 98.2%–99.2% (vs. 92.6%–95.4% for MCMC).

#Small-sample prior sensitivity (n = 30)

A second study evaluated n=30n = 30 across 0%, 15%, and 30% censoring (500 datasets per rate) under weak and strong priors compared against survreg:

  • Averaged across censoring rates, weak-prior VB reduced MSE relative to survreg by 27.3% (β0\beta_0), 27.1% (β1\beta_1), 5.1% (β2\beta_2), and 47.7% (bb) (up to ~48%), driven primarily by lower sampling variance.
  • The stronger prior further lowered regression-coefficient MSE (up to 35.0% vs. survreg) and moved bb coverage closer to nominal (93.8%–96.2%), while increasing the MSE of bb by 16.3% relative to the weak prior—illustrating a concrete parameter-specific bias–variance trade-off.

#METABRIC breast-cancer application

I applied the method to 1,815 complete-case METABRIC breast-cancer patients (1,041 deaths, 774 censored; 42.6% censoring; median observed follow-up 114.6 months) with an intercept and 11 covariate terms covering age at diagnosis, log⁡(1+x)\log(1 + x) tumour size and positive lymph nodes (standardized), histologic grade, ER/HER2/PR status, chemotherapy, hormone therapy, and radiotherapy.

  • Posterior agreement: VB closely reproduced Stan MCMC point estimates and 95% credible intervals across all 11 covariates and the scale parameter (b=0.791b = 0.791 vs. 0.7960.796 for MCMC; Stan diagnostics showed max⁡R^=1.003\max \hat{R} = 1.003, min⁡ESS≈1,420\min \mathrm{ESS} \approx 1{,}420, and zero divergences).
  • Interpretable time ratios: under the AFT parameterization (exp⁡(βj)\exp(\beta_j)), older age (0.678 per SD), larger tumour size (0.861 per SD), more positive lymph nodes (0.778 per SD), grade 3 disease (0.796 vs. grade 1), and HER2-positive status (0.780) were associated with shorter survival, whereas hormone therapy (1.138) and radiotherapy (1.235) were associated with longer survival. Because METABRIC is observational, these represent adjusted associations rather than causal treatment effects.
  • Model diagnostic: the Kaplan–Meier survival curve of Cox–Snell residuals tracked the Exponential⁡(1)\operatorname{Exponential}(1) reference closely over most of the residual range, with mild right-tail separation where fewer patients remained under observation.