vem_smooth: Variational EM Algorithm for Bayesian Basis Function...

View source: R/vem_smooth.R

vem_smoothR Documentation

Variational EM Algorithm for Bayesian Basis Function Selection

Description

Fits m functional curves simultaneously via Bayesian basis function selection with an Ornstein-Uhlenbeck within-curve correlation structure. This function is called internally by vem_fit and only runs the VEM algorithm itself, without performing basis construction, standardization, or GCV tuning. Most users should call vem_fit instead, which handles those steps automatically.

Usage

vem_smooth(
  y,
  B,
  Xt = Xt,
  m = length(y),
  K = K,
  mu_ki = 0.5,
  lambda_1 = 1e-10,
  lambda_2 = 1e-10,
  delta_1 = 1e-10,
  delta_2 = 1e-10,
  maxIter = 1000,
  initial_values,
  convergence_threshold = 0.01,
  lower_opt = 0.1
)

Arguments

y

List of length m of numeric vectors (observed curves, possibly standardized).

B

List of length m of n_i \times K basis matrices, typically from getbasismatrix.

Xt

Numeric vector of n evaluation points, common across curves.

m

Integer. Number of curves. Defaults to length(y).

K

Integer. Number of basis functions.

mu_ki

Numeric scalar in (0,1). Beta prior hyperparameter for inclusion probabilities. Default 0.5.

lambda_1, lambda_2

Positive scalars. Inverse-Gamma prior hyperparameters for \tau^2. Default 10^{-10}.

delta_1, delta_2

Positive scalars. Inverse-Gamma prior hyperparameters for \sigma^2. Default 10^{-10}.

maxIter

Integer. Maximum VEM iterations. Default 1000.

initial_values

Named list with elements p (inclusion probabilities, length mK), delta2, lambda2, and w.

convergence_threshold

Positive scalar. Absolute ELBO tolerance for convergence. Default 0.01.

lower_opt

Positive scalar. Lower bound for w in L-BFGS-B. Default 0.1.

Details

The algorithm alternates between an E-step — sequential coordinate ascent variational inference (CAVI) updates for q(\beta_i), q(\sigma^2), q(\tau^2), q(Z_{ki}), and q(\theta_{ki}) — and an M-step that maximizes the ELBO with respect to the correlation decay parameter w via L-BFGS-B with an analytic gradient. Convergence is declared when the absolute ELBO change between iterations falls below convergence_threshold.

For hyperparameter initialization, set delta_1 and delta_2 such that delta_2 / (delta_1 - 1) is a rough estimate of the noise variance, and initialize w consistent with the expected correlation strength in the data.

Value

A named list containing:

mu_beta

Posterior means \mu_{\beta_{ki}} (length mK).

Sigma_beta

Posterior covariance array (K \times K \times m).

prob

Posterior inclusion probabilities p_{ki} (length mK). Basis k is active for curve i when p_{ki} > 0.5.

delta1, delta2

Final q(\sigma^2) parameters.

lambda1, lambda2

Final q(\tau^2) parameters.

w

Estimated correlation decay parameter (range-normalized scale).

cor_mat

The n \times n Ornstein-Uhlenbeck correlation matrix \Psi evaluated at the final estimated decay parameter \hat{w}, as returned by computePsiMatrix.

elbo_values

ELBO trajectory across iterations.

converged

Logical. Whether the convergence criterion was met.

n_iterations

Number of iterations run.

References

da Cruz, A. C., de Souza, C. P. E., & Sousa, P. H. T. O. (2024). Fast Bayesian basis selection for functional data representation with correlated errors. arXiv:2405.20758. https://arxiv.org/abs/2405.20758

See Also

vem_fit, plot.vem_fit, predict.vem_fit, coef.vem_fit


fda.vi documentation built on June 20, 2026, 5:06 p.m.