Skip to content
Prev 308924 / 398503 Next

help using optim function

tmuman <mumantariq <at> gmail.com> writes:
method=c('Nelder-Mead'),
           fn=least.squares.fit,
            lower=low.constraints,
   upper=high.constraints,data=data,scale=scale,ploton=ploton)
    return(result)                                                              }
You haven't given us much to work with here -- have you
read the posting guide (URL at the bottom of every message)?
It's not reproducible ( http://tinyurl.com/reproducible-000 ),
and you haven't told us what's going wrong.  Are you getting
error messages?  What are they?  Warnings?  No errors but
you have reason to believe the answer is wrong?

A few comments:
*   'scale' and 'ploton' are not arguments to optim(),
so they'd better be accepted by your least.squares.fit() function
* the Nelder-Mead algorithm doesn't accept constraints (lower/upper)
  (see the nloptr package for a Nelder-Mead implementation that does)
* except for the constraints, you might be better off with ?nls
if all you want to do is least-squares fitting; nlsLM in the
minpack.lm package does least-squares fitting with constraints