Conversion {EMCluster}R Documentation

Convert Matrices in Different Format

Description

These utility functions are to convert matrices in different formats.

Usage

LTSigma2variance(x)
variance2LTSigma(x)
LTsigma2var(x1, p = NULL)
var2LTsigma(x1)
class2Gamma(class)
Gamma2class(Gamma)

Arguments

x

a matrix/array to be converted, the dimension could be K×p(p+1)/2K\times p(p+1)/2 or p×p×Kp\times p\times K.

x1

a vector/matrix to be converted, the length and dimension could be p(p+1)/2p(p+1)/2 and p×pp\times p.

p

dimension of matrix.

class

id of clusters for each observation, length nn.

Gamma

containing posterior probabilities if normalized, otherwise containing component densities weighted by mixing proportion, dimension n×Kn\times K.

Details

LTSigma2variance converts LTSigma format to 3D array, and variance2LTSigma is the inversion function.

LTsigma2var converts LTsigma format to a matrix, and var2LTsigma is the inversion function. Note that LTsigma is one component of LTSigma.

class2Gamma converts id to a Gamma matrix where with probability 1 for the cluster where the observation belongs to, and Gamma2class converts posterior to cluster id where largest posterior is picked for each observation.

Value

A vector/matrix/array is returned.

Author(s)

Wei-Chen Chen wccsnow@gmail.com and Ranjan Maitra

References

https://www.stat.iastate.edu/people/ranjan-maitra

See Also

init.EM, emcluster.

Examples

## Not run: 
library(EMCluster, quietly = TRUE)
x <- da2$LTSigma
class <- da2$class

y <- LTSigma2variance(x)
str(y)
y <- variance2LTSigma(y)
str(y)
sum(x != y)

Gamma <- class2Gamma(class)
class.new <- Gamma2class(Gamma)
sum(class != class.new)

## End(Not run)

[Package EMCluster version 0.2-15 Index]