title: 'R', 'mice', missing variable imputation - how to only do one column in sparse matrix
body: <p>I have a matrix that is half-sparse.  Half of all cells are blank (na) so when I try to run the 'mice' it tries to work on all of them.  I'm only interested in a subset.</p>
  
  <p>Question: In the following code, how do I make "mice" only operate on the first two columns?  Is there a clean way to do this using row-lag or row-lead, so that the content of the previous row can help patch holes in the current row?</p>
  
  <pre><code>set.seed(1)
  
  #domain
  x &lt;- seq(from=0,to=10,length.out=1000)
  
  #ranges
  y &lt;- sin(x) +sin(x/2) + rnorm(n = length(x))
  y2 &lt;- sin(x) +sin(x/2) + rnorm(n = length(x))
  
  #kill 50% of cells
  idx_na1 &lt;- sample(x=1:length(x),size = length(x)/2)
  y[idx_na1] &lt;- NA
  
  #kill more cells
  idx_na2 &lt;- sample(x=1:length(x),size = length(x)/2)
  y2[idx_na2] &lt;- NA
  
  #assemble base data
  my_data &lt;- data.frame(x,y,y2)
  
  #make the rest of the data
  for (i in 3:50){
  
  
       my_data[,i] &lt;- rnorm(n = length(x))
       idx_na2 &lt;- sample(x=1:length(x),size = length(x)/2)
       my_data[idx_na2,i] &lt;- NA
  
  }
  
  #imputation
  est &lt;- mice(my_data)
  
  data2 &lt;- complete(est)
  
  str(data2[,1:3])
  </code></pre>
  
  <p>Places that I have looked for answers:</p>
  
  <ul>
  <li>help document (<a href="https://cran.r-project.org/web/packages/mice/mice.pdf" rel="nofollow noreferrer">link</a>)</li>
  <li>google of course... </li>
  <li><a href="https://stats.stackexchange.com/questions/99334/fast-missing-data-imputation-in-r-for-big-data-that-is-more-sophisticated-than-s">https://stats.stackexchange.com/questions/99334/fast-missing-data-imputation-in-r-for-big-data-that-is-more-sophisticated-than-s</a></li>
  </ul>