# R nls results different from those of Excel ??

7 messages
Open this post in threaded view
|

## R nls results different from those of Excel ??

 Hi all I have a set of data whose scatter plot shows a very nice power relationship. My problem is when I fit a Power Trend Line in an Excel spreadsheet, I get the model y= 44.23x^2.06 with an R square value of 0.72. Now, if I input the same data into R and use model< -nls(y~ a*x^b , trace=TRUE, data= my_data, start = c(a=40, b=2)) I get a solution with a = 246.29 and b = 1.51. I have tried several starting values and this what I always get. I was expecting to get a value of a close to 44 and that of b close to 2. Why are these values of a and b so different from those Excel gave me. Also the R square value for the nls model is as low as 0.41. What have I done wrong here? Please help. Thanks in advance David         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: R nls results different from those of Excel ??

 Have you plotted the data and the lines to see how they compare?  (see fortune(193)). Is there error around the line in the data?  The nls function is known to not work well when there is no error around the line.   Also check and make sure that the 2 methods are fitting the same model. You might consider taking the log of both sides of the function to turn it into a linear function and using lm to fit the logs. On Mon, Feb 18, 2013 at 9:49 PM, David Gwenzi <[hidden email]> wrote: > Hi all > > I have a set of data whose scatter plot shows a very nice power > relationship. My problem is when I fit a Power Trend Line in an Excel > spreadsheet, I get the model y= 44.23x^2.06 with an R square value of 0.72. > Now, if I input the same data into R and use > model< -nls(y~ a*x^b , trace=TRUE, data= my_data, start = c(a=40, b=2)) I > get a solution with a = 246.29 and b = 1.51. I have tried several starting > values and this what I always get. I was expecting to get a value of a > close to 44 and that of b close to 2. Why are these values of a and b > so different from those Excel gave me. Also the R square value for the nls > model is as low as 0.41. What have I done wrong here? Please help. Thanks > in advance > > David > >         [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > -- Gregory (Greg) L. Snow Ph.D. [hidden email]         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: R nls results different from those of Excel ??

 In reply to this post by dgwenzi To paraphrase Bill Venables (see fortune(217)):      Simple.  Excel must be broken.  Have you reported it to them? (The difference in this case is that it is probable that Excel *is* broken. It usually is.)      cheers,          Rolf Turner On 02/19/2013 05:49 PM, David Gwenzi wrote: > Hi all > > I have a set of data whose scatter plot shows a very nice power > relationship. My problem is when I fit a Power Trend Line in an Excel > spreadsheet, I get the model y= 44.23x^2.06 with an R square value of 0.72. > Now, if I input the same data into R and use > model< -nls(y~ a*x^b , trace=TRUE, data= my_data, start = c(a=40, b=2)) I > get a solution with a = 246.29 and b = 1.51. I have tried several starting > values and this what I always get. I was expecting to get a value of a > close to 44 and that of b close to 2. Why are these values of a and b > so different from those Excel gave me. Also the R square value for the nls > model is as low as 0.41. What have I done wrong here? Please help. Thanks > in advance > > David > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: R nls results different from those of Excel ??

Open this post in threaded view
|