[R] adding overall constraint in optim()

Ravi Varadhan r@v|@v@r@dh@n @end|ng |rom jhu@edu
Sat May 5 18:31:26 CEST 2018


Hi,

You can use the projectLinear argument in BB::spg to optimize with linear equality/inequality constraints.



Here is how you implement the constraint that all parameters sum to 1.



require(BB)

spg(par=p0, fn=myFn, project="projectLinear", projectArgs=list(A=matrix(1, 1, length(p0)), b=1, meq=1))



Hope this is helpful,

Ravi


	[[alternative HTML version deleted]]




More information about the R-help mailing list