title: loess line not plotting correctly
body: <p>I'm having trouble fitting a loess smooth plus confidence limits to a scatterplot of residuals.</p>
  
  <p>My model is height ~ weight + chest circumference. To check linearity of chest circumference, I've fitted a model without chest circumference (i.e. height ~ weight), and plotted the residuals of this model against chest circumference. So far so good. I then tried to use <code>loess()</code> and <code>predict()</code> to plot a loess line, plus confidence limits. The result looks like this (in the picture I've only plotted the central line, but the CI lines look the same):</p>
  
  <p><a href="https://plus.google.com/photos/101234827474522282864/albums/5727461774276794209" rel="noreferrer">Loess problem in scatterplot</a></p>
  
  <p>The points are correct (when I plot the loess fit as points it looks right), but for some reason the line is not being drawn how I expect. My code is below:</p>
  
  <pre><code># bf.red = data set; mod.nch = model; chestc = chest circumference;
  # loess = loess model; lo.pred = predict loess
  
  plot(bf.red$chestc           #Chest circumference
   ,residuals(mod.nch))    #Residuals from height ~ weight model
  
  loess &lt;- loess(mod.nch$residuals ~ bf.red$chestc)
  lo.pred &lt;- predict(loess, se=T)
  
  lines(bf.red$chestc,lo.pred$fit,pch=2) #Main line
  lines(bf.red$chestc,lo.pred$fit+2*lo.pred$s, lty=2) #rough &amp; ready CI
  lines(bf.red$chestc,lo.pred$fit-2*lo.pred$s, lty=2)
  </code></pre>
  
  <p>Hope you can help. Many thanks,</p>
  
  <p>Mat</p>