[R] Porting optimisation setup from Excel Solver to R

Puneet Singh puneetsingh77 at yahoo.com
Fri Dec 10 12:54:15 CET 2004

Hi all,

I am currently optimising a small portfolio I have
created as a part of my research project in Excel. I
am unable to find the appropriate package to port this
into R. My problem set up is as follows

Minimise ABS(Sum(Xi-Xi')+10*Sum(XiMi)/Mavg)

Subject to:
0 <= Xi <= 0.05
ABS(Sum(Xi)) = 0.2

Mi - Market Cap of Stock i
Xi - Initial weight of Stock i
Xi' - New weight of Stock i
Mavg = Average weighted market cap of portfolio.

My portfolio has a long as well as a short side,
therefore the ABS. The minimisation function is
basically a penalty on the change from initial weight
and the distance from the Average market cap. 

My problem is that I need to optimise a vector X with
the weights instead of one weight at a time... i.e. I
need to be able to change all the stocks in the
portfolio simultaneously. I am able to do this EASILY
in Excel, but have not found any straightforward
application/formulation in R.

Any help would be much appreciated.

Puneet Singh
MBA Student
Indian Institute of Management Calcutta, India


Send a seasonal email greeting and help others. Do good.

More information about the R-help mailing list