Description Usage Arguments Details Value See Also Examples
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.
1 | findLabels(model, comparison, exhaustive = FALSE)
|
model |
the fitted |
comparison |
an array of the same dimensions as model$theta which contains the subpopulation parameters from another model.
|
exhaustive |
a boolean for whether an exhaustive search should be performed. If false, a greedy algorithim is used instead. |
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.
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.
permuteLabels
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.