[R] predicting x values in a polynomial regression

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Oct 27 10:54:34 CEST 2004

Sebastian Leuzinger wrote:

> Dear R
> I would like to predict x-values in a 4th order polynomial regression:
> x <- c(1:10)
> y <- c(2,7,19,49,89,94,97,98,92,89) # these are percentages
> lm(y ~ x+I(x^2)+I(x^3)+I(x^4)-1) -> lm1
> now I would like to know what the model fit (x-value) for y=50 is. This 
> results in solving a 4th order quadratic equation. polyroot() does not 
> really help because it only gives me the x-values for y=0. I have tried 
> with nls() which sort of works, but I am sure there is a much easier 
> solution to that, can anyone give me a hint?

What about optim()?

Uwe Ligges

More information about the R-help mailing list