I would like to find the minimum variance portfolio for 3 risky assets where the sum of the weights of all assets = 2 and weight of asset1 is set at +1 (i.e the problem would be to minimise the portfolio vol by adjusting only the weights for asset asset 2 and 3 subject to them not being more than 1 and >=0. I have found the below snippet of code that minimise the risk for a 3 asset portfolio, but I am unsure about how to incorporate the weight constraints. Any help / suggestions are welcome.
covmat <- matrix(c(3.235343e-02, -3.378191e-03, -1.544574e-05, -3.378191e-03, 8.769166e-03, 1.951734e-06, -1.544574e-05, 1.951734e-06, 2.186799e-06),3,3) mat <- rbind(cbind(2*covmat,rep(1, 3)), c(rep(1, 3), 0)) vec <- c(rep(0, 3),1) smat <- solve(mat)%*%vec smat[1:3,1] Thank you,