Flesaker: forecasting under a bound

One diagram, computed live: forecast log(y) with laplace, map the forecast back through exp, and no probability ever lands below zero. Discuss.

Plain laplace forecasts in the series' own units. On a positive series that drifts toward zero, its band can cross zero. flesaker moves the problem to xt = log(yt − b), where the bound is gone and noise proportional to the level becomes constant. laplace forecasts there, and the exact change of variables carries the forecast back up: every quantile is b + exp of a quantile downstairs, so it stays above the bound and keeps the skew. The diagram commutes:

yt > b (bounded) xt (unbounded) skewed band above b laplace's band in x x = log(y − b) forecast (laplace) ŷ = b + exp(x̂) forecast (bounded)

upstairs: positive series y, with flesaker's band and 8-step fan (grey: plain laplace)

 

downstairs: the same points as x = log(y), where laplace forecasts

Every hundred steps the level falls toward zero, then recovers; switch the cycle off to hold it at 0.2. Plain laplace (grey) keeps a roughly symmetric band and puts probability below zero, shaded red. flesaker's band narrows as the level falls and never crosses the line. Downstairs the same points look ordinary, because a falling level is just a shift in log units. The orange fan upstairs is the image of the fan downstairs under b + exp. This is the JavaScript port of laplace running live, with the log map applied in the page.

Use it

from skaters import flesaker

f = flesaker(k=8)            # lower=0 by default
state = None
for y in observations:
    dists, state = f(y, state)

dists[7].quantile(0.01)      # always > 0
flesaker(lower=-3.0)         # any floor
flesaker(upper=1.0)          # a ceiling

The state is laplace's own, so state["pit"] and state["z"] read as they do for laplace; PIT values are unchanged by the log map. Every observation must lie strictly inside the bound, so a series with exact zeros needs the floor set a little below zero. flesaker is experimental and Python only: an example composition of laplace, log_transform and conjugate, which are the stable surface.

Measured on a synthetic rate

600 points of a mean-reverting rate that dips from about 0.5 to about 0.05 and back. The series is generated on the log scale, so the comparison favours flesaker by construction; it shows the mechanics, not a benchmark. Source: examples/positive_series.py.

skatermean log score80% coveragemax P(Y<0)
laplace()1.28979.4%0.329
flesaker()1.66584.4%0.000
laplace on Yeo–Johnson1.44978.2%0.223

Named after Bjorn Flesaker, whose positive-interest framework with Hughston builds the guarantee that rates stay positive into the model. His interest-rate work was decidedly less trivial than this little homage. More recipes: Examples.