[R] problem predict/poly

2009-07-13 Thread Alexander V Stolpovsky
Dear R experts, I am observing undesired behavior of predict(fit, newdata), in case when fit object is produced by lm() involving a poly(). Here is how to reproduce: x <- c(1:10) y <- sin(c(1:10)) fit <- lm(formula=y~poly(x, 5, raw=TRUE)) predict(fit, newdata=data.frame(x=c(1:10))) ## this works

Re: [R] How to get function from lm object?

2009-07-09 Thread Alexander V Stolpovsky
Thank you much for the useful pointers. Turns out, I can get what I want with predict(fit, newdata = newdata). But for the record, there is no way to get the fit function, from lm object, is there? Alex - This transmission may contain information that i

[R] How to get function from lm object?

2009-07-09 Thread Alexander V Stolpovsky
Dear experts, I am trying to obtain a function from a model, so that I could further manipulate it, plot it, etc. I can get model estimates and manually construct a function, but this gets tedious when trying out different functions to fit the data. There must be a better way of doing it, no?