title: Difference in expected predicted values from lm in R
body: <p>I'm struggling with a problem in R.</p>
  
  <p>This list contains data of pregnant women, birthweight and parity.</p>
  
  <p>I want to predict the difference in the weight gain of two future women giving birth for the first time (parity 0) to respectively a child of 3200 g and 3700 g.</p>
  
  <p>I have this data set:</p>
  
  <pre><code>str(birth_all)
  'data.frame':   910 obs. of  13 variables:
  $ birthweight: int  3270 3580 3030 2460 3400 4250 4260 3450 3880 3600 ...
  $ parity     : int  0 0 0 0 0 0 2 0 1 0 ...
  $ weightgain : num  17.9 15.9 10.4 11.5 11.6 ...
  </code></pre>
  
  <p>I can do like this:</p>
  
  <pre><code>bweight&lt;-birth_all$birthweight[birth_all$parity==0]
  wgain&lt;-birth_all$weightgain[birth_all$parity==0]
  P1&lt;-data.frame(bweight=c(3200,3700))
  pred_val&lt;-predict(lm(wgain~bweight),newdata = P1,interval = "confidence")
  pred_val
         fit      lwr      upr
  1 15.36842 14.62545 16.11138
  2 16.71779 16.07556 17.36002
  </code></pre>
  
  <p>The easy calculation will be this:</p>
  
  <pre><code>    pred_val[2,1]-pred_val[1,1]
  [1] 1.349368
  </code></pre>
  
  <p>I don't think this solution is very elegant, and I loose the confidence intervals.</p>
  
  <p>Alternatively I could use the multcomp-package, but I get similar results. Can anybody help me with a better solution? Thanks a lot.</p>