Bayesian Regression Calculator

Estimate linear trends using priors and observed data. See posterior coefficients, uncertainty, and correlation instantly. Predict new outcomes with credible ranges for practical planning.

Calculator Inputs

Accepted separators: space, comma, tab, or semicolon. Example: 2, 3.5
Formula How to use

Example data table

#xy
101.2
212.1
322.9
433.8
545.2
655.9

Formula used

We fit a straight line with Gaussian noise: y = a + b·x + e, where e ~ N(0, σ²).

The prior over parameters is Gaussian: [a, b]ᵀ ~ N(μ₀, Σ₀). Here Σ₀ is diagonal using your prior SD inputs.

With design matrix X = [1, x] and observations y, the posterior is:

  • Σₙ = (Σ₀⁻¹ + (1/σ²) XᵀX)⁻¹
  • μₙ = Σₙ (Σ₀⁻¹ μ₀ + (1/σ²) Xᵀy)

For prediction at x*, the predictive distribution is Normal with: mean = [1, x*] μₙ and variance = σ² + [1, x*] Σₙ [1, x*]ᵀ.

How to use this calculator

  1. Paste your data pairs (x and y) into the input box, one pair per line.
  2. Set prior means and SDs to reflect what you believe before data.
  3. Enter sigma as the expected noise level around the line.
  4. Choose alpha for your credible interval width (0.05 gives 95%).
  5. Add a prediction x value to get a credible prediction interval.
  6. Press Calculate and review results above the form.

Related Calculators

Multiple Regression CalculatorSimple Regression CalculatorCorrelation Coefficient CalculatorT Statistic RegressionTrend Line CalculatorRegression Diagnostics ToolAutocorrelation Test CalculatorShapiro Wilk CalculatorRMSE CalculatorDummy Variable Calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.