beta_expectations: Expected Residual and Coefficient Squared Moments

beta_expectationsR Documentation

Expected Residual and Coefficient Squared Moments

Description

Three expectations under q(\beta_i) and q(Z_i) appearing in the updates for q(\sigma^2), q(\tau^2), and q(Z_{ki}).

expectedResidualSq computes the expected weighted residual sum of squares E[(y_i - B_i\xi_i)^\top \Psi^{-1}(y_i - B_i\xi_i)] via a quadratic-form plus trace decomposition. Uses prob[iter-1,] because q(Z) has not yet been updated at the point this is called (Step 2).

expectedSumBetaSq computes \sum_k(\text{Var}_{\beta_{ki}} + \mu_{\beta_{ki}}^2), appearing in the q(\sigma^2) and q(\tau^2) updates.

expectedBetaSq computes the same residual quadratic form as expectedResidualSq but with the k-th inclusion indicator fixed at candidate value z \in \{0,1\}, used in the q(Z_{ki}) update.

Arguments

B

List of n_i \times K basis matrices.

i

Integer. Curve index.

y

List of observed curve vectors.

mu

Matrix (\text{maxIter} \times mK) of posterior beta means.

Sigma

Array (K \times K \times m) of posterior beta covariances.

prob

Matrix (\text{maxIter} \times mK) of inclusion probabilities.

iter

Integer. Current iteration index.

psi

Correlation matrix \Psi from computePsiMatrix.

z

Integer (0 or 1). Candidate inclusion value (expectedBetaSq only).

k

Integer. Basis function index (expectedBetaSq only).

K

Integer. Total number of basis functions (expectedBetaSq only).

Value

A numeric scalar.


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