class: Matrix of Indicator Variables given Classification

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/code.R

Description

Converts a classification vector into a matrix of indicator variables.

Usage

1
class(groups, k)  

Arguments

groups

A numeric vector of integers. Typically the distinct entries of this vector would represent a classification of observations in a data set.

k

An integer indicating the number of groups.

Value

An n (number of observations) by k (number of groups) matrix of (0,1) indicator variables. The [i,j]th entry is 1 if groups[i] is j and 0 otherwise.

Author(s)

Punzo A. and McNicholas P. D.

References

Punzo, A., and McNicholas, P. D. (2013). Outlier Detection via Parsimonious Mixtures of Contaminated Gaussian Distributions. arXiv.org e-print 1305.4669, available at: http://arxiv.org/abs/1305.4669.

See Also

pmcgd-package,MS

Examples

1
2
3
4
5
6
n <- 20
k <- 3
prob <- c(0.5,0.3,0.2)
groups <- sample(1:k, size=n, replace = TRUE, prob = prob)
matclass <- class(groups, k)
matclass

pmcgd documentation built on May 1, 2019, 7:35 p.m.