[R] How to predict/interpolate new Y given knwon Xs and Ys?
jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Tue Jan 26 10:20:20 CET 2021
model2 <- lm( x~y )
model2 is however not the inverse of model... if you need that then you need to handle that some other way than using predict, such as an invertible monotonic spline (or in this case a little algebra).
On January 26, 2021 1:11:39 AM PST, Luigi Marongiu <marongiu.luigi using gmail.com> wrote:
>I have a series of x/y and a model. I can interpolate a new value of x
>using this model, but I get funny results if I give the y and look for
>the correspondent x:
>> x = 1:10
>> y = 2*x+15
>> model <- lm(y~x)
>> predict(model, data.frame(x=7.5))
>> predict(model, data.frame(y=26))
> 1 2 3 4 5 6 7 8 9 10
>17 19 21 23 25 27 29 31 33 35
>'newdata' had 1 row but variables found have 10 rows
>what is the correct syntax?
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.
Sent from my phone. Please excuse my brevity.
More information about the R-help