<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Assign Class Id</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body>

<table width="100%" summary="page for Assign Class"><tr><td>Assign Class</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>Assign Class Id</h2>

<h3>Description</h3>

<p>This function assigns cluster id to each observation in <code>x</code>
according to the desired model <code>emobj</code> or specified
parameters <code>pi</code>, <code>Mu</code>, and <code>LTSigma</code>. 
</p>


<h3>Usage</h3>

<pre>
  assign.class(x, emobj = NULL, pi = NULL, Mu = NULL, LTSigma = NULL,
               lab = NULL, return.all = TRUE)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
<p>the data matrix, dimension <i>n * p</i>.</p>
</td></tr>
<tr valign="top"><td><code>emobj</code></td>
<td>
<p>the desired model which is a list mainly contains <code>pi</code>,
<code>Mu</code>, and <code>LTSigma</code>, usually a returned object from
<code>init.EM</code>.</p>
</td></tr>
<tr valign="top"><td><code>pi</code></td>
<td>
<p>the mixing proportion, length <i>K</i>.</p>
</td></tr>
<tr valign="top"><td><code>Mu</code></td>
<td>
<p>the centers of clusters, dimension <i>K * p</i>.</p>
</td></tr>
<tr valign="top"><td><code>LTSigma</code></td>
<td>
<p>the lower triangular matrices of dispersion, dimension
<i>K * p(p+1)/2</i>.</p>
</td></tr>
<tr valign="top"><td><code>lab</code></td>
<td>
<p>labeled data for semi-supervised clustering,
length <i>n</i>.</p>
</td></tr>
<tr valign="top"><td><code>return.all</code></td>
<td>
<p>if returning with a whole <code>emobj</code> object.</p>
</td></tr>
</table>


<h3>Details</h3>

<p>This function are based either an input <code>emobj</code> or inputs <code>pi</code>,
<code>Mu</code>, and <code>LTSigma</code> to assign class id to each observation of
<code>x</code>.
</p>
<p>If <code>lab</code> is submitted, then the observation with label id greater 0
will not be assigned new class.
</p>


<h3>Value</h3>

<p>This function returns a list containing mainly two new variables:
<code>nc</code> (length <i>K</i> numbers of observations in each class) and
<code>class</code> (length <i>n</i> class id).
</p>


<h3>Author(s)</h3>

<p>Wei-Chen Chen <a href="mailto:wccsnow@gmail.com">wccsnow@gmail.com</a> and Ranjan Maitra.
</p>


<h3>References</h3>

<p><a href="https://www.stat.iastate.edu/people/ranjan-maitra">https://www.stat.iastate.edu/people/ranjan-maitra</a>
</p>


<h3>See Also</h3>

<p><code>init.EM</code>, <code>emcluster</code>.
</p>


<h3>Examples</h3>

<pre>

library(EMCluster, quietly = TRUE)
set.seed(1234)
x2 &lt;- da2$da

ret &lt;- init.EM(x2, nclass = 2)
ret.new &lt;- assign.class(x2, ret, return.all = FALSE)
str(ret.new)

</pre>


</body></html>
