Description Usage Arguments Value Author(s) Examples
This function simulates μ and Λ.
1 2 | compute_A_B_G_D_and_simulate_mu_Lambda(SigmaINV,
suff_statistics, OmegaINV, K, priorConst1, T_INV, v_r)
|
SigmaINV |
Precision matrix Σ^{-1} |
suff_statistics |
Sufficient statistics |
OmegaINV |
Prior parameter: Ω^{-1} |
K |
Number of overfitting mixture components |
priorConst1 |
Prior constant: T^{-1}ξ |
T_INV |
Prior parameter: T^{-1}ξ |
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. |
A list containing a draw from the conditional distributions of μ and Λ:
Lambdas |
K\times p\times q array (factor loadings per component) |
mu |
K\times p array (marginal mean per component) |
Panagiotis Papastamoulis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 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
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))
# 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(y = y,
z = z, K = K, x_data = x_data)
v_r <- numeric(p) #indicates the non-zero values of Lambdas
for( r in 1:p ){
v_r[r] <- min(r,q)
}
# now simulate mu and Lambda
f2 <- compute_A_B_G_D_and_simulate_mu_Lambda(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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.