<p>Following the jackknife method highlighted in this <a href="https://www.jmlr.org/papers/volume15/wager14a/wager14a.pdf" rel="nofollow noreferrer">paper</a> to obtain the standard error, you can use an implementation in the package <code>ranger</code> :</p>
<pre><code>library(ranger)
library(mlbench)
data(BostonHousing)

mdl = ranger(medv ~ .,data=BostonHousing[1:400,],keep.inbag = TRUE)

pred = predict(mdl,BostonHousing[401:nrow(BostonHousing),],type=&quot;se&quot;)

 head(cbind(pred$predictions,pred$se ))
          [,1]     [,2]
[1,] 10.673356 1.107839
[2,] 11.390374 1.102217
[3,] 12.760511 1.126945
[4,] 10.458128 1.100246
[5,] 10.720076 1.084376
[6,]  9.914648 1.102000
</code></pre>
<p>The confidence interval can be estimated as 1.96*se. There is also a new package forestError available that can work on randomForest objects:</p>
<pre><code>library(randomForest)
library(forestError)
mdl = randomForest(medv ~ .,data=BostonHousing[1:400,],keep.inbag=TRUE)

err = quantForestError(mdl,BostonHousing[1:400,],BostonHousing[401:nrow(BostonHousing),])

head(err$estimates)
       pred     mspe       bias lower_0.05 upper_0.05
1 10.649734 15.70943 -1.5336411   2.935949   12.59486
2 11.611078 15.16339 -1.4436056   3.897293   13.55621
3 12.603938 20.92701 -0.9590869   4.890153   22.32699
4 10.650549 12.42555 -1.4188440   3.941648   12.49029
5 10.414707 29.08155 -1.1438267   2.700922   31.42272
6  9.720305 19.63286 -1.3469671   2.006520   16.43220
</code></pre>
<p>You can refer to this <a href="https://arxiv.org/pdf/1912.07435.pdf" rel="nofollow noreferrer">paper</a> for the actual method used,</p>
how to calculate the confidence level for random forest regression model in R
<p>I'm using <code>randomForest</code> package in R, for the purpose of predicting the distances between proteins (regression model in RF) &quot;for a homology modeling purposes&quot; and I obtained quite good results. However, I need to have a confidence level to rank my predicted values and filter out the bad models, so I wonder if there is any possibility to calculate such confidence level, or any other way of measuring the certainty of the predictions?
any suggestions or recommendations is highly appreciated</p>