Bayesian posterior

Combine historical growth, the model and consensus

BayesianPosterior combines three readings of growth for each company. A more precise reading receives more weight. The worked tutorial shows the calculation; the posterior contract defines the equations and exceptional cases.

Inputs and outputs

flowchart TB
    subgraph IN["Point-in-time inputs"]
        direction LR
        Y["Actuals y<br>first reported figure<br>per period"]
        B["Model history<br>past forecasts for<br>reported periods"]
        M["Model forecast m<br>for the target period"]
        C["Consensus c<br>analyst dispersion d<br>and count k"]
    end

    subgraph RD["Three readings of growth θ"]
        direction LR
        P["Prior<br>μ₀ mean of realised growth<br>τ₀ from its variance"]
        XM["Model<br>x_M growth of m<br>τ_M from past errors"]
        BC["Bias correction<br>c* removes a share λ<br>of the persistent miss"]
        XC["Consensus<br>x_C growth of c*<br>τ_C from dispersion d<br>or past errors"]
    end

    S["Versioned preset<br>λ, dispersion scale,<br>interval shape"]
    W["Precision-weighted blend<br>w_j = τ_j / T<br>θ̂ = w₀μ₀ + w_M x_M + w_C x_C"]

    L["posterior_level<br>ŷ = last actual × (1 + θ̂)"]
    I["posterior_lower<br>posterior_upper<br>Student-t interval"]
    WT["precision_*<br>weight_*<br>what moved the number"]
    E["eligible<br>eligibility_reason<br>refusal, never a fallback"]
    AU["settings_version<br>preset<br>audit trail"]

    Y --> P
    B --> XM
    M --> XM
    C --> BC --> XC
    P --> W
    XM --> W
    XC --> W
    S -.-> BC
    S -.-> W
    W --> L & I & WT & E & AU

    classDef input fill:#eef3fb,stroke:#4c72b0,color:#1f2d3d
    classDef reading fill:#f6f6f6,stroke:#8c8c8c,color:#222222
    classDef blend fill:#fff4e8,stroke:#dd8452,color:#222222
    classDef output fill:#edf6ef,stroke:#55a868,color:#1f3d27
    class Y,M,B,C input
    class P,XM,BC,XC reading
    class W,S blend
    class L,I,WT,E,AU output
    style IN fill:#f8fafd,stroke:#c7d4ea
    style RD fill:#fafafa,stroke:#d0d0d0
Figure 1: What the method reads, the three readings it forms, and what it returns.
  • Growth is measured over the last actual. Actuals set the base for the model and consensus readings as well as the prior’s history.
  • Every input is point in time. The method reads each source’s latest value strictly before the reading moment, and each past period at its own release, so a later revision never leaks into a weight.
  • Each reading’s weight is its precision share. Nothing is weighted by assumption: the prior by how steady growth has been, the model by its past errors, consensus by analyst agreement or its past errors.
  • Which reading dominates depends on the company. When analyst dispersion sets consensus precision, consensus usually carries most of the weight and the prior barely matters. When consensus precision comes from a poor error record, the prior and the model gain weight, and how the prior is defined starts to move the result.
  • The outputs explain themselves. Precisions and weights show what drove the number; the eligibility columns say why a subject was refused; the settings version ties every row to the configuration that produced it.

Symbols follow the notation page.

The three readings

  • Prior: The company’s earlier realised growth supplies a mean and variance.
  • Model: The current forecast becomes growth over the previous actual. Historical mean squared growth error determines its precision.
  • Consensus: The current consensus becomes growth over the same actual. Precision comes from historical errors or, when configured, analyst dispersion.

The weighted growth converts back to a level. The method also returns each reading’s precision and weight, a configured Student-t interval, and eligibility.

The application path

  1. Prepare: prepare_bayesian_subjects reads the panel at one cutoff and attaches history statistics using the chosen BayesianSettings.
  2. Validate: BayesianPosterior.fit validates the prepared frame and returns a frozen method object. It does not estimate parameters across subjects.
  3. Apply: apply computes the posterior from each row’s prepared statistics. Use the same settings and source names for preparation and application.
  4. Inspect: Check eligible and retain eligibility_reason before publishing.

Historical evaluation requires preparing each target at its own historical cutoff. Preparing everything today does not recreate historical readings.

Settings to choose

  • Presets: Named profiles with evidence and provenance. The plain preset is used for teaching; the recommended profile was evaluated on a particular research sample, not every possible input panel.
  • Bias correction, \(\lambda\): Adjusts consensus to \(c^*\) before the growth blend.
  • Dispersion and count, \(\kappa\) and \(\alpha\): Use analyst agreement \(d\) and count \(k\) to set the consensus precision \(\tau_C\).
  • Model exclusion: Combines prior and consensus without the model reading \(x_M\).
  • Winsorisation: Limits outliers in the historical statistics.
  • Interval shape, \(\nu\), \(\ell\) and \(\omega\): Controls the Student-t band independently of the point estimate \(\hat\theta\).

Presets shows where each setting enters the blend.

See Bayesian settings for exact fields and values.

Eligibility

A subject is published only when the previous actual, a usable prior, a consensus precision and, when the model is included, a model value are all present. The posterior checks no input age and no gap size; those are the caller’s policy. Bayesian eligibility gives every reason, for the main API and the panel workflow.