Note that there are some explanatory texts on larger screens.

plurals
  1. POR KNN imputation - function returning erroneous results & missing help page
    primarykey
    data
    text
    <p>I'm trying to impute some missing values in <code>R</code> using <code>library(imputation)</code> and <code>kNNImpute()</code>. The input data frame is 44 rows of 13 variables. There are 30 complete observations and 14 observations with missing values in 2 columns.</p> <p>The code is saying it's imputing all the missing values; however, it's imputing the last 4 values as <code>0</code>. From my reading of the code, this appears to be a flaw based on using <code>0</code> as a default for errors. My code:</p> <pre><code># impute data library(imputation) knn_data &lt;- kNNImpute(x, k= 5) # examine kNNImpute code kNNImpute </code></pre> <p><code>kNNImpute</code>'s code: See lines 4, 8 the function starting on line 24 and the 2nd line from the bottom (line 48):</p> <pre><code>[4] prelim = impute.prelim(x) [8] x.missing = prelim$x.missing [24] x.missing.imputed = t(apply(x.missing, 1, function(i) {...} [48] x[missing.matrix2] = 0 </code></pre> <p><code>??impute.prelim</code> returns no results (the help page is missing). So, I can't examine this code. </p> <p>However, the program flow for <code>kNNImpute</code> appears to be </p> <pre><code>[4] # run a (seemingly undefined) screening function [8] # pull in the missing rows for later imputation [24] # run imputation function [48] # based on line [4] output, impute all "error rows" == 0 </code></pre> <p>Can anyone explain why this is happening and/or how to solve this problem? </p> <p><strong>FYI</strong>- I have emailed the package author a link to this page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload