I am using the function optim and I get the error message ABNORMAL_TERMINATION_IN_LNSRCH. Reason for this could be a scaling problem. Thus, I used parscale in order to scale the parameters. But I still have the error message. For example, with parscale=c(rep(1,n), 0.01,1,0.01): return(optim(c(mu1,b,k,phi), neg2loglikelihood, method = "L-BFGS-B", lower=c(rep(-1,n),1e-5,1e-5,1e5) ,upper=c(rep(5,n),1.29,100,1.9),control=list(parscale=c(rep(1,n), 0.01,1,0.01)) ) )>$par[1] 0.9684324 0.9618763 0.9632684 0.9667272 0.9596587 0.9661914 [7] 0.9731076 0.9684477 0.9723313 1.1679275 92.3677202 0.4947495 $value [1] -5438.992 $counts function gradient 177 177 $convergence [1] 52 $message [1] "ERROR: ABNORMAL_TERMINATION_IN_LNSRCH" By using small values for the last parameters, for instance parscale=c(rep(1,n),0.001,0.9,0.001), there is no Error message anymore, but then the parameters (n+1) and (n+3) stay at the starting values and are not optimized anymore. I have tried several different values and combinations for parscale, but either I get the error message ABNORMAL_TERMINATION_IN_LNSRCH or at least one parameter is not optimized. But I want to have both. What can I do? I haven?t specified a gradient function. I am grateful for any suggestions! Thanks you! --
Rebekka Schibli <rebekka_schibli <at> gmx.ch> writes:> > I am using the function optim and I get the error messageABNORMAL_TERMINATION_IN_LNSRCH. Reason for this> could be a scaling problem. Thus, I used parscale in order to scale theparameters. But I still have the> error message. For example, with parscale=c(rep(1,n), 0.01,1,0.01): > > return(optim(c(mu1,b,k,phi), neg2loglikelihood, method = "L-BFGS-B", > lower=c(rep(-1,n),1e-5,1e-5,1e5) > ,upper=c(rep(5,n),1.29,100,1.9), > control=list(parscale=c(rep(1,n), 0.01,1,0.01)) > ) > ) > > >$par > [1] 0.9684324 0.9618763 0.9632684 0.9667272 0.9596587 0.9661914 > [7] 0.9731076 0.9684477 0.9723313 1.1679275 92.3677202 0.4947495 >From these ending parameters it looks as though parscale=c(rep(1,n),1,100,1) would be a better choice? If you can specify a gradient that will probably help. Beyond that, we'll probably have to have a reproducible example in order to provide further help. Ben Bolker
There is an error in your call to `optim'. The`lower' bound is incorrect: lower=c(rep(-1,n),1e-5,1e-5,1e5) This should be: lower=c(rep(-1,n),1e-5,1e-5,1e-5) I am not sure if this fixes the problem, but it is worth a try. I do not understand your scaling. From the lower and upper bounds it seems like (n+2)th parameter is the only one that needs to be scaled by a scale factor of 100. After you have fixed the error in `lower' and the scaling, you might also want to try "optimx" package that runs a bunch of optimization algorithms. Ravi. ------------------------------------------------------- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvaradhan@jhmi.edu<mailto:rvaradhan@jhmi.edu> [[alternative HTML version deleted]]