Skip to content
Prev 283939 / 398502 Next

problem in fitting model in NLS function

I am no expert on nls() but since I haven't seen any replies to your
post, I'll chip in:

(1) I am mystified as to why nls() is giving that error about a 
"singular" (???)
gradient.

(2) That being said, I think your parameterisation of the objective function
is a bit flaky.  I would use

         a*log(1+exp(b*x - tau)) # Using "x" instead of the Windoze-ese 
"myday".

This is equivalent to your (c,r,tt) parameterisation with

         c = a*b
         r  = b
         tt = tau/b

(3) However I still get that error message from nls() with this new 
parameterisation.

(4) I tried the optimize() function and *that* seems to work without 
complaint.

With my parameterisation  the Nelder-Mead (default) and the BFGS methods 
give
very similar results with a minumum sum of squares equal to 4.909448 and 
4.904986
respectively.

With your parameterisation the Nelder-Mead method gives a minimum sum of 
squares
equal to 4.972705 --- not as good, and the BFGS method (which is more 
like what nls()
uses) gives 219.79 --- right out to lunch.

The plots of the fitted curves for the two fits with my parameterisation 
are visually
indistinguishable and are visually indistiguishable from a straight line 
fit.  (Which raises
the question --- why are you using such a complicated model?

The Nelder-Mead curve from your parameterisation is "close" to those from my
parameterisation, but is definitely different.  The BFGS curve from your 
parameterisation
is off the plot region.

Summary:

     * I have no idea why nls() is throwing an error.
     * Your parameterisation is bad.
     * A better parameterisation can be readily fitted to your data 
using optimize().
     * The model is probably too complicated and inappropriate for these 
data.

HTH

     cheers,

         Rolf Turner
On 01/02/12 03:11, ram basnet wrote: