The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The survregVB
function provides a fast and accessible
solution for variational inference in accelerated failure time (AFT)
models for right-censored survival times following a log-logistic
distribution. It provides an efficient alternative to Markov chain Monte
Carlo (MCMC) methods by implementing a mean-field variational Bayes (VB)
algorithm for parameter estimation. The VB approach employs a coordinate
ascent algorithm and incorporates a piecewise approximation technique
when computing expectations to achieve conjugacy (Xian et al., 2024b). Eddelbuettel et al. (2025)
The log-logistic AFT model without shared frailty is specified as follows for the \(i^{th}\) subject in the sample, \(i=1,...,n\) , \(T_i\):
\[ log(T_i):=Y=X_i^T\beta+bz_i \]
where \(X_i\) is column vector of \(p-1\) covariates and a constant one (i.e. \(X_i=(1,x_i1,...,x_i(p-1))^T\)), \(\beta\) is a vector of coefficients for the covariates, \(z_i\) is a random variable following a standard logistic distribution with scale parameter \(b\).
The survregVB
function uses a Bayesian framework to
obtain the optimal variational densities of parameters \(\beta\) and \(b\) by maximizing the evidence based lower
bound (ELBO). To do so, we assume prior distributions:
\(\beta\sim\text{MVN}(\mu_0,\sigma_0^2I_{p*p})\), with precision \(v_0=1/\sigma^2\), and
\(b\sim\text{Inverse-Gamma}(\alpha_0,\omega_0)\)
where \(\mu_0,v_0,\alpha_0\) and
\(\omega_0\) are known hyperparameters.
At the end of the model fitting process, survregVB
obtains
the approximated posterior distributions:
\(q^*(\beta)\), a \(N_p(\mu,\Sigma)\) density function, and
\(q^*(b)\), an \(\text{Inverse-Gamma}(\alpha,\omega)\) density function,
where the parameters \(\mu,\Sigma,\alpha\) and \(\omega\) are obtained via the VB algorithm (Xian et al., 2024b).
First, we load the survregVB and survival libraries.
For the dnase
data set included in the package, our goal
is to fit it a log-logistic AFT regression model of the form:
\[
\log(T):=Y=\beta_0+\beta_1x_1+\beta_2x_2+bz
\] where trt
(\(x_1\), treatment, binary) and
fev
(\(x_2\), forced
expiratory volume, continuous) are the covariates of interest, and the
right-censoring indicator is infect
(Xian et al., 2024b).
The following fits the model with priors based off previous studies:
fit <- survregVB(
formula = Surv(time, infect) ~ trt + fev,
data = dnase,
alpha_0 = 501,
omega_0 = 500,
mu_0 = c(4.4, 0.25, 0.04),
v_0 = 1,
max_iteration = 10000,
threshold = 0.0005,
na.action = na.omit
)
print(fit)
## Call:
## survregVB(formula = Surv(time, infect) ~ trt + fev, data = dnase,
## alpha_0 = 501, omega_0 = 500, mu_0 = c(4.4, 0.25, 0.04),
## v_0 = 1, na.action = na.omit, max_iteration = 10000, threshold = 5e-04)
##
## Posterior distributions of the regression coefficients (Beta):
## mu=
## (Intercept) trt fev
## 4.1124 0.4155 0.0213
##
## Sigma=
## (Intercept) trt fev
## (Intercept) 0.036204 -0.01 < 2e-16
## trt -0.010274 0.02 2.2e-05
## fev -0.000473 0.00 8.3e-06
##
## Posterior distribution of the scale parameter (b):
## alpha= 744 omega= 674.648
##
## ELBO= -4857.094
##
## Number of iterations= 9
##
## n= 645
## Call:
## survregVB(formula = Surv(time, infect) ~ trt + fev, data = dnase,
## alpha_0 = 501, omega_0 = 500, mu_0 = c(4.4, 0.25, 0.04),
## v_0 = 1, na.action = na.omit, max_iteration = 10000, threshold = 5e-04)
## Value SD 95% CI Lower 95% CI Upper
## (Intercept) 4.112 0.190 3.739 4.485
## trt 0.415 0.141 0.139 0.692
## fev 0.021 0.003 0.016 0.027
## scale 0.908 0.033 0.844 0.974
##
## ELBO= -4857.094
##
## Number of iterations= 9
##
## n= 645
The following package and versions were used in the production of this vignette.
## R version 4.4.2 (2024-10-31)
## Platform: aarch64-apple-darwin20
## Running under: macOS Big Sur 11.6
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
##
## locale:
## [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## time zone: America/Toronto
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] survival_3.8-3 survregVB_0.0.1 knitr_1.49
##
## loaded via a namespace (and not attached):
## [1] digest_0.6.37 R6_2.5.1 invgamma_1.1 fastmap_1.2.0
## [5] Matrix_1.7-2 xfun_0.50 lattice_0.22-6 splines_4.4.2
## [9] cachem_1.1.0 htmltools_0.5.8.1 rmarkdown_2.29 lifecycle_1.0.4
## [13] cli_3.6.3 bayestestR_0.15.2 grid_4.4.2 sass_0.4.9
## [17] jquerylib_0.1.4 compiler_4.4.2 rstudioapi_0.17.1 tools_4.4.2
## [21] evaluate_1.0.3 bslib_0.9.0 yaml_2.3.10 rlang_1.1.5
## [25] jsonlite_1.8.9 insight_1.0.2
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.