# compute_A_B_G_D_and_simulate_mu_Lambda_CCU: Computation and simulations for CCU In fabMix: Overfitting Bayesian Mixtures of Factor Analyzers with Parsimonious Covariance and Unknown Number of Components

 compute_A_B_G_D_and_simulate_mu_Lambda_CCU R Documentation

## Computation and simulations for CCU

### Description

This function simulates \mu and \Lambda for the CCU model.

### Usage

	compute_A_B_G_D_and_simulate_mu_Lambda_CCU(SigmaINV,
suff_statistics, OmegaINV, K, priorConst1, T_INV, v_r)


### Arguments

 SigmaINV Precision matrix \Sigma^{-1} suff_statistics Sufficient statistics OmegaINV Prior parameter: \Omega^{-1} K Number of overfitting mixture components priorConst1 Prior constant: T^{-1}\xi T_INV Prior parameter: T^{-1}\xi v_r This vector is used to set to zero the upper right (q-1)\times(q-1) diagonal block of factor loadings for identifiability purposes.

### Value

A list containing a draw from the conditional distributions of \mu and \Lambda:

 Lambdas K\times p\times q array (factor loadings per component) mu K\times p array (marginal mean per component)

### Author(s)

Panagiotis Papastamoulis

### Examples

	library('fabMix')
data(waveDataset1500)
x_data <- scale(as.matrix(waveDataset1500[ 1:20, -1])) # data
z <-  waveDataset1500[ 1:20, 1] # class
p <- dim(x_data)[2]
n <- dim(x_data)[1]
q <- 2
K <- length(table(z))           # 3 classes
# give some arbitrary values to the parameters:
set.seed(1)
mu <- array( runif(K * p), dim = c(K,p) )
y <- array(rnorm(n = q*n), dim = c(n,q))
SigmaINV <- array(data = 0, dim = c(p,p) )
diag(SigmaINV) = 0.5 + 0.5*runif(p)
OmegaINV <- diag(q)
# compute sufficient stats
suf_stat <- compute_sufficient_statistics_given_mu(y = y,
z = z, K = K, x_data = x_data, mu = mu)

v_r <- numeric(p) #indicates the non-zero values of Lambdas
for( r in 1:p ){
v_r[r] <- min(r,q)
}
T_INV <- array(data = 0, dim = c(p,p))
diag(T_INV) <- diag(var(x_data))
diag(T_INV) <- 1/diag(T_INV)
ksi <- colMeans(x_data)
priorConst1 <- array(diag(T_INV)*ksi, dim =c(p,1))
# now simulate mu and Lambda
f2 <- compute_A_B_G_D_and_simulate_mu_Lambda_CCU(SigmaINV = SigmaINV,
suff_statistics = suf_stat, OmegaINV = OmegaINV,
K = K, priorConst1 = priorConst1, T_INV = T_INV, v_r = v_r)
# f2$mu contains the simulated means # f2$Lambdas contains the simulated factor loadings



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