update_z2_Sj | R Documentation |
z
using matrix inversion lemma
Collapsed Gibbs for z
using matrix inversion lemma
update_z2_Sj(w, mu, Lambda, SigmaINV, K, x_data)
w |
vector with length |
mu |
|
Lambda |
|
SigmaINV |
|
K |
Number of components |
x_data |
|
Allocation vector
Panagiotis Papastamoulis
library('fabMix')
# simulate some data
n = 8 # sample size
p = 5 # number of variables
q = 2 # number of factors
K = 2 # true number of clusters
sINV_diag = 1/((1:p)) # diagonal of inverse variance of errors
set.seed(100)
syntheticDataset <- simData(sameLambda=TRUE,K.true = K, n = n, q = q, p = p,
sINV_values = sINV_diag)
SigmaINV <- array(data = 0, dim = c(K,p,p))
for(k in 1:K){
diag(SigmaINV[k,,]) <- 1/diag(syntheticDataset$variance) + rgamma(p, shape=1, rate = 1)
}
# use the real values as input and simulate allocations
update_z2_Sj(w = syntheticDataset$weights, mu = syntheticDataset$means,
Lambda = syntheticDataset$factorLoadings,
SigmaINV = SigmaINV,
K = K, x_data = syntheticDataset$data)$z
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.