MAP {BayesLCA}R Documentation

Maximum a posteriori (MAP) Classification

Description

MAP obtains maximum a posteriori (MAP) classifications. unMAP converts a classification vector into an indicator matrix.

Usage

MAP(mat, tie = c("random", "standard"))
unMAP(vec)

Arguments

mat

An N \times G matrix, typically N denotes observations from a dataset and G denotes the number of underlying groups in the data. Each row is expected to contain positive entries which sum to 1, but this isn't strictly necessary.

tie

May take one of two values, "random" or "standard". Takes the value "random" by default. See 'Details'.

vec

An vector consisting of integer entries. unMAP is intended to be used with a vector whose entries are classifications of dataset observations.

Details

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".

Value

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).

Author(s)

Arthur White

See Also

Zscore

Examples

##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")

[Package BayesLCA version 1.9 Index]