[R] Constrained Optimisation

Enrico Schumann enricoschumann at yahoo.de
Tue Dec 20 07:02:40 CET 2011


This looks much like the kinds of problems that function 'solve.QP' in 
package 'quadprog' can handle. But if you want people to help you, 
follow the posting guide and 'provide commented, minimal, 
self-contained, reproducible code'. You need to show people what you 
tried and how it failed (so provide actual error messages, and do not 
just say 'it creates an error').

Regards,
Enrico

Am 19.12.2011 20:32, schrieb Russell2:
> Dear All
>
> I have a constrained optimisation problem, I want to maximise the following
> function
>
> t(weights) %*% CovarianceMatrix %*% weights
>
> for the weights,
>
> subject to  constraints on each element within the weights&  the weights
> vector  summing to 1.
>
> i.e.
>
> weights = (x1, x2, x3), where x1 is within some given range (a +b, a - b).
>
> I have tried to do this using the optim function in R, setting the minimum&
> maximum tolerances as lower and upper bounds but once I set the constraint
> of the weights summing to 1 in the function, it creates an error.
>
> I have also looked at the constrOptim&  solveQP packages and have similar
> problems with constraint settings.
>
> Thanks in advance.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Constrained-Optimisation-tp4215341p4215341.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>

-- 
Enrico Schumann
Lucerne, Switzerland
http://nmof.net/



More information about the R-help mailing list