On Sun, 29 Apr 2012, Abigail Clifton wrote:
> Hi,
>
> This is my code (my data is attached):
>
> library(languageR)
> library(rms)
> library(party)
> OLDDATA <-
read.csv("/Users/Abigail/Documents/OldData250412.csv")
> OLDDATA$YD <- factor(OLDDATA$YD, label=c("Yes",
"No"))?
> OLDDATA$ND <- factor(OLDDATA$ND, label=c("Yes",
"No"))?
> attach(OLDDATA)
> defaults <- cbind(YD, ND)
I'm not really sure what you are trying to do here. It seems that you have
a bivariate response, where each of the responses is a binary factor. If
so, you have to specify this as
cforest(YD + ND ~ LN + LV + ..., ...)
because cbind(YD, ND) loses the factor property of the data and hence
leades to the error below.
But it may also be conceivable that YD/ND count the number of
successes/failures, similar to a binary GLM. If so, you need to construct
a binary factor response y = factor(c("Success", "Failure",
"Success",
"Failure", ...)) with the corresponding w = c(nsuc1, nfail1, nsuc2,
nfail2, ....)) and then call cforest(y ~ ..., weights = w).
hth,
Z
> set.seed(47)
> data.controls <- cforest_unbiased(ntree=500, mtry=3)
> data.cforest <- cforest(defaults~LN+LV+LT+RV+MR+TL+DIA+CB, data =
OLDDATA,
> controls=data.controls)
> data.cforest.varimp <- varimp(data.cforest, conditional = TRUE)
> barplot(sort(data.cforest.varimp))
>
>
>
> And this is the error I get:
>
>> data.cforest <- cforest(defaults~LN+LV+LT+RV+MR+TL+DIA+CB, data =
OLDDATA,
>> controls=data.controls)
> Error in xt[[j]][nas, drop = FALSE] <- 0 :?
> ? (subscript) logical subscript too long
>
>
> Basically I want to reduce the number of factors I've got (9) to fewer,
say
> the 5 most important ones? Hence I imagined Random Forests would be a good
> idea. However I get the error given above. Is it possible to smarten up the
> code and correct the error? Or has anybody got other ideas of how I can
> reduce the amount of factors I have?
>
> Kind regards,
>
>
> AJC
> ______________________________________________
> 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.
>