Displaying 1 result from an estimated 1 matches for "yournewvalues".
2009 Jul 09
3
How to get function from lm object?
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}