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

Frank Harrell f.harrell at vanderbilt.edu
Thu Mar 1 14:39:01 CET 2012


yes, e.g.
require(rms)
f <- ols( ) # ols is a wrapper for lm
g <- Function(f)
g(age=30) # get predicted mean at age=30 and defaults for other variables
(medians & modes)
Frank



Pascal Oettli-2 wrote
> 
> Hi Keith,
> 
> Do you mean as "predict.lm" can do?
> 
> Regards,
> Pascal
> 
> 
> ________________________________
> De : Keith Weintraub <kw1958@>
> À : r-help@ 
> Envoyé le : Jeudi 1 mars 2012 11h41
> Objet : [R] Create a function "automatically" from lm formula and
> coefficients?
> 
> 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]]
> 
> ______________________________________________
> R-help@ mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________
> R-help@ mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/Create-a-function-automatically-from-lm-formula-and-coefficients-tp4433854p4434981.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list