Skip to content
Prev 175273 / 398506 Next

nls, convergence and starting values

Patrick Giraudoux <patrick.giraudoux <at> univ-fcomte.fr> writes:
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