title: Plot "regression line" from multiple regression in R
body: <p>I ran a multiple regression with several continuous predictors, a few of which came out significant, and I'd like to create a scatterplot or scatter-like plot of my DV against <em>one</em> of the predictors, including a "regression line".  How can I do this?</p>
  
  <p>My plot looks like this</p>
  
  <pre><code>D = my.data; plot( D$probCategorySame, D$posttestScore )
  </code></pre>
  
  <p>If it were simple regression, I could add a regression line like this:</p>
  
  <pre><code>lmSimple &lt;- lm( posttestScore ~ probCategorySame, data=D )
  abline( lmSimple ) 
  </code></pre>
  
  <p>But my actual model is like this:</p>
  
  <pre><code>lmMultiple &lt;- lm( posttestScore ~ pretestScore + probCategorySame + probDataRelated + practiceAccuracy + practiceNumTrials, data=D )
  </code></pre>
  
  <p>I would like to add a regression line that reflects the coefficient and intercept from the actual model instead of the simplified one.  I think I'd be happy to assume mean values for all other predictors in order to do this, although I'm ready to hear advice to the contrary.</p>
  
  <p>This might make no difference, but I'll mention just in case, the situation is complicated slightly by the fact that I probably will not want to plot the original data. Instead, I'd like to plot mean values of the DV for binned values of the predictor, like so:</p>
  
  <pre><code>D[,'probCSBinned'] = cut( my.data$probCategorySame, as.numeric( seq( 0,1,0.04 ) ), include.lowest=TRUE, right=FALSE, labels=FALSE )
  D = aggregate( posttestScore~probCSBinned, data=D, FUN=mean )
  plot( D$probCSBinned, D$posttestScore )
  </code></pre>
  
  <p>Just because it happens to look much cleaner for my data when I do it this way.</p>