Here is another approach using an augmented penalty lagragian method.
The same example:
fr <- function(x) { ## Rosenbrock Banana function
x1 <- x[1]
x2 <- x[2]
100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
fr.pen <- function(x, k=1e05) {
fr(x) + k * ( 1 - sum(x))^2
}
require(BB)
spg(par=c(0, 0), fn=fr.pen) # Note: this starting value will fail for the
"projection method" due to division by zero
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: [email protected]
Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
----------------------------------------------------------------------------
--------
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of dre968
Sent: Wednesday, April 22, 2009 8:23 AM
To: [email protected]
Subject: [R] Help using spg optimization in BB package
i'm trying to use the BB package to minimize the sum of the squared
deviations for 2 vectors. The only thing am having trouble with is defining
the project constraint. I got the upper and lower bounds to work but i am
not sure how to create a constraint that the sum of x must be 1. Any help
would be greatly appreciated.
--
View this message in context:
http://www.nabble.com/Help-using-spg-optimization-in-BB-package-tp23175224p2
3175224.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
[email protected] 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.
______________________________________________
[email protected] 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.