I tried to use calcMin with a function that uses a number of ... arguments (all args from resid on) besides the vector of parameters being fit. Same idea as optim, nlm, nlminb for which this form of ... syntax works. But with calcMin I get an error regarding unused arguments. No partial matches to previous arguments that I can see. Anybody know the reason or fix for this?
calcMin(pvec=data.frame(val=par,min=rep(.000001,length(par)),max=rep(100 0000,length(par)),active=rep(TRUE,length(par))),func=optimwrap2, resid=resid,caa=caa,na=na,vcode=vcode,maa=maa,ny=ny,nind=nind,qage=qage, selmod=selmod,oldagei=oldagei,vpaflag=vpaflag) Error in f(x, ...) : unused argument(s) (resid = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), caa = c(0.344919912565012, 1.36925481463155, 4.94519930946541, 5.12996667120799, 11.0171415280463, 9.4432641668968, 4.7216320834484, 3.14775472229893, 1.57387736114947, 3.14775472229893, > And an example using optim to address concerns about the user function itself. [I'm trying to concoct a solver that handles far-off initial parameter values without getting stuck in local minima. I'm searching for something faster and more intelligent than this example.] > for(i in 1:9) { + fitpars=optim(par=parset1,fn=optimwrap,control=list(maxit=100),resid=res id,caa=caa,na=na,vcode=vcode,maa=maa,ny=ny,nind=nind,qage=qage,selmod=se lmod,oldagei=oldagei,vpaflag=vpaflag) + parset2=fitpars$par + parval2=fitpars$value + print(parval2) + print(parset2) + if((parval1-parval2)>1.0) { + parval1=parval2 + parset1=parset2 + } + if((parval1-parval2)<1.0 & parval2>0.1) { + parset1=par*pardown[i] + } + } [1] 193.1500 [1] 43.84105 43.47576 42.91166 41.81009 42.57930 [1] 15.69411 [1] 13.35845 12.52650 12.28231 11.78171 11.29699 [1] 15.65625 [1] 11.91989 11.10244 10.84155 10.34886 9.85170 [1] 15.45980 [1] 10.374731 9.569294 9.302000 8.779963 8.325952 [1] 14.85332 [1] 9.105026 8.293079 8.004561 7.521170 7.080387 [1] 8.18217 [1] 6.209737 5.876993 5.229392 4.887182 4.102208 [1] 6.720143 [1] 6.180562 5.276061 5.057946 4.561191 4.317552 [1] 0.04003793 [1] 3.754422 2.871289 2.876904 2.091451 1.806243 [1] 0.04003793 [1] 3.754422 2.871289 2.876904 2.091451 1.806243 Mark Fowler Population Ecology Division Bedford Inst of Oceanography Dept Fisheries & Oceans Dartmouth NS Canada B2Y 4A2 Tel. (902) 426-3529 Fax (902) 426-9710 Email mark.fow...@dfo-mpo.gc.ca Home Tel. (902) 461-0708 Home Email mark.fow...@ns.sympatico.ca [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.