Re: [R] Create a function automatically from lm formula and coefficients?

2012-07-05 Thread taheri
Hi, I need to create a function from lm formula and coefficients to use it in my c++ code later. but when I do it as you said require(rms) f - ols( ) g - Function(f) g(x1=2,x2=3,...) I realize that it didn't give me the same result as predict.lm? how can I reach a function to give me the same

[R] Create a function automatically from lm formula and coefficients?

2012-02-29 Thread Keith Weintraub
I hope the subject says it all. I want to be able to use an lm object and the associated coefficients to create function that can produce expected y values given inputs. Thanks, KW -- [[alternative HTML version deleted]] __

Re: [R] Create a function automatically from lm formula and coefficients?

2012-02-29 Thread Frank Harrell
require(rms) f - ols(y ~ rcs(age,4)*sex + blood.pressure + rcs(height,5)) latex(f) # typeset algebraic form of model Function(f) # create an R function that computes Y hat Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: