How do I translate the coefficients of an OLS confidence interval into a range of actual values?

42 Views Asked by At

I'm using statsmodels to perform an OLS simple regression on the Palmer's penguins dataset. The regression uses birds' bill length as the sole independent variable and their body mass as the target. Here is the relevant part of the results:

OLS results

To find a point on the regression line for a bird with a given bill length, I would multiply bill length by the B1 coefficient and then add the B0 intercept. So, for a 50 mm bill length, this would be: (50 * 141.1904) - 1707.2919 = 5352.2281 grams.

This number aligns with the (zoomed in) graph that I plotted using seaborn regplot: regression plot

Now, suppose I want to find the range of body mass values in the 0.95 confidence interval. To find the lower bound of the interval, I thought I would multiply bill length by the lower bound of the B1 coefficient and then add the lower bound of the intercept. So, again, for a 50 mm bill length, this would be: (50 * 131.788) - 2112.202 = 4477.198 grams.

Similarly, for the upper bound, I would multiply bill length by the upper bounds of the B1 coefficient and add the B0 intercept: (50 * 150.592) - 1302.382 = 6227.218 grams.

However, this range of [4477, 6227] does not at all coincide with the range indicated by the confidence band of the seaborn plot (which was set to .95).

So my question is: how do I calculate the range of body masses for a .95 confidence interval using the OLS results? How do I get my calculations to align with what the graph is showing me?