# findLabels: Mixed Membership Post-Processing In mixedMem: Tools for Discrete Multivariate Mixed Membership Models

## Description

findLabels finds the optimal permutation of labels that minimizes the weighted squared difference between the arrays of subpopulation parameters from a fitted mixed membership model, θ and a given comparison model.

## Usage

 1 findLabels(model, comparison, exhaustive = TRUE) 

 model the fitted mixedMemModel 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 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 dependent on the initialization points of the variational EM algorithim. The function findLabels selects a permutation of the sub-population labels that best matches a given comparison model by minimizing the weighted squared difference between the θ arrays. The weights are determined by the relative frequencies of each group. Loss = ∑_j ∑_k α_k/α_0 [∑_v (\hatθ_{k,v} - θ_{k,v})^2] where α_0 = ∑_k α_k 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 mixedMemModel documentation for how to generate data and instantiate a mixedMemModel object # 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) theta1 = theta_truth[,perm,] test_model <- mixedMemModel(Total = Total, J = J,Rj = Rj, Nijr= Nijr, K = K, Vj = Vj,dist = dist, obs = obs, alpha = alpha, theta = theta1) out <- mmVarFit(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) 

mixedMem documentation built on Dec. 2, 2020, 1:09 a.m.