Member-only story
How to Create A Correlation Band for a Regression
Two ggplot functions, geom_smooth() and ggribbon(), can explain your regression model (and errors) better
People often treat regression models as a definite relationship among a set of variables. While a regression represents a relatively accurate relationship between examined variables, it is a best-fit calculation based on the data. To show how well the model “fits” among the data, analysts graph the regression line with a confidence band on either side to show the amount of variation that exists.
One feature that helps with visualizing how data fits in a confidence band is a ggplot2 layer function called geom_smooth(). It displays a regression line in your graph, indicating where the data is relative to the regression model.
What a confidence band does
A confidence band is a shaded area on a line graph, created around a regression line. The band indicates the range of values within which you can be reasonably confident that the true population value of a trendline or curve would normally lie.
Displaying the confidence band highlights how well a given set of observations lies close to a regression line and shows what additional observations that fit a confidence level…