Variational Bayes for linear mixed model (random intercept only).
Source:R/RcppExports.R
vb_lmm_randint.Rd
Variational Bayes for linear mixed model (random intercept only).
Usage
vb_lmm_randint(
X,
Z,
y,
mu_beta,
sigma_beta,
mu,
sigma,
Aeps = 1,
Beps = 1,
Au = 1,
Bu = 1,
Bqeps = 1,
Bqu = 1,
tol = 1e-08,
maxiter = 100L,
verbose = FALSE,
trace = FALSE
)
Arguments
- X
The design matrix
- Z
Group design matrix
- y
The response vector
- mu_beta
The prior mean for beta
- sigma_beta
The prior covariance for beta
- mu
Initial value for mu
- sigma
Initial value for sigma
- Aeps
The prior shape for sigma_eps
- Beps
The prior scale for sigma_eps
- Au
The prior shape for sigma_u
- Bu
The prior scale for sigma_u
- Bqeps
The intial value for Bqeps
- Bqu
The initial value for Bqu
- tol
Tolerance level
- maxiter
Maximum iterations
- verbose
Print trace of the lower bound to console. Default is
FALSE
.- trace
Print a trace of `mu` to console.
Value
A list containing:
- converged
Indicator for algorithm convergence.
- elbo
Vector of the ELBO sequence.
- mu
The optimised value of mu.
- Sigma
The optimised value of Sigma.
Examples
library(nlme)
X <- model.matrix( ~ age + factor(Sex, levels = c("Female", "Male")), data = Orthodont)
Z <- kronecker(diag(1, 27), rep(1, 4))
y <- Orthodont$distance
mu0 <- rep(0, ncol(X))
S0 <- diag(1e8, ncol(X))
mu <- rep(0, ncol(X) + ncol(Z))
S <- diag(1, ncol(X) + ncol(Z))
A <- 1/100
B <- 1/100
fit <- vb_lmm_randint(X, Z, y, mu0, S0, mu, S, A, B, A, B, verbose = TRUE)
#> Iter: 1; ELBO = -312.245477
#> Iter: 2; ELBO = -260.313773
#> Iter: 3; ELBO = -259.935380
#> Iter: 4; ELBO = -259.914549
#> Iter: 5; ELBO = -259.912980
#> Iter: 6; ELBO = -259.912836
#> Iter: 7; ELBO = -259.912821
#> Iter: 8; ELBO = -259.912819
#> Iter: 9; ELBO = -259.912819
#> Iter: 10; ELBO = -259.912819
#> Iter: 11; ELBO = -259.912819