title: gls model plotting with 95% intervals
body: <p>I am trying to plot my gls predicted values with 95% confidence and I am struggling with the syntax.</p>
  
  <p>I have done this with a gam model previously with the following code: </p>
  
  <pre><code>m1 &lt;- gam(Chl ~ s(IR, fx= F, k= -1, bs = "cr"))
  m1pred &lt;- predict(m1, se=T, type = "response")
  
  plot(IR, Chl, type ="p")
  I1 &lt;- order(IR)
  lines(IR[I1], m1pred$fit[I1], lty=1, col="red", lwd = 3 )
  lines(IR[I1], m1pred$fit[I1]+2*m1pred$se[I1], lty=2, col = "red", lwd =2)
  lines(IR[I1], m1pred$fit[I1]-2*m1pred$se[I1], lty=2, col = "red", lwd = 2)
  </code></pre>
  
  <p>but this does not work for a gls model as it says:</p>
  
  <p>Error in pred2$fit : $ operator is invalid for atomic vectors</p>
  
  <p>I have got to this point with an alternate method where i can plot the predicted model and the data following some of Zurr et al (2009) code:</p>
  
  <pre><code>plot(IR, Chl,
   ylim = c(0, 2.5), pch= 21,
   ylab = "Chl concentration µg/L", xlab = "Incident irradiance  (W/m-2)")
  
  MyX &lt;- data.frame(IR = seq(from = min(IR),
                         to = max(IR), length = 1076), ID = "IR")
  pred2 &lt;- predict(m1s, newdata = MyX)
  lines(MyX$IR, pred2, col="red", lwd=3)
  </code></pre>
  
  <p>But I am then not sure how to add the 95% interval lines? </p>
  
  <p>I think I can get the intervals using this syntax from the AICmodav package:</p>
  
  <pre><code>predictSE.gls(m1s, MyX, se.fit=T)
  lines(MyX$IR, predse, col="red", lwd=1)
  </code></pre>
  
  <p>But then I am not sure how to plot this as it seems the x and y variables are then different...can anyone help?</p>
  
  <p>I am not amazing with R so the simpler the explanation the more I will be able to take away from it.</p>
  
  <p>Thanks in advance
  Luci</p>