[R] optim, constrOptim: setting some parameters equal to each other

From: Alex F. Bokov <ahupxot02_at_sneakemail.com>
Date: Sun, 08 Jun 2008 19:15:57 +0000

Hello, and apologies for the upcoming naive questions. I am a biologist who is trying to teach himself the appropriate areas of math and stats. I welcome pointers to suggested background reading just as much as I do direct answers to my question.

Let's say I have a function F() that takes variables (a,b,c,a1,b1,c1) and returns x, and I want to find the values of these variables that result in a minimum value of x. That's a straightforward application of optim(). However, for the same function I also need to obtain values that return the minimum value of x subject to the following constraints: a=a1, b=b1, c=c1, a=a1 && b=b1, a=a1 && c=c1, ... and so on, for any combination of these constraints including a=a1, b=b1, c=c1. The brute force way to do this with optim() would be to write into F() an immense switch statement anticipating every possible combination of constrained variables. Obviously this is inefficient and unmaintainable. Therefore, my question is:

Is the purpose of constrOptim() this exact type of problem? If so, how does one express the constraint I described above in terms of the ui, ci, and theta parameters? Are there any introductory texts I should have read for this to be obvious to me from constrOptim's documentation?

If constrOptim() is not the answer to this problem, can anybody suggest any more elegant alterntives to the switch-statement-from-hell approach?

Thank you very, very much in advance. I thought I understood R reasonably well until I started banging my head against this problem!

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. Received on Sun 08 Jun 2008 - 19:22:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 08 Jun 2008 - 22:30:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive