# findLabels: Mixed Membership Post-Processing 'findLabels' finds the... In ysamwang/mixedMem: Tools for Discrete Multivariate Mixed Membership Models

## Description

Mixed Membership models are invariant to permutations of the sub-population labels; swapping the names of each sub-population yields an equivalent model. The ordering of the labels in a fitted model is often dependent on the initialization points. The function findLabels selects a permutation of the sub-population labels that best matches a given comparison model by minimizing squared differences between the θ arrays.

## Usage

 1 findLabels(model, comparison, exhaustive = FALSE)

 model the fitted mixedMemModelMCMC or mixedMemModelVarInf object. comparison an array of the same dimensions as model$theta which contains the subpopulation parameters from another model. findLabels will return a permutation of the labels of model which match to comparison most closely. exhaustive a boolean for whether an exhaustive search should be performed. If false, a greedy algorithim is used instead. ## Details Loss = ∑_j ∑_k [∑_v (\hatθ_{k,v} - θ_{k,v})^2] If K, number of sub-populations, is small, the method searches through all K! permutations of the sub-population labels and select the permutation which minimizes the loss. If K is large, a greedy algorithim can be used instead. This algorithm selects the best match for each fitted sub-population starting with the group with the largest fitted relative frequency. ## Value findLabels returns a list with two objects: perm and loss. perm is the optimal permutation of the labels with respect to the squared error loss. loss is the calculated value of the weighted squared error loss (shown above) for the optimal permutation. ## See Also permuteLabels ## Examples  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ## Not run: # See mixedMemModelMCMC or mixedMemModelVarInf documentation for how to generate data and instantiate objects # After the data as been generated, we initialize the array of sub-population parameters (theta) # according to a permutation of the true labeling set.seed(123) perm <- sample.int(K, size = K, replace = FALSE) theta.perm <- theta_truth[,perm,] test_model <- mixedMemModelVarInf(Total = Total, J = J,Rj = Rj, Nijr= Nijr, K = K, Vj = Vj,dist = dist, obs = obs, alpha = alpha, theta = theta.perm) out <- mmVIFit(test_model) opt.perm <- findLabels(out, theta_truth) opt.perm # produce mixedMemModel object with sub-population labels permuted to best match # the comparison model out <- permuteLabels(out, opt.perm$perm) ## End(Not run)

ysamwang/mixedMem documentation built on May 4, 2019, 5:33 p.m.