Cookies on Macro by Mark.We use essential cookies for sign-in, locale, and security. With your permission, we also use optional cookies for preferences, for analytics, and for advertising measurement with the Meta (Facebook) Pixel. Read our cookie policy.
Bagged decision-tree ensemble for nonlinear macro prediction and feature-importance diagnostics.
Graph workspace
The OOB error convergence plot is the canonical random forest diagnostic. It shows generalization error stabilizing as the number of trees grows, directly illustrating the variance-reduction mechanism. The companion feature importance bar chart reveals which predictors drive the ensemble. Together they answer the two practitioner questions: how many trees are enough, and which variables matter.
OOB MSE at selected B
Out-of-bag mean squared error using only the first B trees. Compare against the asymptotic level to judge whether more trees are needed.
2.63
squared units
Top predictor importance
Permutation importance of the most influential of the eight predictors, signal or noise. In this toy ; the depth-4 trees capture 's sine most easily, so usually dominates. A noise predictor on top means the forest is fitting noise.
2.35
MSE increase
Noise predictor importance
Average importance of the five irrelevant predictors ( through ), each clipped at zero. Should be near zero; positive values are chance fits to noise, which grow in small noisy samples.
0.0179
MSE increase
OOB vs. linear benchmark ratio
Ratio of forest OOB error to OLS in-sample MSE. Values below 1.0 indicate the forest captures nonlinear structure that OLS misses.
0.8813
ratio
Number of trees: 200
How many trees are in the forest; more trees steady the answer, with shrinking gains.
The OOB convergence curve extends further to the right. Beyond the stabilization point, additional trees add negligible improvement.
Features per split (mtry): 3
How many variables each split may choose from; fewer makes trees more different but weaker.
A low decorrelates the trees but weakens each one, so the convergence curve starts higher. In this toy, with three signal predictors among eight and shallow trees, the stronger trees win: OOB error falls as rises from 1 to 7 (about 3.6 to 2.2 at the defaults) and ends a little higher at 8, bagged trees, still well below .
Min node size: 5
The fewest data points allowed in a tree's final group; smaller settings grow deeper trees.
Very small lowers the converged OOB error (deeper trees capture more signal) but may slow convergence. Large raises the asymptote because trees underfit.
How much random noise is added to the simulated data; more noise means unavoidably larger errors.
Higher noise shifts the entire OOB curve upward. The gap between the converged OOB error and the irreducible noise level widens, showing remaining model error.
How many observations the forest learns from; more data makes trees and error estimates better.
More data tends to lower the converged OOB error (from 100 to 300 observations it falls from about 3.8 to 2.2), though not at every step on this one fixed sample: at 500 it is back near 2.5. The importance bar chart also stabilizes: relevant predictors separate more clearly from noise predictors.