投资组合优化约束矩阵/bvec解释 [英] Portfolio Optimization constraints Matrix/bvec explanation

查看:208
本文介绍了投资组合优化约束矩阵/bvec解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近对投资组合优化非常感兴趣,并开始在R中玩转,以创建最小方差投资组合,

I recently got very interested in portfolio optimization and started playing around in R, to create a minimum variance portfolio,

library(quadprog)
Dmat <- matrix(c(356.25808, 12.31581, 261.88302, 12.31581, 27.24840,
18.50515,261.88302, 18.50515,535.45960), nrow=3, ncol=3)
dvec <- matrix(c(9.33, 3.33, 9.07), nrow=3, ncol=1)
A.Equality <- matrix(c(1,1,1), ncol=1)
Amat <- cbind(A.Equality, dvec, diag(3), -diag(3))
bvec <- c(1, 5.2, rep(0, 3), rep(-0.5, 3))
qp <- solve.QP(Dmat, dvec, Amat, bvec, meq=1)

上面的示例具有以下约束条件(例如,此处)

Example above has the following constraints ( example from here)

有4个约束条件:

  • 权重之和等于1
  • 投资组合的预期回报率等于5.2%
  • 每项资产权重均大于0
  • 每个资产权重小于.5

我目前正在尝试刷新矩阵/矢量数学,如果有人能告诉我如何在aMat和bvec以及它们的基本代数背景中将各个约束加在一起,我将不胜感激.另一个问题是权重<0(短裤)的约束看起来如何.

I am currently trying to refresh my matrix/vector math, I would really appreciate if someone could tell me how you add the individual constraints together in aMat and bvec and the basic algebra background for it. And as another question how a constraint for weights <0 (shorting) would look like.

预先感谢

推荐答案

第一步是写下数学模型.可能看起来像:

First step is to write down the mathematical model. That could look like:

下一部分将在R的quadprog中实现.可能看起来像:

The next part is to implement this in R's quadprog. That could look like:

  • 在代码中添加注释可能有助于稍后理解
  • Quadprog不允许变量的简单上下限,因此我们需要将它们转换为> =不等式.
  • 请注意,Quadprog最小化了0.5 * x'Qx.与最小化x'Qx具有相同的结果.
  • 可以通过在x上使用其他下限来限制.
  • 您的数据使该模型不可行.我将分配的上限从0.5放宽到0.8.

这篇关于投资组合优化约束矩阵/bvec解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆