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?

x <- c(1:10)
y <- c(1:10)

fit <- lm(y ~ x)
f <- function(x){fit$coef[1] + fit$coef[2]*x}  # Manually constructing function
                                               # Would be nice to do something like this:
                                               # f<-getFunction(fit)
plot(f, 0, 10)

Thanks,
  Alex Stolpovsky



-----------------------------------------
This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law.  If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED.  Although this transmission and
any attachments are believed to be free of any virus or other
defect that might affect any computer system into which it is
received and opened, it is the responsibility of the recipient to
ensure that it is virus free and no responsibility is accepted by
JPMorgan Chase & Co., its subsidiaries and affiliates, as
applicable, for any loss or damage arising in any way from its use.
 If you received this transmission in error, please immediately
contact the sender and destroy the material in its entirety,
whether in electronic or hard copy format. Thank you.
	[[alternative HTML version deleted]]


