Estimate robust median relationships as a linear program, impose economic
restrictions directly on coefficients, and test whether those restrictions
hold only within a dated policy or economic regime.
Least absolute deviationsMedian regressionCoefficient constraintsDated regime effectsPrimal and dualObservation shadow prices
The first series in LIST is the dependent variable. Every
remaining series is a predictor. RainbowStats aligns the dates and includes
an intercept automatically.
What it estimates
Ordinary least squares minimizes squared errors and therefore gives large
residuals disproportionate influence. LP_REGRESSION minimizes
absolute errors. At the default quantile of 0.50, it estimates the conditional
median of the dependent variable.
minimize Σ |yi − xi′β|
Median regression is especially useful when a series contains shocks,
heavy tails, unequal variance, or isolated observations that should not
dominate the fitted relationship.
Why this is a linear program
Each residual is split into nonnegative positive and negative components.
Each unrestricted coefficient is similarly written as the difference of
two nonnegative variables.
This estimates the median quarterly relationship between year-over-year
inflation, unemployment, and the federal funds rate. The command names
supplied by SET_NAME also become the coefficient names used
in later constraint equations.
A coefficient is an estimated conditional association, not automatically a
causal effect. A positive policy-rate coefficient may reflect the Federal
Reserve raising rates in response to inflation rather than rates causing inflation.
The inequality restricts the unemployment coefficient over the entire
sample. Because linear programs use closed feasible regions,
< and > are interpreted as ≤ and ≥.
If the unrestricted coefficient is positive, the restricted optimum will
often place it exactly at zero. A coefficient on its boundary is evidence
that the restriction is binding—not that the data independently estimated
an exact zero.
A period equation does not constrain the full-sample coefficient. It adds
a regime interaction that is active only from the start date through the
end date, both inclusive.
period coefficient = base coefficient + period adjustment
Outside the interval, the base coefficient applies. Inside the interval,
the effective coefficient includes the estimated adjustment and must
satisfy the stated restriction.
Reading a period-constrained result
Reported row
Interpretation
Illustrative value
Unemployment
Estimated unemployment coefficient outside the dated regime.
+0.032378
Unemployment_20200101_20211231_Adjustment
Change applied only during the specified period.
−0.032378
Unemployment_20200101_20211231_Effective
Base plus adjustment: the coefficient operating during the period.
0
In this illustration, the period adjustment exactly offsets the positive
base estimate. The COVID-period restriction is binding while the relationship
outside the period remains free to be positive.
Primal and dual methodology
For quantile τ and observation weights wi, the primal model is:
minimize Σwi[τui+ + (1−τ)ui−]
subject to Xβ + u+ − u− = y
For an unconstrained coefficient model, the exact dual is:
maximize y′a
subject to X′a = 0, (τ−1)wi ≤ ai ≤ τwi
Equality of the primal and dual objectives provides a numerical
strong-duality check on the solution.
Slideshow panels
Panel
What it shows
Model
Status, quantile, dimensions, objective values, duality gap, and mean absolute error.
Coefficients
Base estimates plus period adjustments and effective period coefficients.
Fit
Actual, fitted, and residual values for aligned observations.
Shadow
Observation-level dual sensitivity for an unconstrained model.
Tableau
Primal decision variables, equations, activities, slack, and binding status.
Dual
The explicit dual LP when the simple unconstrained dual applies.
Equations
The objective and generated observation, coefficient, and period equations.
Where it is useful
Estimate macroeconomic relationships without allowing crisis outliers to dominate squared-error loss.
Impose sign or magnitude restrictions suggested by economic theory.
Test whether a restriction applies only during COVID, zero-rate policy, tightening, recession, or another dated regime.
Compare an unrestricted empirical relationship with a theory-constrained alternative.
Inspect which observations have the greatest local influence through the dual shadow prices.
Period-model safeguards
Dates use integer YYYYMMDD format.
The start and end dates are inclusive.
At least two aligned observations must exist inside the period.
At least two aligned observations must remain outside the period.
Multiple restrictions may use the exact same interval.
Partially overlapping intervals are not supported in the initial implementation.
A short regime can produce an unstable adjustment even when the LP has a
mathematically valid optimum. Economic interpretation still requires an
adequate number of observations and meaningful variation within the period.
Interpretation and limitations
Issue
Guidance
Not OLS
The objective is absolute or quantile loss. OLS standard errors, t-statistics, and R² do not carry over automatically.
No automatic causality
Contemporaneous macroeconomic coefficients often combine behavior, policy reactions, expectations, and feedback.
Scaling
Rescale very large or very small predictors when numerical magnitudes differ substantially.
Collinearity
Highly related predictors can make individual coefficient decompositions unstable or non-unique.
Binding restrictions
A coefficient at a boundary reflects the imposed feasible region and should be identified as constrained.
Regime choice
Date intervals should follow a defensible event or hypothesis, not repeated searching for a preferred result.
LP_REGRESSION estimates a constrained statistical relationship.
It does not allocate capital or maximize investment returns. Use the
RainbowStats linear-programming model builder when the variables themselves
represent allocations, production, financing, or other decisions.