yat: Ticket #346: Generalize NNI to utilize different metrics
https://dev.thep.lu.se/yat/ticket/346
<p>
It has been reported that is might be beneficial to use a correlation based distance rather than an Euclidean one (see e.g. <a class="ext-link" href="http://www.biomedcentral.com/1471-2105/9/12/abstract/"><span class="icon"></span>Brock et al.</a>).
</p>
<p>
These seems trivial to simply add a Distance class and thereby achieve the generalization. However, one'd better be careful here, because changing the metric should not only be reflected in calculation of distance between rows (i.e. genes). It should also be reflected in the imputation equation (see eq. 10 in WeNNI paper).
</p>
<p>
In equation 10, imputation value is simply a weighted average of the values of the nearest neighbors. This is motivated because you assume that nearest neighbors should also be close in the sample we are imputing. Using a semi-positive definite distance measure such as PearsonDistance, this is suboptimal. The reason is that two vectors can have a very small distance even though element values are very different. The distance can actually be zero also for non-identical vectors. In other words, the distance is translational and scale invariant. Say for instance that we have the following small matrix
</p>
<pre class="wiki">0 12 0 12 mv
4 8 4 8 4
</pre><p>
Obviously imputing the missing value to 4 here is not optimal - the vectors have a zero distance prior imputation and post imputation the distance would no longer be zero. Rather we would like to set the value to 0. How can that be achieved? Well, the key is in the invariants mentioned above. We remember that correlation based distance is equivalent to a z-score normalization followed by Euclidean distance. Therefore, it would be tempting to z-score each row and then use Euclidean distance to impute values. However, there are some disadvantages with that approach basically because a correlation calculation is based solely on pairs of data present in both vectors. Therefore, the average and variance used in correlation calculation would be different from the one in the z-score normalization, which would yield unwanted behavior such as mentioned above. A better approach would be to perform the z-score normalization based on the same data that is used in calculation of the distance.
</p>
<blockquote>
<p>
<code>y' = (y-m)/s</code>
</p>
</blockquote>
<p>
The missing value can then be imputed from the neighbor: <code>y' = x'</code> and the z-score is reversed to get back the original average and scale <code>y = s*y'+m</code> (well technically they will be different due to imputed values, but almost...).
</p>
<p>
Implementation-wise there is probably no reason to perform the normalization back and forth. Instead one could calculate the correlation distance using AveragerPairWeighted and thereby getting the nearest neighbors. the trick is then to calculate the imputation value directly using averages and variances of x and y.
</p>
<p>
<code>y = s_y * y' + m_y = s_y * x' + m_y = s_y * (x-m_x) / s_x + m_y </code>
</p>
<p>
which is similar to equation for linear regression
</p>
<p>
<code>y = s_y/s_x * r * (x-m_x) + m_y</code>.
</p>
en-usyat/yat/chrome/site/images/yat.png
https://dev.thep.lu.se/yat/ticket/346
Trac 1.2.3PeterTue, 11 Mar 2008 18:47:46 GMTdescription changed
https://dev.thep.lu.se/yat/ticket/346#comment:1
https://dev.thep.lu.se/yat/ticket/346#comment:1
<ul>
<li><strong>description</strong>
modified (<a href="/yat/ticket/346?action=diff&version=1">diff</a>)
</li>
</ul>
Ticket