# PortfolioAnalytics Package Questions on Initial Weights & Group Constraints Classic List Threaded 3 messages Open this post in threaded view
|

## PortfolioAnalytics Package Questions on Initial Weights & Group Constraints

 Dear R-sig-finance Group, I have 3 of questions about the PortfolioAnalytics package: 1) I'm using DEOptim optimization.  And I use the following initialization:   i.portf <- portfolio.spec(assets=allInstruments,                             weight_seq=generatesequence(min = 0.001,                                                         max = 0.06,                                                         by = 0.002)) I believe that the initial portfolios are generated randomly using random_portfolios.   However, if I wanted to specifically pre-set one of the portfolios to a given set of predefined weights, would that be possible with DEOPtim? 2) I'm using group constraints to specify the sum of weights by group.  For example on Sectors:   for( jj in 1:length(uniqueSectors)){     group_indices <- which(sectors == uniqueSectors[jj])     groupsum <- sum(benchmark_weights[group_indices])     groupmax <- 0.1 + groupsum     groupmin <- -0.1 + groupsum     groupmins[jj]   <- groupmin     groupmaxs[jj]   <- groupmax     grouplist[[jj]] <- group_indices   }     i.portf <- add.constraint(portfolio=i.portf,                               type="group",                               groups=grouplis,                               group_min=groupmins,                               group_max=groupmaxs,                               group_labels=groupnames)   There is nothing stopping me from making two separate add.constraint() group calls by splitting the initial groups' constraints into 2     i.portf <- add.constraint(portfolio=i.portf,                               type="group",                               groups=grouplist[1:5],                               group_min=groupmins[1:5],                               group_max=groupmaxs[1:5],                               group_labels=groupnames[1:5])     i.portf <- add.constraint(portfolio=i.portf,                               type="group",                               groups=grouplist[5:10],                               group_min=groupmins[5:10],                               group_max=groupmaxs[5:10],                               group_labels=groupnames[5:10]) What is the difference when I split the group constraints into two instead of 1?  Based on my tests these two are not the same; it seems that splitting the group constraints into 2 is less restrictive(?) than if I just have one group add.constraint() 3) There is a maximum position constraint--for example pspec <- add.constraint(portfolio=pspec, type="position_limit", max_pos=3) Is there a reason that a minimum position constraint was not/cannot be implemented? Thanks & Regards, -Ed         [[alternative HTML version deleted]] _______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance-- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.