RainbowStats Command Reference
BEST_BIC_REGRESSION
Build a parsimonious regression by adding explanatory variables only while they improve the Bayesian Information Criterion. The second argument is a maximum—not a required number of variables.
Syntax
BEST_BIC_REGRESSION(DataSeriesList, MaximumVariables)| Argument | Description |
|---|---|
DataSeriesList |
A list of aligned series. The first series is the dependent variable; every remaining series is a candidate explanatory variable. |
MaximumVariables |
The largest number of explanatory variables the forward search may select. The returned model can contain fewer variables when another addition would not lower BIC. |
The command returns a standard RainbowStats regression containing the selected variables, coefficients, standard errors, goodness-of-fit measures, and residual diagnostics.
How the search works
RainbowStats performs a forward search. At each stage it evaluates every unused candidate as the next addition and retains the one producing the largest improvement in BIC.
- Begin with the candidate having the highest absolute correlation with the dependent variable.
- Fit the initial ordinary least-squares regression with a constant.
- Add each remaining candidate in turn and calculate the resulting BIC.
- Keep the best addition only if it lowers BIC; otherwise stop.
The process continues until no remaining candidate improves BIC or the model reaches
MaximumVariables. The current implementation therefore selects at least
one explanatory variable and at most the requested maximum.
Here, n is the number of observations, RSS is the residual sum of squares, and k is the number of estimated regression parameters, including the constant. Lower BIC is preferred.
Example
L=SAME_DATE_RANGE(LIST(UNRATE,DGS10,TCU,GDP,CORESTICKM159SFRBATL))
LD=LOGDIFF(L)
Exact=BEST_REGRESSION(LD,2)
Parsimonious=BEST_BIC_REGRESSION(LD,4)
UNRATE is first in the list, so its log difference is the dependent
variable. The remaining transformed series are candidate explanatory variables.
BEST_BIC_REGRESSION may select one, two, three, or four variables,
depending on whether each successive addition lowers BIC.
Running both commands provides a useful comparison. BEST_REGRESSION
returns the best-fitting model containing exactly two variables. The BIC command
searches for a more parsimonious specification, subject to a four-variable ceiling.
Comparison with BEST_REGRESSION
| Feature | BEST_REGRESSION |
BEST_BIC_REGRESSION |
|---|---|---|
| Search method | Exhaustive best-subset search | Forward selection |
| Variable count | Exactly N | From 1 through MaximumVariables |
| Selection criterion | Lowest RSS for fixed model size | Lowest BIC at each forward step |
| Search cost | Can grow combinatorially | Usually much faster for large candidate sets |
| Guarantee | Best RSS among all models of exactly that size | Best forward addition at each step; not necessarily the global minimum-BIC subset |
Interpretation and residuals
BIC balances fit against complexity, but the selected model still requires inspection. Examine coefficient signs, stability, residual autocorrelation, unusual observations, and residual behavior over time. A compact model can still be misspecified.
Forward selection is path-dependent. A variable excluded early may become valuable in combination with another excluded variable. For important applications, compare the result with theory-driven specifications and, when practical, an exhaustive search.
Good practice
- Transform and align all series consistently before searching.
- Use a focused candidate set grounded in economic reasoning.
- Treat
MaximumVariablesas a sensible ceiling rather than a target. - Inspect the residuals and compare the selected model across different sample periods.
- Test predictive performance on observations not used during selection whenever possible.
- Report that the specification was selected by a search procedure.