Thanks, sure you can use NLP.

However, in case you are interested a leverage constraint can be handled in
QP by rewriting the vector to solve for as the sum of a positive and
negative part. Please see
http://zoonek.free.fr/blosxom/R/2012-06-01_Optimization.html
There is an example under "Long-short constraints".



On Mon, Sep 30, 2013 at 3:24 PM, alexios ghalanos <alexios@4dscape.com>wrote:

> 1. This works just fine: (LB and UB should be a vector)
>
> myspec<-parmaspec(S=cov(R),forecast=100*abs(colMeans(R)),LB=rep(-0.05,15),UB=rep(0.05,15),budget=0,risk='EV',riskType='minrisk',target=0.0030346)
> mysol <- parmasolve(myspec,type='QP')
> +---------------------------------+
> |        PARMA Portfolio          |
> +---------------------------------+
> No.Assets               : 15
> Problem                 : QP
> Risk Measure            : EV
> Objective               : minrisk
> Risk                    : 3e-07
> Reward                  : 0.0030346
>
>     Optimal_Weights
> EWG          0.0293
> EEM          0.0206
> EWL          0.0174
> TLT          0.0120
> EZA          0.0107
> EWA          0.0107
> EPP          0.0106
> EWC          0.0094
> IWO          0.0061
> IWN          0.0051
> IWF         -0.0078
> EWJ         -0.0214
> EWU         -0.0221
> IWD         -0.0309
> EWQ         -0.0500
>
>
> 2. You've set leverage with a quadratic solver. How do you suppose the
> absolute value function can be accommodated in this problem?
> This works:
> myspec <-
>
> parmaspec(scenario=as.matrix(R),forecast=100*abs(colMeans(R)),LB=rep(-0.05,15),UB=rep(0.05,15),leverage=0.1,risk='EV',riskType='minrisk',target=0.0030346)
> mysol <- parmasolve(myspec, type='NLP', w0=rep(0.01,15))
> sum(abs(weights(mysol)))
>
> i.e. use a scenario matrix instead and solver as NLP (and make sure to
> provide a set of starting weights 'w0').
>
>
> I suppose I should add more checks/warnings.
>
>
> Regards,
>
> Alexios
>
>
>
> On 30/09/2013 22:52, Preston Li wrote:
> > *Can someone please tell me why the following is not giving me a
> solution?*
> >
> >
> > if (!is.loaded('etfdata')) data(etfdata)
> >
> > R = timeSeries::returns(etfdata)
> >
> >> myspec <-
> >
> parmaspec(S=cov(R),forecast=100*abs(colMeans(R)),LB=-0.05,UB=0.05,budget=0,risk='EV',riskType='minrisk',target=0.0030346)
> >> mysol <- parmasolve(myspec,type='QP')
> >> mysol
> >
> > +---------------------------------+
> > |        PARMA Portfolio          |
> > +---------------------------------+
> > No.Assets               : 15
> > Problem                 : QP
> > Risk Measure            : EV
> > Objective               : minrisk
> > Risk                    : NA
> > Reward                  : NA
> >
> > Error in Math.data.frame(list(Optimal_Weights = logical(0)), 4) :
> >   non-numeric variable in data frame: Optimal_Weights
> >
> > *Whereas if I do the following I get a solution (and why is the
> "leverage"
> > constraint ignored?):*
> >
> >> myspec <-
> >
> parmaspec(S=cov(R),forecast=100*abs(colMeans(R)),LB=-0.05,UB=0.05,budget=0,risk='EV',riskType='optimal',leverage=0.1)
> >> mysol <- parmasolve(myspec,type='QP')
> >> mysol
> >
> > +---------------------------------+
> > |        PARMA Portfolio          |
> > +---------------------------------+
> > No.Assets               : 15
> > Problem                 : QP
> > Risk Measure            : EV
> > Objective               : optimal
> > Risk                    : 3e-07
> > Reward                  : 0.0030346
> >
> >     Optimal_Weights
> > EWG          0.0293
> > EEM          0.0206
> > EWL          0.0174
> > TLT          0.0120
> > EZA          0.0107
> > EWA          0.0107
> > EPP          0.0106
> > EWC          0.0094
> > IWO          0.0061
> > IWN          0.0051
> > IWF         -0.0078
> > EWJ         -0.0214
> > EWU         -0.0221
> > IWD         -0.0309
> > EWQ         -0.0500
> >> sum(abs(mysol@solution$weight)/2)
> > [1] 0.1321498
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-SIG-Finance@r-project.org 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.
> >
> >
>
>

	[[alternative HTML version deleted]]

