update_Omega | R Documentation |
This function updates the class covariances (independent from the other classes).
update_Omega(beta, b, z, m, nu, Theta)
beta |
The matrix of the decision-maker specific coefficient vectors of dimension
|
b |
The matrix of class means as columns of dimension |
z |
The vector of the allocation variables of length |
m |
The vector of class sizes of length |
nu |
The degrees of freedom (a natural number greater than |
Theta |
The scale matrix of dimension |
The following holds independently for each class c
.
Let \Omega_c
be the covariance matrix of class number c
.
A priori, we assume that \Omega_c
is inverse Wishart distributed
with \nu
degrees of freedom and scale matrix \Theta
.
Let (\beta_n)_{z_n=c}
be the collection of \beta_n
that are currently allocated to class c
,
m_c
the size of class c
, and b_c
the class mean vector.
Due to the conjugacy of the prior, the posterior \Pr(\Omega_c \mid (\beta_n)_{z_n=c})
follows an inverted Wishart distribution
with \nu + m_c
degrees of freedom and scale matrix \Theta^{-1} + \sum_n (\beta_n - b_c)(\beta_n - b_c)'
, where
the product is over the values n
for which z_n=c
holds.
A matrix of updated covariance matrices for each class in columns.
### N = 100 decider, P_r = 2 random coefficients, and C = 2 latent classes
N <- 100
b <- cbind(c(0,0),c(1,1))
(Omega_true <- matrix(c(1,0.3,0.3,0.5,1,-0.3,-0.3,0.8), ncol=2))
z <- c(rep(1,N/2),rep(2,N/2))
m <- as.numeric(table(z))
beta <- sapply(z, function(z) rmvnorm(b[,z], matrix(Omega_true[,z],2,2)))
### degrees of freedom and scale matrix for the Wishart prior
nu <- 1
Theta <- diag(2)
### updated class covariance matrices (in columns)
update_Omega(beta = beta, b = b, z = z, m = m, nu = nu, Theta = Theta)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.