0

Trying to run R's party package's cforest and doing something basically wrong.

Here's my example data:

set.seed(1)
pred.mat <- matrix(rnorm(100*10),nrow=100)
colnames(pred.mat) <- paste("feature",1:10,sep="")
df <- cbind(data.frame(y=round(runif(100))),pred.mat)

Trying to run cforest:

library(party)
crf.fit <- cforest(y~.,data=df)

I get this error:

Error in mget(plabels[hasSubclass], env) : invalid first argument

What am I doing wrong?

dan
  • 6,048
  • 10
  • 57
  • 125
  • 2
    can't reproduce - it works for me (party 1.0-25) – dww Oct 11 '16 at 01:54
  • Can you test and confirm getting this error after updating R and party? If not, I'll probably vote to close as unreproducible. – dww Oct 11 '16 at 02:23

1 Answers1

0

Your code works without problems for me in current versions of R and party. Moreover, the offending piece of code mget(plabels[hasSubclass], env) is not in the party package but it comes from the basic methods package which is used by party. My suspicion is that your installation is out of sync in some way, e.g., you did not re-install the packages in your library after upgrading your R version or something similar. So you could try to run update.packages(..., checkBuilt = TRUE) or something along those lines to reinstall the packages in your libraries. Hopefully, this should fix the issue above.

Another comment regarding your artificial example: The variable y is a numeric 0/1 dummy variable but I assume you really want to do classification rather than regression. So I would recommend to do

df$y <- factor(df$y)

prior to fitting the cforest(). This will assure that the appropriate test statistics are used during the learning of the tree - and the correct predictions are produced etc.

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49