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)
ArgumentDescription
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.

  1. Begin with the candidate having the highest absolute correlation with the dependent variable.
  2. Fit the initial ordinary least-squares regression with a constant.
  3. Add each remaining candidate in turn and calculate the resulting BIC.
  4. 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.

BIC = n ln(RSS / n) + k ln(n)

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.

Why BIC? Adding a variable normally reduces residual error. BIC asks whether that improvement is large enough to justify the additional parameter. This favors models that explain the data without unnecessary complexity.

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.

Prediction is not causation. Do not use BIC selection to decide which variables belong in a causal regression. A mediator, collider, or post-treatment variable can improve BIC while biasing the treatment-effect estimate. Select causal controls from the research design and economic reasoning, not from goodness of fit alone.

Good practice