# The p value for the random forest regression model

So I was asked by a reviewer to provide the "P-value" for my random forest regression model.

I tried to do some research on this, and only found methods to produce p values for each split condition (like in 'party' package), and p-values for variable importance (like in 'rfPermute' package). I find it hard to trust the p-values for variable importance since some very important variables have p-values of >0.9.

Any input on how to generate the general "p-value" for random forest (if there is one) would be appreciated.

• p-value of what? Commented Jun 6, 2017 at 19:16
• So I reported the "% Var explained" and the reviewer asked me to provide the p-value. Commented Jun 6, 2017 at 19:25
• @markwhite, I agree completely. It has always been my experience that you should not argue with reviewers, let alone try to educate them about stats as they will a) ignore you, b) reject the paper. Therefore it is much more easy to simply bootstrap on the raw data, and completely ignore what hypothetical distribution we are inferring about or whether the psudo R-square of an RF can be thought to come from anysuch distribution. But I digress. Commented Jun 6, 2017 at 19:50
• The digression is appreciated; in my opinion, the peer-review process is one of the biggest hurdles in advancing statistical methodologies; many applied researchers don't continue their statistical education after finishing graduate school. Commented Jun 6, 2017 at 19:52
• @MarkWhite: (obligatory snarky comment) some applied researchers appear to stop their statistical education after their undergraduate years and spend the rest of their academic life actively forgetting what they learned. All this while loudly proclaiming that they don't need no stinkin' statisticians for their applications or studies. Commented Jun 6, 2017 at 20:05

When in doubt, simulate or permute.

In this specific case:

1. Randomly permute your dependent variable.
2. Fit a random forest.
3. Note the % variance explained.

Do steps 1-3 multiple times, say 1,000-10,000 times. You now have an empirical distribution of % variance explained through a random forest, under the null hypothesis of no relationship between your independent and dependent variable.

Insert the actual % variance explained in your original model into this distribution, and note which proportion of permutation-based "null" % variance explained values exceeds this true value. This proportion is your p value.

If you did the same thing in a standard linear regression model, you would (asymptotically) get the p value for the classical F test for variance explained.

As others write, your reviewer does not sound overly statistically savvy, but the approach I'm outlining above makes sense and should satisfy him. It's better than getting into an anonymous argument over the statistical competence of a reviewer, anyway.

• What would be the steps for the simulation approach? Commented Jul 11, 2019 at 8:16
• @Digio: I'd go with the permutation approach in this case. Commented Jul 11, 2019 at 8:17
• Stephan - I still have 1 question on this method. How would you estimate the % variance explained per predictor from the RF importance score? Commented Jul 26, 2019 at 19:49
• i would not calculate % variance explained from the RF importance score. I would assess % variance explained from the permutation analysis (by noting residual variance from the full model, and variance explained in a model with one predictor permuted), then define this as the variable's importance. Alternatively, use any other reasonable KPI, like Gini impurity reduction. Commented Jul 27, 2019 at 17:34
• I see, thanks. By the way, by "RF importance score" I did mean Gini impurity or information gain. Commented Jul 28, 2019 at 18:11