I'm copying the package maintainer who can probably give a more definite
answer. I'm getting the same error on your data. I can get a subset of your
data to run, eg:
d.imp <- mice(d[,c(1:2, 5:6)]) works, but
d.imp <- mice(d[,c(3:4, 7:8)]) fails.
That suggests to me that the problem is with your data. There are some very high
correlations between variables. Looking at pairwise complete observations, C1
has correlations of .998, .999, and .998 with C2, C3, and C4 while M1 has
correlations of .999, .999, and .999 with M2, M3, and M4. The correlations
between the C variables and the M variables are also high (consistently greater
than .80). You really have only two variables C and M. This is probably the
reason function mice() is failing, but the error message could be more
informative. Since you are only imputing single values, you might be better off
with simpler imputation methods. Package VIM has a number of options of which
nearest neighbor and hot deck might work well with your data.
-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Jeremy Miles
Sent: Thursday, September 11, 2014 7:49 PM
To: r-help
Subject: [R] mice - undefined columns selected
I've got a problem with the mice package that I don't understand.
Here's the code:
library(mice)
d <-
read.csv("https://dl.dropboxusercontent.com/u/24381951/employment.csv",
as.is=TRUE, row.names=1)d.imp <- mice(data=d, m=1)
Result is:
Error in `[.data.frame`(data, , jj) : undefined columns selected
I hope I'm doing something foolish,
thanks,
Jeremy
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.