title: geom_smooth: what is its meaning (why is it lower than the mean?)
body: <p>I have data on the number of trips people make to work per week. Along with the distance of the trip, I am interested in the relationship between the two variables. (Frequency is expected to fall as distance increases, essentially a negative relationship.) Cor.test supports this hypothesis: -0.08993444 with a p value of 2.2e-16.</p>
  
  <p>When I come to plot this, the distance clearly tends to decrease for more frequent trips. To make sense of the vast number of points I used geom_smooth. But I don't fully understand the result. According to the <a href="http://docs.ggplot2.org/current/geom_smooth.html" rel="nofollow noreferrer">help pages</a>, it's a "conditional mean". However, it seems never to approach the true mean,</p>
  
  <pre><code>&gt; mean(aggs3$Distance)
  [1] 9.766497
  </code></pre>
  
  <p>in the plot below, which seems never to go above 8.
  What's going on here? I think I really want the rolling mean, but found <a href="http://rss.acs.unt.edu/Rdoc/library/zoo/html/rollmean.html" rel="nofollow noreferrer">rollmean</a> from the zoo package a hassle to implement (you need to sort the data first), and I would like to ask for the optimal solution before forging ahead. Many thanks.</p>
  
  <p><img src="https://i.stack.imgur.com/UMJiD.png" alt="geom_smooth"></p>
  
  <pre><code>p &lt;- ggplot(data=aggs3, aes(x=N.trips.week, y=Distance))
  p + geom_point(alpha = 0.1) + geom_smooth() +
    ylim(0,30) + xlim(0,25)  + ylab("Distance (miles)") +
    stat_density2d(aes(fill = ..level..), geom="polygon", alpha=0.5,na.rm=T, se=0.1) 
  </code></pre>
  
  <p>(Secondary unrelated question: how do I make the 2d density layer contours smoother?)</p>
  
  <p>(P.s. I know there are better ways to visualise this - e.g. below, but I for the sake of learning I need better understanding of how to use geom_smooth.)</p>
  
  <p><img src="https://i.stack.imgur.com/0tVir.png" alt="histogram"></p>