Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

name: op-reg-bayes-linear
description: Bayesian linear regression with a conjugate Normal-Inverse-Gamma prior; emits posterior means, std errors, and credible intervals. Streams the same sufficient statistics as an OLS fit.
kind: operator
category: REG
operator: REG_BAYES_LINEAR
type: reference
applies_to: process, compose, predict
examples_tags: [regression, bayesian, streaming-friendly]

Regression operators emit coefficient + diagnostics; no Response.Components. Fit summaries ride Response.Regressions[i].

Use when

Fits a straight-line model of a numeric outcome under a prior, reporting each coefficient’s posterior mean and credible interval.

Questions it answers:

  • Given the data and our prior belief, what range of values is plausible for the price coefficient?
  • How do the coefficients shift when last year’s estimates are used as the prior?

Use something else:

  • REG_GLM when the outcome is yes/no (0/1) or a count.

Params

NameTypeDefaultDescription
targetfieldrequiredResponse variable (numeric).
predictors[]fieldrequired≥1 numeric predictor.
priorenumnigOnly "nig" (conjugate Normal-Inverse-Gamma) in v1.
prior_mu[]floatzeroPrior mean vector, length predictors + 1, intercept FIRST.
prior_precisionfloat0.001Scalar ε, Λ₀ = ε·I, relative to σ²: prior SD = σ/√ε.
prior_shape / prior_ratefloatengineInverse-gamma α₀ / β₀ on residual variance.
credible_levelfloat0.95Posterior credible-interval mass.
conf_levelfloatcredible_levelCILower / CIUpper mass, 0<c<1.
weightslot weightinheritednull opts out; frequency only (= the expanded rows: X’WX, X’Wy, Σw in the posterior). Adds SumWeights; NObs raw rows.
vcovboolfalseAdds the POSTERIOR covariance b_n/(a_n−1)·Λ_n⁻¹ (null if a_n ≤ 1) + Correlation; diag = StdErrors²·a_n/(a_n−1).
covarianceobjectabsent{type, cluster, order_by, lags} as op-reg-ols. Keeps the posterior-mean βs but REPLACES the posterior covariance with Müller’s (2013) sandwich posterior N(μ_n, Λ_n⁻¹MΛ_n⁻¹): StdErrors, CredibleIntervals, CIs (normal, no DF) and Vcov (√diag = StdErrors) follow it.

Inputs

target / predictors — numeric analytics set: u4/u8/u16/u32/u64, f32/f64, decimal128, date, packed_bool, plus nullable variants. Nullable rows drop from n_obs.

Output

RegressionResult: Coefficients["(intercept)"] + per-predictor posterior-mean βs; StdErrors = the Student-t marginal’s SCALE (not the posterior SD, which is larger by √(ν/(ν−2))); CredibleIntervals[name] = [lower, upper] at credible_level; CILower / CIUpper the same t interval at conf_level (equal when unset), DF = 2a_n, ConfLevel; R2, AdjR2, ResidualStdErr, NObs; a robust covariance adds the Covariance echo. No PValues — Bayesian inference reports credibility, not tail probability. Streams the same Welford stats as OLS; one finalize-time Cholesky on Λ_n applies the conjugate posterior.

Reading the output

  • coefficients.*: Posterior mean of the coefficient: the expected difference in the outcome between rows one unit apart on this predictor, holding the other predictors fixed, after combining the data with the prior.
  • std_errors.*: Scale of the coefficient’s Student-t posterior: how uncertain the coefficient is given the data and the prior. With many rows it is close to the posterior standard deviation.
  • conf_level: The coverage ci_lower and ci_upper were built at (the request’s conf_level, 0.95 by default).

Gotchas

  • A probability weight in force (request, slot or Options.DefaultWeight) → PULSE_WEIGHT_UNSUPPORTED naming the kind; "weight": null runs it unweighted.
  • penalty / alpha / l1_ratio / family / link rejected — other engines’ knobs.
  • resample / selection → PROCESSING_CONFIG (not advertised) — credible intervals already convey uncertainty.
  • prior_mu length ≠ predictors + 1 → PROCESSING_CONFIG.
  • Robust covariance is a substitution, not a posterior: honest under heteroskedastic or dependent rows, but no longer the conjugate model’s probability statement. It forces the buffered path; < 2 clusters or a repeated order_by → PROCESSING_REGRESSION_VCOV_UNSUPPORTED.
  • Vague-prior limit reproduces the OLS point estimate; intervals and ResidualStdErr run below OLS with few rows per predictor (σ² ≈ RSS/n, not RSS/(n−p−1)).
  • R2 is on the posterior-mean fit, not averaged over posterior draws.

See