[R] constrained optimisation in R.

Ravi Varadhan RVaradhan at jhmi.edu
Thu Jul 2 19:15:27 CEST 2009


Please tell us about the actual problem that you are trying to solve,
because the "answer" would very much depend on that. 

Are your constraints really sum(par) = 0?  If so, you can just eliminate one
of the parameters and solve the optimization problems with (p-1) parameters.

If you have other constraints on the parameters such that par[i] > 0, then
you can use any one of the optimization functions that allow for
box-constraints (e.g. optim() with method="L-BFGS-B", nlminb(), spg() in
"BB" package).  

If you have convex inequality constraints, you can use constrOptim().  If
you have nonlinear inequalities you may try Rdonlp2, or you can use a
function that I have written that extends constrOptim() to handle non-linear
inequalities.

As you can see, the answer depends upon what type of constraints you really
have.

Ravi.


----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 

----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Iason Christodoulou
Sent: Thursday, July 02, 2009 11:56 AM
To: r-help at r-project.org
Subject: [R] constrained optimisation in R.


i want to estimate parameters with maximum likelihood method with contraints
(contant numbers).
for example
sum(Ai)=0 and sum(Bi)=0
i have done it without the constraints but i realised that i have to use the
contraints.


Without constraints(just a part-not complete):

skellamreg_LL=function(parameters,z,design)      
{
n=length(z);
mu=parameters[1];
H=parameters[2];
Apar=parameters[3:10];      
Dpar=parameters[11:18];   

res=optim(par,skellamreg_LL,method="Nelder-Mead", hessian = FALSE,
control=list(trace=1000,maxit=100000),z=z,design=x,)

_________________________________________________________________


	[[alternative HTML version deleted]]

______________________________________________
R-help at 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.




More information about the R-help mailing list