| fit_ss | R Documentation |
Iteratively solves for the fixed-effects coefficient vector
beta and the random-effects vector alpha using only the
aggregated sufficient summary, implementing Algorithm 1 of Jalili and
Lin (2025) for the normal linear VCMM. The raw response and design
matrices are not needed: everything reads off stats, which may
come from a single call to compute_sufficient_stats() or from a
streaming accumulator (init_accumulator() plus repeated
accumulate_stats()).
fit_ss(stats, penalty, control = vcmm_control(), re_cov_state = NULL)
## S3 method for class 'vcmm_fit'
print(x, ...)
stats |
A |
penalty |
A symmetric |
control |
A |
re_cov_state |
Optional. An internal random-effects covariance
state object (NULL for diagonal, or constructed for kronecker via
|
x |
A |
... |
Unused; present for S3 method consistency. |
At each iteration the algorithm solves:
beta-update: (C + P) beta = b - XtZ %*% alpha
alpha-update:
(ZtZ + (sigma_eps^2 / sigma_alpha^2) * I) alpha = Zty - t(XtZ) %*% beta
Both linear systems are solved via invert_matrix(), which
automatically dispatches between solve() and SVD pseudo-inverse
depending on dimension and condition number. Convergence is declared
when the relative change in both beta and alpha falls
below their respective tolerances.
If control$update_variance is TRUE, the residual variance
is re-estimated each iteration from the SS residual sum of squares,
and the random-effect variance is re-estimated as
mean(alpha^2).
A list of class "vcmm_fit" with elements:
beta: fitted fixed-effects vector, length p.
alpha: fitted random-effects vector, length q.
sigma_eps: final residual standard deviation.
sigma_alpha: final random-effect standard deviation.
iterations: number of iterations performed.
converged: TRUE if convergence tolerances were met.
elapsed_sec: wall-clock fitting time in seconds.
n_obs, p, q: data and design dimensions.
method: character, "SS".
control: the vcmm_control object used.
call: the matched call.
Jalili, L. and Lin, L.-H. (2025). Scalable and Communication-Efficient Varying Coefficient Mixed-Effects Models.
set.seed(1)
n <- 200; p <- 4; q <- 3
X <- cbind(1, matrix(rnorm(n * (p - 1)), n, p - 1))
Z <- matrix(rnorm(n * q), n, q)
alpha_true <- rnorm(q, sd = 0.5)
y <- as.vector(
X %*% c(2, 0.5, -0.3, 0.8) + Z %*% alpha_true + rnorm(n, sd = 0.5)
)
# Build sufficient statistics and penalty
stats <- compute_sufficient_stats(y, X, Z)
P <- build_penalty_matrix(n_basis = p - 1, lambda = 0.1)
# Fit with fixed variances
fit <- fit_ss(stats, P,
vcmm_control(sigma_eps = 0.5, sigma_alpha = 0.5))
fit
coef(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.