RainbowStats™ · Command reference · Model discovery
Discover predictors and observation lags, interrogate nonlinear structure with a Random Forest, compare with OLS, and evaluate the selected specification on a reserved chronological test period.
D=DISCOVER_MODEL(LIST(Y,X1,X2,X3))
D=DISCOVER_MODEL(LIST(Y,X1,X2,X3),MIN_LAG:1,MAX_LAG:6,MAX_VARIABLES:2,SEED:42)
The first series is the dependent variable. Remaining series are candidate predictors. At least one predictor is required. The result is a D3 slideshow; assign it to a variable to inspect its extracts.
| Stage | Question | What to examine |
|---|---|---|
| 1. Genetic search | Which predictors and lags merit attention? | Selected specification, alternative candidates, validation performance |
| 2. Random Forest | Is there nonlinear structure? | Forest versus OLS, consolidated threshold regimes |
| 3. OLS | Can a simpler equation describe the relationship? | Coefficients, residuals, diagnostics; post-selection inference is exploratory |
| 4. Chronological test | Does it generalize? | Test RMSE, historical-mean baseline, test R² |
| 5. Forest compression | How much forest complexity is redundant? | Representative-tree fidelity, consolidated rules and regimes |
| Option | Use |
|---|---|
MIN_LAG:1 | Require at least one observation lag in the genetic search. Use when contemporaneous predictor values would not be available at forecast time. Added in the updated implementation. |
MAX_LAG:6 | Largest candidate observation lag. |
MAX_VARIABLES:2 | Maximum predictors selected. |
SEED:42 | Repeatable stochastic search. |
POPULATION, GENERATIONS, MAX_EVALUATIONS | Genetic-search breadth and computational budget. |
TREES, MAX_DEPTH, MIN_LEAF | Forest size and complexity. |
TRAIN_PCT, VALIDATION_PCT, PENALTY_PCT | Chronological sample allocation and predictor penalty. |
EXTRACT(D,slideshow)
EXTRACT(D,selected)
EXTRACT(D,test_rmse)
EXTRACT(D,test_baseline_rmse)
EXTRACT(D,test_r_squared)
EXTRACT(D,compression_chart)
The slideshow includes genetic search, leading candidates, forest-versus-OLS comparison, nonlinear regimes, regression and residual diagnostics, and the reserved test period. compression_chart displays representative-tree agreement with the fitted full forest. For forest-specific extracts, consult RANDOM_FOREST.
Representative trees are chosen to approximate the full forest. The compression chart measures the training-sample RMSE between the representative ensemble and the original forest, alongside the number of exact consolidated rules and broad threshold regimes. Lower compression RMSE means greater agreement with the original model—not necessarily lower future forecast error.
| Representative trees | GBP/EUR fidelity RMSE | Exact consolidated rules | Threshold regimes |
|---|---|---|---|
| 5 | 0.000432 | 199 | 16 |
| 10 | 0.000278 | 467 | 17 |
| 20 | 0.000157 | 924 | 17 |
| 50 | 0.000062 | 2,412 | 19 |
The number of broad regimes changes relatively little while detailed rules multiply. Regimes are descriptions of the fitted forest, not causal effects or statistically identified economic states. These figures are illustrative results from the linked GBP/EUR analysis, not fixed output of the command.
# Exchange-rate example: use only lagged predictors
g=ECB(EXR.D.GBP.EUR.SP00.A)
r=LOGDIFF(SERIES_SINCE(g,20200101))
a=LAG(r,1)
b=LAG(r,2)
m=DISCOVER_MODEL(LIST(r,a,b),MIN_LAG:1,MAX_LAG:6,MAX_VARIABLES:1,SEED:42)
EXTRACT(m,slideshow)
EXTRACT(m,selected)
EXTRACT(m,test_rmse)
EXTRACT(m,test_baseline_rmse)
EXTRACT(m,test_r_squared)
EXTRACT(m,compression_chart)
In the documented experiment, the model's chronological test RMSE was 0.002240, versus 0.002142 for the historical-mean baseline; test R² was −0.094. The discovered specification did not improve the baseline forecast.
# Monthly employment example
y=DIFF(SERIES_SINCE(PAYEMS,20000101))
a=LAG(DIFF(SERIES_SINCE(INDPRO,20000101)),1)
b=LAG(DIFF(SERIES_SINCE(TCU,20000101)),1)
c=LAG(DIFF(SERIES_SINCE(CPIAUCSL,20000101)),1)
d=LAG(DIFF(SERIES_SINCE(UNRATE,20000101)),1)
m=DISCOVER_MODEL(LIST(y,a,b,c,d),MIN_LAG:1,MAX_LAG:6,MAX_VARIABLES:3,SEED:42)
EXTRACT(m,slideshow)
EXTRACT(m,compression_chart)
The documented payroll experiment reported test RMSE of 457.90 thousand jobs, versus 277.03 thousand for the baseline. Historical revised macroeconomic data should not be mistaken for a point-in-time forecast backtest.
Model selection is not causal identification. Genetic search and Random Forest can reveal associations, but they do not establish causal relationships. OLS standard errors following adaptive selection are exploratory. A reserved test sample reduces—but does not eliminate—the risk of overfitting when researchers repeatedly revise their designs after seeing results.
Forecast accuracy is not trading profit. The output does not include a trading strategy, transaction costs, slippage, financing, or realized P&L. Good in-sample fidelity is not evidence of profitable trades.
Run the complete RainbowStats study · Why Bother? — AI and market efficiency · GENETIC_MODEL documentation · RANDOM_FOREST documentation