title: I am trying to plot confidence intervals on a regression graph.
body: <p>I have tried a few methods, but all of them gives me an error saying that the x and y values are not the same.</p>
  
  <p>This is what i have done so far.</p>
  
  <pre><code>head(new_data[,4:5])
  
   Humerus   Radius
   4.992607 4.921148
   5.170484 5.049856
   5.005623 4.936989
   5.065755 4.976734
   4.219508 4.174387
   4.262680 4.157319
  
  plot(new_data$Radius, new_data$Humerus, main="Regression analysis of Humerus to radius", 
   xlab="Radius ", ylab=" Humerus", pch=19)
  abline(lm(new_data$Humerus~ new_data$Radius))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rhPqA.png" rel="nofollow noreferrer">This is the graph I got</a></p>
  
  <p>And to do the confidence intervals, I tried this</p>
  
  <pre><code>lm.out &lt;- lm(new_data$Humerus ~ new_data$Radius)
  newx = seq(min(new_data$Radius),max(new_data$Humerus),by = 0.05)
  conf_interval &lt;- predict(lm.out, newdata=data.frame(x=newx), interval="confidence",level = 0.95)
  plot(new_data$Radius, new_data$Humerus, xlab="Radius", ylab="Humerus", main="Regression")
  abline(lm.out, col="lightblue")
  lines(newx, conf_interval[,2], col="blue", lty=2)
  lines(newx, conf_interval[,3], col="blue", lty=2)
  </code></pre>
  
  <p>When I do this, error message keep popping up saying -</p>
  
  <pre><code> Warning message:
  'newdata' had 61 rows but variables found have 150 rows
  </code></pre>
  
  <p>I'm really stuck here, any kind of help would very much appreciated. Thank you</p>