0

I know NLS is used to fit nonlinear equations, but I don't understand why it won't work with a simple linear one. I mean, the theory should still hold, right? But, when I try to do something simple like the following, it won't converge.

y = c(1,2,3,4,5);
x = c(5,4,3,2,1);

summary(nls(y ~ A*x + B, start=list(A=-1,B=6)));

I mean, I gave it the actual parameters that A and B should be. Any idea why this won't work? And, if it is in fact because it is linear, does anyone know why that won't work based on theory or how this specific function is written? Sorry for the annoyance, I'm just trying to understand what's going on. Thanks and I appreciate the help!

kyro1021
  • 31
  • 2
  • 2
    Read the `?nls` help page, specifically the bold section where it states: "Do not use nls on artificial 'zero-residual' data." – MrFlick Mar 01 '16 at 18:37
  • Thanks, guys! I guess I didn't think about that part of it at all and was more just thinking it was because of the linearity thing, ha. Sorry for the question, but thanks for your responses both of you! – kyro1021 Mar 01 '16 at 18:52

0 Answers0