0
votes

I'm trying to construct a random forest for ecological data but keep getting the error

"no applicable method for 'importance' applied to an object of class "logical".

The code I have is:

fit2 <- randomForest(sv ~ salinity + temp + Depthbin +  cdistance + oxygen + 
                      type + diel, data=d.omit, importance(TRUE), ntree=2000)

The variable of interest (sv) is continuous, so I'm not sure if that impacts things. When I remove the importance(TRUE) portion of the code, I can run the random forest but the IncNodePurity values I obtain are ridiculously high (some values over 100,000!!). I'm hoping the importance(TRUE) addition will fix that, but if not, does anyone know of a better way to examine the importance of each variable?

1
It is easier to help if you provide a reproducible example - MrFlick
Great advice MrFlick. Will make sure to do next time. - vbar

1 Answers

1
votes

try this instead:

fit2 <- randomForest(sv ~ salinity + temp + Depthbin + cdistance + oxygen + type + diel, data=d.omit, importance=TRUE, ntree=2000)

With importance(fit2) you should be able to see the variable importance.