I am doing some exploratory data analysis in the Heritage Health Prize , and have come across a weird error using R's caret package. In the dataset, I've created a dataframe counting how many times a patient (by MemberID) has visited a specific primary care physician (denoted by a number) in year 1 insurance claims. Let's say there are 57 such primary care physicians, and so our dataframe looks like this:
> head(cbind(right.a[,1],right.a[,107:111]))
MemberID 2448 91972 20893 30870 13281
1 24027523 0 0 0 0 0
2 98321677 2 0 0 3 0
3 33896267 0 1 0 0 1
4 5481382 0 0 2 0 0
5 69908341 0 0 0 0 17
6 8169352 0 0 0 0 0
As you can see, this is a very sparse matrix.
Our outcome here is the number of days they spent in hospital the following year in year 2 (DaysInHospital). I'm using year 2 insurance claims and year 3 days in hospital as a validation set.
I'm using rfe to do some recursive feature selection, and I'm getting the following error:
> subsets <- seq(12,57,by = 3)
> lmProfile <- rfe(right.a[,c(107:164)],
log1p(right.a$DaysInHospital),
right.b[,c(107:164)],
log1p(right.b$DaysInHospital),
sizes=subsets,
metric="RMSE",
maximize="FALSE",
rfeControl=ctrl)
.
(snip)
.
External resampling iter: 10
Computing importance
Fitting subset size: 58
Computing importance
Computing importance
Error in y$pred : $ operator is invalid for atomic vectors
Am I missing something here?
rfeIter()(which expects train X and y and test X and y) instead ofrfe()? Areright.aandright.bdata.frame or matrix objects? – chl♦ Jun 26 '11 at 21:12rfeIter(), although when I run it again I get a new error:Error in '[.data.frame'(x, , retained, drop = FALSE) : undefined columns selected. Bothright.aandright.bare data.frames. – sylowtheorems Jun 27 '11 at 0:01summaryFunctionintrainControlis looking for a column (like class probabilities) that isn't there. Often this can be fixed by usingclassProbs =TRUEargument. – Zach Oct 6 '11 at 20:33