Display the result of a linear model and its confidence interval on top of a scatterplot.
Adding a linear trend to a scatterplot helps the reader in seeing
patterns. ggplot2
provides the geom_smooth()
function that allows to add the linear trend and the confidence interval
around it if needed (option se=TRUE
).
Note:: the method
argument allows to apply
different smoothing method like glm, loess and more. See the doc
for more.
This document is a work of the statistics team in the Biostatistics and Medical Information Department at Saint-Louis Hospital in Paris (SBIM).
Based on The R Graph Gallery by Yan Holtz.