mwdavis@nist.gov
2005-Jun-08 00:52 UTC
[R] Bounding or constraining parameters in non-linear regressions
Dear R-Users, Being an engineer and not a statistician, my desired course of action may either be impossible or very simple. I am attempting to fit a non-linear model to some measured data. One term in the model contains a square-root, but in the course of regression, this term turns negative and an error occurs. I started using Micrsoft's Excel Solver, and then I turned to NIST's Datplot statistical package. I can constrain in Solver, but it violates those constraints. :) Dataplot does not have the capability to constrain parameters. Does R have the capability to constrain or bound parameters in non-linear regressions? Thanks, Mark Davis
Douglas Bates
2005-Jun-08 14:39 UTC
[R] Bounding or constraining parameters in non-linear regressions
On 6/7/05, mwdavis at nist.gov <mwdavis at nist.gov> wrote:> Dear R-Users, > > Being an engineer and not a statistician, my desired course of action may > either be impossible or very simple. > > I am attempting to fit a non-linear model to some measured data. One term in > the model contains a square-root, but in the course of regression, this term > turns negative and an error occurs. I started using Micrsoft's Excel Solver, > and then I turned to NIST's Datplot statistical package. I can constrain in > Solver, but it violates those constraints. :) Dataplot does not have the > capability to constrain parameters. > > Does R have the capability to constrain or bound parameters in non-linear > regressions?Sort of. If you look at the stats package in r-devel you will see that a function called nlminb has been added. This function calls optimization software from the Port package (http://www.netlib.com/port/). The Fortran code for constrained nonlinear least squares problems is included in the package but the interface code for R has not yet been written. The energetic could create such interface code by emulating that for nlminb - it's not that long. Alternatively you could use either optim or nlminb on the function which is the residual sum of squares from your model.