Imputation by regression in R Say I have below example data, where rows are observations and columns are variables, and NAs stand for missing values.
 1  2 NA  4  5 6 14 5  2
 6 13  7  1 11 4 NA 9  6
15 12  3 12 NA 8  3 7 12
 8  1 NA  7  8 9  4 6  1

I want to impute the missing values by regression (I know I can impute by means, but I need to see how regression performs). There is a CRAN package named 'Amelia' for imputation by regression, but it gives an error for above data saying that #observations is smaller than #variables. 'mi' package also gives an error. I can code myself, but I do not want to reinvent the wheel since I am sure there is already a package for that which would work faster than the one I write (Speed is important since I will run this imputation for thousands of variables and hundreds of observations with lots of missing values). So, does anybody know about a package which would impute the values above by regression? Thanks.
 A: Even though this thread is a bit old, I am sure some people are still trying to find a solution in this thread. Therefore I want to add an example how you could use the mice package for regression imputation:
library("mice")

# Example data
data <- data.frame(x1 = c(1, 6, 15, 8, 5, 1, 7, 4),
                   x2 = c(2, 13, 12, 1, 6, 6, 1, 2),
                   x3 = c(NA, 7, 3, NA, 1, 2, 7, 3),
                   x4 = c(4, 1, 12, 7, 12, 1, 6, 6),
                   x5 = c(5, 11, NA, 8, 8, 11, 5, 6),
                   x6 = c(6, 4, 8, 9, 3, 9, 6, 12),
                   x7 = c(14, NA, 3, 4, 12, 5, 10, 10),
                   x8 = c(5, 9, 7, 6, 12, 2, 6, 3),
                   x9 = c(2, 6, 12, 1, 2, 2, 7, 1))

# Deterministic regression imputation via mice
imp <- mice(data, method = "norm.predict", m = 1)

# Store data
data_imp <- complete(imp)

With a larger dataset, You could also add a stochastic error term to the imputed values with the "norm.nob" method:
# Stochastic regression imputation
imp <- mice(data, method = "norm.nob", m = 1)

You can find further information on regression imputation in the following two links:
Deterministic vs. stochastic regression imputation & examples in R
Flexible Imputation of Missing Data of Stef van Buuren, the author of mice
