QUANTILE_RANDOM_FOREST extends the RainbowStats regression forest from conditional-mean prediction to estimation of a conditional distribution. It reports lower, median and upper conditional quantiles while retaining the ordinary forest diagnostics.
QUANTILE_RANDOM_FOREST(LIST(Y,X1,X2,...),TREES:500,MAX_DEPTH:12,MIN_LEAF:5,MTRY:2,SEED:12345,LOWER:0.05,MEDIAN:0.50,UPPER:0.95)
| Argument | Description | Default |
|---|---|---|
| LIST(Y,X1,...) | Y is the dependent series. X1...Xp are predictor series. | Required |
| TREES | Number of bootstrap regression trees. | 500 |
| MAX_DEPTH | Maximum depth of each tree. | 12 |
| MIN_LEAF | Minimum observations allowed in a terminal leaf. | 5 |
| MTRY | Number of randomly selected predictors considered at each split. | max(1,p/3) |
| SEED | Random seed. | 12345 |
| LOWER | Lower conditional quantile, between 0 and 1. | 0.05 |
| MEDIAN | Middle conditional quantile. | 0.50 |
| UPPER | Upper conditional quantile, between 0 and 1. | 0.95 |
The quantiles must satisfy 0 < LOWER < MEDIAN < UPPER < 1.
The operator grows the same bootstrap CART regression forest used by RANDOM_FOREST, but retains the training observations associated with terminal leaves. For a query observation, each tree identifies its terminal leaf. Observations sharing that leaf receive equal within-tree weight; weights are then aggregated across trees to form a conditional empirical distribution of Y. Requested quantiles are read from that weighted distribution.
Bootstrap multiplicity is retained: if an observation occurs more than once in a bootstrap leaf, its repeated membership contributes correspondingly to that tree's conditional distribution.
Use EXTRACT(qrf,extract_name) or its shorthand EX(qrf,extract_name).
| Extract | Result |
|---|---|
summary / model | Forest settings, requested quantiles and training/OOB diagnostics. |
lower / q_lower | Lower conditional-quantile series. |
median / q50 | Middle conditional-quantile series (median with the default MEDIAN:0.50). |
upper / q_upper | Upper conditional-quantile series. |
quantiles | DataList containing lower, middle and upper conditional-quantile series. |
fitted / predicted | Forest conditional-mean fitted-value series. |
residuals | Actual minus mean fitted series. |
oob / oob_prediction | Out-of-bag mean prediction series. |
importance | Named and sorted OOB permutation-importance table. |
importance_values | Raw OOB permutation-importance array in original predictor order. |
benchmark | Comparison of forest and OLS fit and validation diagnostics. |
ols_summary / ols_inference | OLS benchmark coefficients and inference table. |
ols_fitted | OLS benchmark fitted-value series. |
ols_oos / ols_loocv | OLS leave-one-out prediction series. |
ols / ols_regression / regression | OLS benchmark regression operator, or its inference table when the operator is unavailable. |
equation | HTML explanation of the exact forest mean equation: the average of tree predictions expressed as terminal-region indicators. |
rules | Original table of up to 50 terminal leaf rules, ranked by influence; rules from different trees can overlap or repeat. |
consolidate_rules / consolidated_rules | Full table grouping identical terminal regions across trees. Includes exact conditions, supporting trees, leaf predictions, combined weight, active contribution, matching aligned rows and bootstrap counts. |
rules_charts / rule_charts | Slideshow containing the consolidated rule table and one contribution line chart per nonzero rule on the aligned observations. |
rules_bar_chart / bar_chart / bar_charts | Single horizontal bar chart of mean rule contributions. Shows the top 30 by absolute contribution, with remaining contributions grouped into Other positive rules and Other negative rules. |
predictor_bar_charts | Slideshow with one horizontal rule-contribution chart per predictor, followed by its matching rule-detail table. Shows up to 30 nonzero rules per predictor, selected by absolute mean contribution. |
regimes | Table grouping nearby split thresholds for each predictor, with threshold ranges, tree support, split support and mean right-minus-left subtree prediction contrast. |
regimes_bar_chart / regimes_bar_charts | Slideshow with one horizontal threshold-regime chart per predictor, followed by its matching detail table. Shows up to 30 nonzero clusters per predictor, selected by tree support and then split support. |
actual_vs_fitted | Actual-versus-mean-fitted chart. |
slideshow | Model slideshow with diagnostics and the original rule/regime tables and requested quantiles. Use the chart extracts separately for contribution and regime slideshows. |
consolidate_rules combines regions with identical full-precision bounds after simplifying repeated bounds on a predictor. Nearby but different thresholds remain separate. Consolidation summarizes the fitted forest without changing its predictions. The full table retains zero-contribution rules; contribution charts omit rules whose contribution is zero throughout the aligned sample.
For a consolidated rule, its active contribution is the sum of its member leaf predictions divided by the total number of trees. Its line chart shows that contribution when all rule conditions hold and zero otherwise. Contributions from all consolidated rules sum to the forest mean fitted value at each observation. Its bar height is the active contribution multiplied by the fraction of aligned observations matching the rule. All bars in rules_bar_chart, including the Other bars, sum to the mean fitted prediction.
Labels such as R1 identify rules in the full consolidated table. Predictor charts shorten the displayed bounds; the next slide gives full conditions and exact thresholds for the displayed rules. A multivariate rule appears on each predictor chart whose predictor it constrains. These charts show the full conditional rule contribution, so contributions must not be summed across predictor charts. Remaining contributions are reported in subtitles rather than Other bars.
regimes groups nearby split thresholds within 2.5% of a predictor's observed range around a running weighted center. Labels such as G1 identify clusters in the full regime list. Chart ranges describe clusters of split locations, not disjoint intervals of predictor values. Bars show the observation-weighted mean right-minus-left subtree prediction contrast. Positive means the higher side predicts a higher target within the tree's other conditions; negative means a lower target. Supporting-tree counts show how widely the split cluster appears in the forest; a tree may support several clusters.
Quantile forest: equation, rule and regime extracts explain the conditional-mean forest. They do not decompose the lower, middle or upper quantiles. Use lower, median, upper and quantiles for conditional-quantile estimates.
u=DIFF(SERIES_SINCE(UNRATE,20000101)) p=LOGDIFF(SERIES_SINCE(PAYEMS,20000101)) c=LOGDIFF(SERIES_SINCE(CPIAUCSL,20000101)) i=LOGDIFF(SERIES_SINCE(INDPRO,20000101)) qrf=QUANTILE_RANDOM_FOREST(LIST(u,p,c,i),TREES:500,MAX_DEPTH:12,MIN_LEAF:5,MTRY:1,SEED:12345,LOWER:0.05,MEDIAN:0.50,UPPER:0.95) EXTRACT(qrf,summary) EXTRACT(qrf,quantiles) EXTRACT(qrf,importance) EXTRACT(qrf,slideshow)
An ordinary random forest estimates the conditional mean. A quantile forest also describes how the conditional distribution changes. A widening Q05-Q95 range indicates increased conditional uncertainty or tail risk even when the conditional mean changes little. This is useful for financial stress, market-liquidity and other applications where the tails of the distribution are economically important.
EX(qrf,equation) EX(qrf,rules) EX(qrf,consolidate_rules) EX(qrf,rules_charts) EX(qrf,rules_bar_chart) EX(qrf,predictor_bar_charts) EX(qrf,regimes) EX(qrf,regimes_bar_chart)