MAP {BayesLCA} | R Documentation |
MAP
obtains maximum a posteriori (MAP) classifications. unMAP
converts a classification vector into an indicator matrix.
MAP(mat, tie = c("random", "standard"))
unMAP(vec)
mat |
An |
tie |
May take one of two values, |
vec |
An vector consisting of integer entries. |
For each row in mat
, MAP
assigns an indexing value identifying the entry in the row taking the highest value. In the case where multiple values in a row share a common largest value, tie
determines how such a value is chosen. If tie = "random"
, one of the suitable values is chosen at random; when tie = "standard"
, the first such suitable value is selected, in common with other packages. Defaults to "random"
.
MAP
returns a classification vector. unMAP
returns a classification matrix, with each row indicating group membership by the column entry which is non-zero (and equal to one).
Arthur White
##Simple example
s1<- sample(1:2, 10, replace=TRUE)
unMAP(s1)
MAP(unMAP(s1))
##More to the point
data(Alzheimer)
fit<- blca.em(Alzheimer, 2)
MAP(fit$Z) ## Best estimates of group membership.
mat1<- matrix(1/3, nrow=10, ncol=3) ##demonstrating the use of "tie" argument
MAP(mat1, tie="random")
MAP(mat1, tie="standard")