[R] Using lm coefficients in polyroot()

From: Lukasz Komsta <luke_at_novum.am.lublin.pl>
Date: Fri 19 Aug 2005 - 17:30:07 EST


Dear useRs,

I need to compute zero of polynomial function fitted by lm. For example if I fit cubic equation by fit=lm(y~x+I(x^2)+i(x^3)) I can do it simply by polyroot(fit$coefficients). But, if I fit polynomial of higher order and optimize it by stepAIC, I get of course some coefficients removed. Then, if i have model

y ~ I(x^2) + I(x^4)

i cannot call polyroot in such way, because there is a need to call polyroot(c(0,0,fit$coefficients[1],0,fit$coefficients[2]).

Is there any method to do it automagically? I would like to write small function solving polynomial optimized by stepAIC, regardless of missing terms.

Sincerely

-- 
Lukasz Komsta
Department of Medicinal Chemistry
Medical University of Lublin
Jaczewskiego 4, 20-090 Lublin, Poland
Fax +48 81 7425165

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Aug 19 17:37:52 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:54 EST