update_z4_Sj: Collapsed Gibbs for z

Description Usage Arguments Value Author(s) Examples

View source: R/fabMix.R

Description

Collapsed Gibbs for z

Usage

1
update_z4_Sj(w, mu, Lambda, SigmaINV, K, x_data)

Arguments

w

vector with length K consisting of mixture weights

mu

K\times p array containing the marginal means

Lambda

K\times p array with factor loadings

SigmaINV

K\times p\times p array containing the precision matrix per component

K

Number of components

x_data

n\times p matrix containing the observed data

Value

Allocation vector

Author(s)

Panagiotis Papastamoulis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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_z4_Sj(w = syntheticDataset$weights, mu = syntheticDataset$means, 
	Lambda = syntheticDataset$factorLoadings, 
	SigmaINV = SigmaINV, 
	K = K, x_data = syntheticDataset$data)$z

fabMix documentation built on Feb. 20, 2020, 1:09 a.m.