Learn R Programming

gmmsslm (version 1.1.5)

bayesclassifier: Bayes' rule of allocation

Description

Bayes' rule of allocation

Usage

bayesclassifier(dat, p, g, pi = NULL, mu = NULL, sigma = NULL, paralist = NULL)

Value

clust

Class membership for the ith entity

Arguments

dat

An \(n\times p\) matrix where each row represents an individual observation.

p

Dimension of observation vecor.

g

Number of multivariate normal classes.

pi

A g-dimensional vector for the initial values of the mixing proportions.

mu

A \(p \times g\) matrix for the initial values of the location parameters.

sigma

A \(p\times p\) covariance matrix,or a list of g covariance matrices with dimension \(p\times p \times g\). It is assumed to fit the model with a common covariance matrix if sigma is a \(p\times p\) covariance matrix; otherwise it is assumed to fit the model with unequal covariance matrices.

paralist

A list containing the required parameters \((\pi, \mu, \Sigma)\).

Details

Classifier specified by Bayes' rule

The classifier/Bayes rule of allocation \(R(y_j;\theta)\) assigns an entity with observation \(y_j\) to class \(C_k \)(that is, \(R(y_j;\theta)=k\)) if \( k=\arg\max_i \tau_i(y_j;\theta),\)

Examples

Run this code
n <- 150
pi <- c(0.25, 0.25, 0.25, 0.25)
sigma <- array(0, dim = c(3, 3, 4))
sigma[, , 1] <- diag(1, 3)
sigma[, , 2] <- diag(2, 3)
sigma[, , 3] <- diag(3, 3)
sigma[, , 4] <- diag(4, 3)
mu <- matrix(c(0.2, 0.3, 0.4, 0.2, 0.7, 0.6, 0.1, 0.7, 1.6, 0.2, 1.7, 0.6), 3, 4)
dat <- rmix(n = n, pi = pi, mu = mu, sigma = sigma)
params <- list(pi=pi,mu = mu, sigma = sigma)
clust <- bayesclassifier(dat=dat$Y,p=3,g=4,paralist=params)

Run the code above in your browser using DataLab