MoE_estep | R Documentation |
Softmax function to compute the responsibility matrix z and the log-likelihood for MoEClust models, with the aid of MoE_dens
.
MoE_estep(data,
mus,
sigs,
log.tau = 0L,
Vinv = NULL,
Dens = NULL)
data |
If there are no expert network covariates, |
mus |
The mean for each of G components. If there is more than one component, this is a matrix whose k-th column is the mean of the k-th component of the mixture model. For the univariate models, this is a G-vector of means. In the presence of expert network covariates, all values should be equal to |
sigs |
The |
log.tau |
If covariates enter the gating network, an n times G matrix of mixing proportions, otherwise a G-vector of mixing proportions for the components of the mixture. Must be on the log-scale in both cases. The default of |
Vinv |
An estimate of the reciprocal hypervolume of the data region. See the function |
Dens |
(Optional) A numeric matrix whose |
A list containing two elements:
z |
A matrix with |
loglik |
The estimated log-likelihood, computed efficiently via |
This softmax function is intended for joint use with MoE_dens
, using the log-densities. Caution is advised using this function without explicitly naming the arguments. Models with a noise component are facilitated here too.
The E-step can be replaced by a C-step, see MoE_cstep
and the algo
argument to MoE_control
.
Keefe Murphy - <keefe.murphy@mu.ie>
MoE_dens
, MoE_clust
, MoE_cstep
, MoE_control
, mclustVariance
, rowLogSumExps
data(ais)
hema <- ais[,3:7]
model <- MoE_clust(hema, G=3, gating= ~ BMI + sex, modelNames="EEE", network.data=ais)
Dens <- MoE_dens(data=hema, mus=model$parameters$mean,
sigs=model$parameters$variance, log.tau=log(model$parameters$pro))
# Construct the z matrix and compute the log-likelihood
Estep <- MoE_estep(Dens=Dens)
(ll <- Estep$loglik)
# Check that the z matrix & classification are the same as those from the model
identical(max.col(Estep$z), as.integer(unname(model$classification))) #TRUE
identical(Estep$z, model$z) #TRUE
# Call MoE_estep directly
Estep2 <- MoE_estep(data=hema, sigs=model$parameters$variance,
mus=model$parameters$mean, log.tau=log(model$parameters$pro))
identical(Estep2$loglik, ll) #TRUE
# The same can be done for models with expert covariates &/or a noise component
# Note for models with expert covariates that the mean has to be supplied as 0,
# and the data has to be supplied as "resid.data"
m2 <- MoE_clust(hema, G=2, expert= ~ sex, modelNames="EVE", network.data=ais, tau0=0.1)
Estep3 <- MoE_estep(data=m2$resid.data, sigs=m2$parameters$variance, mus=0,
log.tau=log(m2$parameters$pro), Vinv=m2$parameters$Vinv)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.