quadprog

How to allow for weights between -1 and 1 using constraints in Aeq x <= beq

半世苍凉 提交于 2019-12-24 08:57:05
问题 I am using quadprog to find a portfolio of optimal weights. So far, I have managed to implement long-only and short-only constraints as follows: FirstDegree = zeros(NumAssets,1); SecondDegree = Covariance; Long only Aeq = ones(1,NumAssets); beq = 1; A = -eye(NumAssets); b = zeros(NumAssets,1); x0 = 1/NumAssets*ones(NumAssets,1); MinVol_Weights = quadprog(SecondDegree,FirstDegree,A,b,Aeq,beq,[],[],x0, options); Short-only Aeq = ones(1,NumAssets); beq = -1; A = eye(NumAssets); b = zeros

Minimizing quadratic function subject to norm inequality constraint

杀马特。学长 韩版系。学妹 提交于 2019-12-12 07:24:00
问题 I am trying to solve the following inequality constraint: Given time-series data for N stocks, I am trying to construct a portfolio weight vector to minimize the variance of the returns. the objective function: min w^{T}\sum w s.t. e_{n}^{T}w=1 \left \| w \right \|\leq C where w is the vector of weights, \sum is the covariance matrix, e_{n}^{T} is a vector of ones, C is a constant. Where the second constraint ( \left \| w \right \| ) is an inequality constraint (2-norm of the weights). I

error while installing quadprog package in R for MAC

二次信任 提交于 2019-12-11 00:48:51
问题 I'm trying to install the quadprog package in R in mac but it keeps showing this massage: installing source package ‘quadprog’ ... ** package ‘quadprog’ successfully unpacked and MD5 sums checked ** libs gfortran-4.8 -fPIC -g -O2 -c aind.f -o aind.o make: gfortran-4.8: No such file or directory make: *** [aind.o] Error 1 ERROR: compilation failed for package ‘quadprog’ removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/quadprog’ Anybody know what I should do to have it

Portfolio Optimisation under weight constraints

北慕城南 提交于 2019-12-09 20:17:19
问题 With a lot of help from contributors to StackOverflow I have managed to put together a function to derive the weights of a 2-asset portfolio which maximises the Sharpe ratio. No short sales are allowed and the sum of weights add to 1. What I would like to do now is to constrain asset A to not being more or less than 10% from a user defined weight. As an example I would like to constrain the weight of asset A to be no less than 54% or more than 66% (i.e 60% +/- 10%). So on the below example I

How to use R package Quadprog to solve SVM?

耗尽温柔 提交于 2019-12-07 11:08:48
问题 I was wondering what's the proper way to implement Quadprog to solve quadratic programming. I have the following question(ripped from the internet)and also was looking at the following http://cbio.ensmp.fr/~thocking/mines-course/2011-04-01-svm/svm-qp.pdf What would be the proper way to solve this issue? Would this tutorial be useful to solve if i was given a question like above? http://www.r-bloggers.com/solving-quadratic-progams-with-rs-quadprog-package/ 回答1: Here is an implementation, for

Why doesn't solve.QP and portfolio.optim generate identical results?

蓝咒 提交于 2019-12-06 13:49:18
问题 The documentation for portfolio.optim {tseries} says that solve.QP {quadprog} is used to generate the solution for finding the tangency portfolio that maximizes the Sharpe ratio. That implies that results should be identical with either function. I'm probably overlooking something, but in this simple example I get similar but not identical solutions for estimating optimal portfolio weights with portfolio.optim and solve.QP. Shouldn't the results be identical? If so, where am I going wrong?

How to use R package Quadprog to solve SVM?

坚强是说给别人听的谎言 提交于 2019-12-05 17:35:53
I was wondering what's the proper way to implement Quadprog to solve quadratic programming. I have the following question(ripped from the internet)and also was looking at the following http://cbio.ensmp.fr/~thocking/mines-course/2011-04-01-svm/svm-qp.pdf What would be the proper way to solve this issue? Would this tutorial be useful to solve if i was given a question like above? http://www.r-bloggers.com/solving-quadratic-progams-with-rs-quadprog-package/ Here is an implementation, for linear C-SVM, which is based on the primal optimization problem: min_{beta_0, beta, zeta} 1/2 w^T w + C sum_

Why doesn't solve.QP and portfolio.optim generate identical results?

旧巷老猫 提交于 2019-12-04 19:33:44
The documentation for portfolio.optim {tseries} says that solve.QP {quadprog} is used to generate the solution for finding the tangency portfolio that maximizes the Sharpe ratio. That implies that results should be identical with either function. I'm probably overlooking something, but in this simple example I get similar but not identical solutions for estimating optimal portfolio weights with portfolio.optim and solve.QP. Shouldn't the results be identical? If so, where am I going wrong? Here's the code: library(tseries) library(quadprog) # 1. Generate solution with solve.QP via: comisef

Portfolio Optimisation under weight constraints

喜欢而已 提交于 2019-12-04 15:14:24
With a lot of help from contributors to StackOverflow I have managed to put together a function to derive the weights of a 2-asset portfolio which maximises the Sharpe ratio. No short sales are allowed and the sum of weights add to 1. What I would like to do now is to constrain asset A to not being more or less than 10% from a user defined weight. As an example I would like to constrain the weight of asset A to be no less than 54% or more than 66% (i.e 60% +/- 10%). So on the below example I would end up with weights of (0.54,0.66) instead of the unsconstrained (0.243,0.7570) .I assume this

Constraints on weight in portfolio optimization using quadprog package in R

喜欢而已 提交于 2019-12-01 05:46:10
问题 I am new to using R and portfolio optimization. I am trying to optimize a portfolio with 7 assets such that asset number 3 and 4 have a minimum weight of 0.35 each and the sum of all 7 assets equal to 1. Following is the code I have tried: library(quadprog) dmat <- cov(dr) #dr stores the daily return of the 7 assets and is a timeSeries object dvec <- colMeans(dr) c1 <- c(0,0,1,0,0,0,0) c2 <- c(0,0,0,1,0,0,0) amat <- t(rbind(matrix(1, ncol = ncol(dmat)), c1, c2)) #used transpose because