Skip to main content

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.

Macro by MarkMacro by Mark
  • Home
Loading…
Loading…
← Models
MacroConceptsPolicyModels

Random forest Model

Bagged decision-tree ensemble for nonlinear macro prediction and feature-importance diagnostics.

OverviewGraphMathReferences

Graph workspace

OOB error convergence curve with feature importance bar chart

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.

Chart axis metadata
xNumber of treescount · 1 to 500yOOB Mean Squared Errorsquared units of y · Depends on response scale; typical macro: 0.5 to 5.0
Out-of-bag error as trees are added static chart preview showing Out-of-bag error, Error at the full forest
Permutation importance by predictor static chart preview showing Series 1
xNumber of treescount · 1 to 500yOOB Mean Squared Errorsquared units of y · Depends on response scale; typical macro: 0.5 to 5.0

Current results

OOB MSE at selected B

Explain: OOB MSE at selected B
OOB(B)\text{OOB}(B)OOB(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

Explain: Top predictor importance
max⁡jVIMj\max_j \text{VIM}_jmaxj​VIMj​

Permutation importance of the most influential of the eight predictors, signal or noise. In this toy y=2sin⁡(X1)+X22−1+0.8X3y = 2 \sin(X_1) + X_2^2 - 1 + 0.8 X_3y=2sin(X1​)+X22​−1+0.8X3​; the depth-4 trees capture X1X_1X1​'s sine most easily, so X1X_1X1​ usually dominates. A noise predictor on top means the forest is fitting noise.

2.35

MSE increase

Noise predictor importance

Explain: Noise predictor importance
mean(VIMj:j∈noise)\text{mean}(\text{VIM}_j : j \in \text{noise})mean(VIMj​:j∈noise)

Average importance of the five irrelevant predictors (X4X_4X4​ through X8X_8X8​), 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

Explain: OOB vs. linear benchmark ratio
OOB(B)  /  MSEOLS\text{OOB}(B) \;/\; \text{MSE}_{\text{OLS}}OOB(B)/MSEOLS​

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

Controls

Mostly settled
Explain: How many trees to grow

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.

Trees stay varied
Explain: Variables tried at each split

Features per split (mtry): 3

How many variables each split may choose from; fewer makes trees more different but weaker.

A low mmm 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 mmm 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 m=3m = 3m=3.

Middling depth
Explain: Smallest group trees allow

Min node size: 5

The fewest data points allowed in a tree's final group; smaller settings grow deeper trees.

Very small nmin⁡n_{\min}nmin​ lowers the converged OOB error (deeper trees capture more signal) but may slow convergence. Large nmin⁡n_{\min}nmin​ raises the asymptote because trees underfit.

1
Explain: How noisy the data is

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.

200
Explain: How much training data

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.

Keep going

Read next

Continue with a related concept, model, or example.

Theory model

IS-LM Model

a well-connected theoretical model two steps from here

New angle: theoretical model →
Macro by Mark
Help
Privacy PolicyTerms of UseEthics and Compliance

© 2026 Mark Jayson Nation LLC