# Can Random Forest regression be conducted with a response variable containing <5 unique values?

I'm using Random Forests to determine the importance of numerous environmental predictor variables for predicting forest structural variables. One of the response variables only contains 5 unique values, and so this warning message is produced:

Warning messages:
1: In randomForest.default(m, y, ...) :
The response has five or fewer unique values.  Are you sure you want to do
regression?


My data is legitimate regression data, so can I ignore this warning? Is it still ok to perform regression when there are limited response values?

• Minimal requirement is that the values are on an interval scale (taking average has to make sense to evaluate the squared loss criterion in the splits) Apr 11 '18 at 6:51

## 1 Answer

You can still do it, it's a warning not an error. However, you might be looking for classification. People generally have more than 5 unique values when it comes to regression.

• The variable is 'density of oldgrowth trees'. There are only ever up to 5 trees in a site, and many sites have none. I think this still needs to be a regression.
– LvG
Apr 11 '18 at 6:55
• @LvG I'll leave it up to you it's a regression or not. But it sounds like 4.56 doesn't make sense. If this is the case, regression is not appropriate. You'll need to think and make a decision. I don't understand what density we have here. Apr 11 '18 at 6:57