stat_binmean() is astat for ggplot2. Itreturns the mean ofy andx within bins ofx. It’s a bareborne version of the Stata commandbinscatter
Sincestat_binmean is just a layer for ggplo2, you cansurimpose any model fit
ggplot(iris,aes(x = Sepal.Width ,y = Sepal.Length,color = Species))+stat_binmean(n=10)+stat_smooth(method ="lm",se =FALSE)