[R] questions about nls

Mei-Chu Lo Lom at wyeth.com
Mon Jun 9 16:30:37 CEST 2003


Dear R users,
 
I am new in R and I want to use the nls package to analyze some
experimental data.  The data is in the attached file "data".  It is the
response "Sav" measured at different "C0".  Basically, the "C0" is a
function of C1, K2, and r, and the "Sav" is a function of C0, C1, K2,
and r. The math equations are shown in the attached file"equations". 
The parameters K2 and r are the physical properties I want to get from
the non-linear regression.  The R codes I wrote is in the attached
file"Rcode".  Basically, I wrote two functions.  First , I calculated
the C1 for different C0 at the estimated K2 and r using the binary
search method and implemented it in the function "fn1".  Then for the
calculated C1 and estimated K2 and r, I used the function "fn2" to get
the estimated Sav for different C0.  "nls" was used to minimize the
differences between the calculated Sav and observed Sav.  When I run my
R script, I got the error message " step factor reduced below minFactor"
.  If I changed the minFactor to zero, the nls continued but did not
converge (exceed the maxiteration).  I changed the tolerance to higher
value, nls finished but the fitting is bad.  From the published results,
the best fitted values for K2 and r are 0.2237 and 1.296*10^7,
respectively.  I can't get these numbers using my R script.


I know there are a lot math and R experts on the R mailing-list.  I
will appreciate it if anyone can tell me what is wrong in my R script or
in the methods I used to get these parameters.


Mei-Chu Lo   
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: data.txt
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20030609/c44d8de8/data.txt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Rcode.txt
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20030609/c44d8de8/Rcode.txt


More information about the R-help mailing list