[R] predict function the other way around

Gerrit Voigt gerrit.voigt at campus.tu-berlin.de
Mon May 11 17:20:01 CEST 2009


Dear List,
Consider the following example

x=c(1,2,3,4,5)
y=c(2,4,6,8,10)
linearmodel=lm(y~x)

To predict a y-value if you know the corresponding x value is very easy 
with the command predict.

predict(linearmodel, newdata=(x=1.5))

The other way around, to predict an x-value with a corresponding 
y-value, doesn't work unfortunately.
Is there another function that can do that, or do I need to solve that 
problem the classical way?

Thanks in advance

Gerrit Voigt




More information about the R-help mailing list