[R] nls, convergence and starting values

Ben Bolker bolker at ufl.edu
Sat Mar 28 18:26:45 CET 2009


Patrick Giraudoux <patrick.giraudoux <at> univ-fcomte.fr> writes:

> 
> Patrick Burns a écrit :
> > Patrick Giraudoux wrote:
> >> Bert Gunter a écrit :
> >>> Based on a simple scatterplot of pourcma vs  transat, a 4 parameter 
> >>> logistic
> >>> looks like wild overfitting, and that may be the source of your 
> >>> problems.
> >>> Given the huge scatter, a straight line is about as much as would seem
> >>> sensible. I think this falls into the "Why ever would you want to do 
> >>> such a
> >>> thing?" category.
> >>>
> >>> -- Bert
> >>>   
> >>
> >> Right, well, the general idea was just to show that the "straight 
> >> line" was the best model indeed (in the other data sets, with model 
> >> comparison, the logistic one was clearly shown to be the best... ). 
> >> Can the fact that convergence cannot be obtained be an acceptable and 
> >> sufficient reason to select the null model (the straight line) ?
> >
> > It is my experience that convergence problems are
> > often encountered when the model makes little sense.
> > I'm not so sure that non-convergence on its own is
> > a good reason to reject  the model.  That is, to answer
> > your specific question, I think it is acceptable but not
> > sufficient.
> >
> > Patrick Burns
> > patrick <at> burns-stat.com
> > +44 (0)20 8525 0696
> > http://www.burns-stat.com
> > (home of "The R Inferno" and "A Guide for the Unwilling S User") 
> 
> OK. Thanks for this opinion. Actually I was sharing it intuitively but 
> facing such situation for the first time, was quite unconfortable to 
> make a decision (and still I am). We are touching epistemology...  and 
> maybe a bit far from purely technical thus from the R list issues.
> 

  A technical solution to this particular problem:


with(bdd,plot(pourcma~transat))

stval <- list(Asym=30,xmid=0.07, scal=0.02)
with(stval,curve(Asym/(1+exp((xmid-x)/scal)),add=TRUE))

nls(pourcma~SSlogis(transat, Asym, xmid, scal), start=c(Asym=30,
xmid=0.07, scal=0.02),data=bdd, weights=sqrt(nbfeces),trace=T,alg="plinear")

library(bbmle)
m1 <- mle2(pourcma~dnorm(mean=Asym/(1+exp((xmid-transat)/scal)),sd=sd),
           start=c(stval,list(sd=0.1)),method="Nelder-Mead",
           data=bdd)

with(as.list(coef(m1)),curve(Asym/(1+exp((xmid-x)/scal)),add=TRUE,col=2))


  It happens to be able to find the flat-line solution (although it
should really complain about lack of convergence, since the scale parameter
should go to infinity and the midpoint parameter should be arbitrary
in this case -- only Asym and the standard deviation are well
defined).

  Ben Bolker




More information about the R-help mailing list