Reference

Public API, data contracts and mathematical definitions

Public entry points

Import the supported API from postforecast.

  • publish_anchored: Accepts the estimate panel and as_of, with required forecast_source and parameters. Optional consensus_source, subjects and fields control source selection, the requested universe and numeric outputs.
  • AnchoringParameters: Frozen, versioned coefficients and eligibility limits. Includes fitted_through; publication requires it to precede the reading date.
  • bayesian_kpi_predictions: Accepts the estimate panel and as_of, with required forecast_source and settings. Optional backtest_source separates historical model estimates; publications supplies publication-relative reading dates.
  • BayesianPredictionSettings: Frozen configuration for the complete reference workflow. version is required. Defaults to method="independent", series="combined" and values=("prediction",).
  • BayesianPosterior: The earlier prepared-subject tutorial interface, configured with BayesianSettings. It remains supported; its behavior is distinguished from the complete workflow in the coverage audit.
  • prepare_anchored_subjects: Prepares the anchored method’s input, including age and revision data, from the raw panel.
  • AnchoredEstimate: Applies versioned parameters to prepared subjects through the fit / apply protocol.

Runnable calls are in the how-to guides.

Data contracts

  • Estimate panel: One row per subject, source and known_at. A subject is identified by entity, period and target. The complete column contract includes period_end, value and optional consensus dispersion and contributor count.
  • Timestamps: known_at, period_end and as_of must be UTC-aware. The caller converts from the known source timezone before passing the frame.
  • Source names: actual and consensus have defined roles. Other source identifiers belong to the caller.
  • Validation: validate_estimates returns a validated, canonically ordered panel. Invalid input raises PanelError.
  • Anchoring: latest_before selects observations strictly before the explicit reading moment by default. age_at measures their age.
  • Reshaping: pivot_sources produces one row per subject with source value and knowledge-time columns. Colliding generated column names are rejected.
  • History: consensus_revision, growth_prior and growth_error_variance provide the history statistics consumed by the methods.
  • Method protocol: fit returns a frozen fitted object; apply does not learn. The anchored method validates already-fitted parameters without estimating weights.

Publication results

  • Anchored identity: One row per subject, reading moment, forecast source, method and parameter version. Reading policy and fitted-through date accompany it.
  • Anchored values: expected_surprise is a fraction. anchored_level is a level. Selected contributions attribute the expected surprise to its ingredients.
  • Anchored refusals: eligible=False, missing numeric fields and an eligibility_reason; source levels are never included.
  • Bayesian identity: Subject keys and period end accompany as_of, method, settings_version and resolved relative_days.
  • Bayesian values: Requested reference names are preserved, including hyphens. Growth outputs are fractions; consensus-bias-pct uses percentage points.
  • Bayesian refusals: eligible and eligibility_reason describe prediction availability. Diagnostics can remain available on refused rows.

Mathematical reference

Provenance and coverage

  • Bayesian reference audit: Source snapshot, calculation mapping, golden-scenario evidence and integration boundaries.
  • Tutorial provenance: Origins of both method families and the role of reference self-checks as golden tests.