Re: [R-SIG-Finance] PortfolioAnalytics: Custom Constraint

2016-09-21 Thread Abhay Bhadani
Thank you, Brian and Ross. That was very helpful. DEoptim and random solvers gave good results. I tested the same using GenSA, which performed worse than pso. Thank you again! :) On Tue, Sep 20, 2016 at 8:53 PM, Brian G. Peterson wrote: > The attached .R file should demonstrate what Ross was

Re: [R-SIG-Finance] PortfolioAnalytics: Custom Constraint

2016-09-20 Thread Brian G. Peterson
The attached .R file should demonstrate what Ross was talking about. The cardinality constraint is directly supported by the stochastic global solvers 'DEoptim' and 'random', as described in the documentation. It can also be formulated as a mixed integer linear problem for certain objective fun

Re: [R-SIG-Finance] PortfolioAnalytics: Custom Constraint

2016-09-20 Thread Ross Bennett
Hi Abhay, The cardinality constraint is not directly support by the pso solver so we have to implement that constraint as a penalized objective. Also note that your box constraint is greater than 0, so the box constraint and position limit constraint are fighting each other (i.e your problem is ov

Re: [R-SIG-Finance] PortfolioAnalytics: Custom Constraint

2016-09-19 Thread Jason Hart
I've never been able to get portfolioanalytics to work for me.  It looks like a nice little addition to the R arsenal but we just weren't meant to work together.  I figured what the heck I'll try this code and I got the same error message I usually get: Error in optimize.portfolio(R = returns,

Re: [R-SIG-Finance] PortfolioAnalytics: Custom Constraint

2016-09-19 Thread Abhay Bhadani
Thanks, Brian! I implemented the following: -- data("edhec") returns <- edhec[,1:12] colnames(returns) <- c("CA","CTAG","DS","EM","EN","ED","FIA","GMLS","MA","RV","SS","FF") print(head(returns,5)) fund.name

Re: [R-SIG-Finance] PortfolioAnalytics: Custom Constraint

2016-09-19 Thread Brian G. Peterson
On Mon, 2016-09-19 at 20:22 +0530, Abhay Bhadani wrote: > I just started exploring PortfolioAnalytics package. > > Similar to setting up custom objective functions, is there a way to set up > custom constraints too? > > I would like to know how to set up cardinality constraint (i.e., limiting > n