Skip to content
Prev 6782 / 63421 Next

Bug in predict(newdata=x) with poly() (PR#1258)

On Sat, 12 Jan 2002 07:49:01 +0000 (GMT), you wrote:

            
Yes, I didn't notice that predict.bs wasn't being called by
predict.lm.
A short-term workaround would be to put code like this into
predict.lm, at the point where tt contains the terms of the fit, and
it has been determined that newdata is not missing:

  if (any(c('poly','bs','ns') %in% flatten(tt)))          
     warning("newdata not supported with 'poly', 'ns', or 'bs'")

I don't know if there's already a function like flatten in R; here's a
simple one:

flatten <- function (expr) 
{
  if (is.expression(expr) | is.call(expr) | is.list(expr)) {
    unlist(lapply(as.list(expr), flatten))
  } else {
    as.character(expr)
  }
}

There may be other functions besides poly, bs and ns that return
bases; I don't know.

Duncan Murdoch
 


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._