|
Greetings,
I am having some troubles with the nls() function in R V 2.14.2. I am doing some modelling where I want to predict the mass of leaf litter on the forest floor (X) as a function of time since fire (t). Fortunately, I have a differential equation that I can fit to the data which is acceptable on theoretical grounds. It is: X(t) = (L/k)[1-exp(-kt)], where L is the litter fall rate (t/ha/yr) and k is the decomposition rate (/yr). I have two problems: (1) I have experimental error in both X and t. Is there a way to take this into account with nls? (2) Is there a way to constrain the parameter estimates from nls? For example, for a data snippet: X = 4.6 4.1 4.7 11.0 t = 1.5 4.5 7.0 8.0 After I run nls I get: L = 0.873 k = -0.059 The estimate for L is ok, but k (by definition) should be greater than 0. Is there a way around this? Many thanks, Nic Surawski. |
|
On 2012-04-01 17:31, n.surawski wrote:
> Greetings, > > I am having some troubles with the nls() function in R V 2.14.2. I am doing > some modelling where I want to predict the mass of leaf litter on the forest > floor (X) as a function of time since fire (t). Fortunately, I have a > differential equation that I can fit to the data which is acceptable on > theoretical grounds. It is: X(t) = (L/k)[1-exp(-kt)], where L is the litter > fall rate (t/ha/yr) and k is the decomposition rate (/yr). I have two > problems: > > (1) I have experimental error in both X and t. Is there a way to take this > into account with nls? > (2) Is there a way to constrain the parameter estimates from nls? > > For example, for a data snippet: > X = 4.6 4.1 4.7 11.0 > t = 1.5 4.5 7.0 8.0 > > After I run nls I get: > L = 0.873 > k = -0.059 > > The estimate for L is ok, but k (by definition) should be greater than 0. > > Is there a way around this? Yes. Plot your data, decide which you trust more: your data or theory. There is no way to use the given data to help substantiate the proposed theory. As to your other questions above: (1) If the uncertainty in your t values is small compared with that in the X values, then I would just ignore it. (2) To force a parameter to be positive, see ?SSasymp or for your case, perhaps ?SSasympOrig. Peter Ehlers > > Many thanks, > > Nic Surawski. > > -- > View this message in context: http://r.789695.n4.nabble.com/Non-linear-least-squares-tp4524812p4524812.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [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-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
|
Thanks for these comments!
|
| Powered by Nabble | Edit this page |
