update_all_y_Sj: Gibbs sampling for y in 'xUx' model

View source: R/fabMix.R

update_all_y_SjR Documentation

Gibbs sampling for y in xUx model

Description

Gibbs sampling for updating the factors y for models with different variance of errors per component.

Usage

update_all_y_Sj(x_data, mu, SigmaINV, Lambda, z)

Arguments

x_data

n\times p matrix with obseved data

mu

n\times p matrix of marginal means

SigmaINV

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

Lambda

p\times q matrix of factor loadings

z

Allocation vector

Value

A matrix with generated factors

Author(s)

Panagiotis Papastamoulis

Examples

library('fabMix')

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)
# add some noise here:
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 factors
update_all_y_Sj(x_data = syntheticDataset$data, 
		mu = syntheticDataset$means, 
		SigmaINV = SigmaINV, 
		Lambda = syntheticDataset$factorLoadings, 
		z = syntheticDataset$class)


fabMix documentation built on May 29, 2024, 2:53 a.m.