[R] nlm question
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Oct 11 21:31:41 CEST 2004
Thomas Lumley <tlumley at u.washington.edu> writes:
> You might want to look at the function surface, eg:
>
> dd<-expand.grid(x=seq(0,2,length=20),y=seq(0,2,length=20))
> yy<-apply(dd,1,mfun1)
> contour(seq(0,2,length=20),seq(0,2,length=20),matrix(yy,20),nlevels=40)
>
> The function is nearly flat on a fairly wide band where either x or y
> is 1 or slightly larger, and so is far from quadratic in that region.
> You need better starting values, or some rescaling of the objective
> function.
A slight modification is quite revealing:
dd<-expand.grid(x=seq(-1,2,length=100),y=seq(-1,2,length=100))
yy<-apply(dd,1,mfun1)
persp(seq(-1,2,length=100),seq(-1,2,length=100),matrix(yy,100)^.1)
contour(seq(-1,2,length=100),seq(-1,2,length=100),matrix(yy,100)^.1)
abline(v=1.485,h=0)
> Another optimisation algorithm might give different results, and in
> fact if you try optim() you end up at (1,1) with method="Nelder-Mead"
> and method="BFGS", but at (1.48,0) with "CG" or "L-BFGS-B".
And SANN found (1,1) two times out of three for me, the third one
getting stuck in the 3rd local minimum at (-0.72,1.22)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list