Update class means
Arguments
- beta
[
matrix(nrow = P_r, ncol = N)
]
The matrix of the decider-specific coefficient vectors.- Omega
[
matrix(nrow = P_r * P_r, ncol = C)
]
The matrix of vectorized class covariance matrices as columns.- z
[
numeric(N)
]
The decider class allocations.- m
[
numeric(C)
]
The vector of current class frequencies.- Sigma_b_0_inv
[
matrix(P_r, P_r)
]
The prior precision of the class mean.- mu_b_0
[
numeric(P_r)
]
The mean vector of the normal prior for eachb_c
.
Examples
N <- 100
b <- cbind(c(0, 0), c(1, 1))
Omega <- matrix(c(1, 0.3, 0.3, 0.5, 1, -0.3, -0.3, 0.8), ncol = 2)
z <- c(rep(1, N / 2), rep(2, N / 2))
m <- as.numeric(table(z))
beta <- sapply(
z, function(z) oeli::rmvnorm(n = 1, b[, z], matrix(Omega[, z], 2, 2))
)
update_b(
beta = beta, Omega = Omega, z = z, m = m,
Sigma_b_0_inv = diag(2), mu_b_0 = c(0, 0)
)
#> [,1] [,2]
#> [1,] 0.0401460 1.125959
#> [2,] -0.1740866 1.032935