[R-SIG-Finance] Parma Package QP optimization Failing and Ignoring Leverage Constraint
alexios ghalanos
alexios at 4dscape.com
Tue Oct 1 00:24:09 CEST 2013
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 at solution$weight)/2)
> [1] 0.1321498
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at 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.
>
>
More information about the R-SIG-Finance
mailing list