title: gls object produced with wrapper function fails for prediction with new data
body: <p>In the following example, I'm using a wrapper function to fit a gls object. I can successfully return the model prediction for the original data, but not when using <code>newdata</code>, which returns the error "<code>Error in eval(expr, envir, enclos) : 'nthcdr' needs a list to CDR down</code>":</p>
  
  <pre><code># library -----------------------------------------------------------------
  library(nlme)
  
  
  # wrapper function --------------------------------------------------------
  test.gls &lt;- function(data, ...){
    fit &lt;- gls(data=data, ...)
    return(fit)
  }
  
  
  # make data ---------------------------------------------------------------
  set.seed(1)
  n &lt;- 20
  x &lt;- sort(rlnorm(n, meanlog = 0.25, sdlog = 1.5))
  b &lt;- 100
  cv &lt;- 0.5
  y &lt;- x*b * rlnorm(n, 0, cv)
  dat &lt;- data.frame(x,y)
  
  
  # fit model ---------------------------------------------------------------
  fit &lt;- test.gls(data=dat, model=y~x-1, weights=varExp())
  class(fit)
  # [1] "gls"
  plot(y~x, dat)
  lines(dat$x, predict(fit)) # works
  
  
  # prediction --------------------------------------------------------------
  newdat &lt;- data.frame(x=sort(rlnorm(n, meanlog = 0.25, sdlog = 1.5)))
  pred &lt;- predict(fit)
  newpred &lt;- predict(fit, newdata = newdat)
  # Error in eval(expr, envir, enclos) : 'nthcdr' needs a list to CDR down
  </code></pre>