title: Data imputation using R
body: <p>I need to do multiple imputation to a data set which is similar to the following toy data set.</p>
  <pre><code>x1=rbinom(20,1,0.5)
  x2=rnorm(20,100,2)
  x2=x2/max(x2)
  x3=rbinom(20,3,0.4)
  x4=rnorm(20,0,0.5)
  
  data=data.frame(x1,x2,x3,x4)
  data[1,2]=NA
  data[10,2]=NA
  data[15,2]=NA
  data[2,1]=NA
  data[12,1]=NA
  data[12,3]=NA
  data[19,3]=NA
  data[20,3]=NA
  
  &gt; data
     x1        x2 x3           x4
  1   0        NA  2  0.103982689
  2  NA 0.9599301  1 -0.153152527
  3   1 0.9563003  0 -0.783492651
  4   0 0.9974261  1  0.325931603
  5   1 0.9515747  3 -0.769568378
  6   1 0.9431853  0  0.336488307
  7   0 0.9637072  1  0.383011575
  8   0 0.9937089  0 -0.575941420
  9   1 0.9357041  3 -0.648096345
  10  0        NA  3  0.213382349
  11  0 0.9454354  1  0.111094020
  12 NA 0.9330617 NA -0.256448985
  </code></pre>
  <p>where x1 is a binary variable, x2 is a variables between 0 and 1 and x3 is a ordinal level variable. I did the imputation using <code>amelia</code> function from the <code>Amelia</code> package. But it seems that the imputed values are not within the desired range.</p>
  <pre><code>require(Amelia)
  
  imp=amelia(data,m=2)
  imp1=imp$imputations[[1]]
  imp2=imp$imputations[[2]]
  </code></pre>
  <p>For an example, I got values greater than 1 for x1 and x2. Also the values for x1 and x3 does not preserve the categorical nature of the data.</p>
  <p>Is it possible to do the imputation for a data set that involves categorical variables (including binary and ordinal variables) and continuous variables within a certain range using R?</p>