Conversion {EMCluster} | R Documentation |
These utility functions are to convert matrices in different formats.
LTSigma2variance(x) variance2LTSigma(x) LTsigma2var(x1, p = NULL) var2LTsigma(x1) class2Gamma(class) Gamma2class(Gamma)
x |
a matrix/array to be converted, the dimension could be K * p(p+1)/2 or p * p * K. |
x1 |
a vector/matrix to be converted, the length and dimension could be p(p+1)/2 and p * p. |
p |
dimension of matrix. |
class |
id of clusters for each observation, length n. |
Gamma |
containing posterior probabilities if normalized, otherwise containing component densities weighted by mixing proportion, dimension n * K. |
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.
A vector/matrix/array is returned.
Wei-Chen Chen wccsnow@gmail.com and Ranjan Maitra
https://www.stat.iastate.edu/people/ranjan-maitra/
## 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)