Your first Bayesian regression
Today let's take a regression you already know how to fit the usual way, and fit it again the Bayesian way, so you can see exactly what stays the same and what is genuinely different.
Twenty-four small retail stores each spent some money on online ads last month, and each tracked how much it sold online that same month, both numbers in thousands of dollars. The chart below plots all twenty-four stores: one point per store, ad spend on the x-axis against sales on the y-axis.
That rising scatter, with real noise scattered around the trend, is the one example this whole lesson runs on.
The same linear model, a different account of uncertainty
The chart you just saw has a clear trend: more spend lines up with more sales. The usual way to put a number on that trend is ordinary least squares, the regression that fits a straight line through the points, choosing the line that makes the squared vertical gaps between the points and the line as small as possible.
The equation behind that line is simple. Sales equals an intercept, plus a slope times spend, plus noise for everything the line does not explain:
sales = b0 + b1 * spend + noise
b0 is what sales would be at zero spend, and b1 is how many extra thousand dollars of sales one extra thousand dollars of spend buys, on average.
Fit that line with lm() and read off its three numbers.
#> Estimate Std. Error
#> (Intercept) 52.43 5.42
#> spend 3.36 0.61
#> [1] 8.59
Read the three numbers in dollars. A store spending nothing would be expected to sell about $52,430 (the intercept, 52.43 thousand). Each extra $1,000 of monthly spend lines up with about $3,360 more in monthly sales (the slope, 3.36 thousand). And a typical store's actual sales miss this line by about $8,590 (the residual standard error, 8.59 thousand).
That is what least squares hands you: one number for b0, one number for b1, and one standard error attached to each. A Bayesian fit keeps the exact same equation, the same sales, the same spend, the same noise term. What it replaces is the single number and its standard error for b0 and for b1, swapping each one out for a full range of plausible values, built by combining a prior belief with this same data. That is the only difference between the two.
Same model, same data, a different account of the uncertainty around the two numbers that describe it.