Hi,
   I apologize if this is trivially simple or exists elsewhere, but I
couldn't find exactly what I am looking for through searching the web.
Basically, I would like to display what the feasible set of portfolios are
for a given linearly constrained problem.  What the code below does, is,
given a set of constraints (including expected return
*equality*constraints) finds the minimum risk portfolios.  In order to
find the
"feasible set", I would also need to find the maximum risk portfolios for
the same levels of expected return, however I am not sure how to do this
with solve.QP.  This would also have to be for a more complicated linear
constraint matrix (group constraints, etc), the one I have below is just a
test case.  I read some slides from various R presentations that had
figures that look like what I want, but I could not find sample code.
Thanks in advance for the help.
The figure on page 19 of the link below is kind of what I have in mind.
Thanks in advance for the help
-Bob
www.zurichr.org/Presentations/ZurichR.pdf



library(quadprog)
mus <- c(.07, .03, -.08, .06, .04)
sigs <- c(.10, .05, .15, .10, .06)
nAss <- 5
set.seed(10)
crs.v <- runif((nAss^2-nAss)/2)
crs <- matrix(0, nAss, nAss)
diag(crs) <- 1
crs[upper.tri(crs)] <- crs.v
crs <- t(crs)
crs[upper.tri(crs)] <- crs.v
cov.mat <- sigs%o%sigs*crs

##Constraints
sumOne <- rep(1, nAss)
longOnly <- cbind(diag(nAss), -diag(nAss))
mnret <- mus
Amat <- cbind(sumOne, mus, longOnly)
bvec <- c(1, NA, rep(0, nAss), rep(-1, nAss))

fp <- 100
mu.rng <- seq(min(mus), max(mus), length.out = fp)
out.mat <- matrix(NA, fp, 2)
dvec <- rep(0, nAss)
for(i in 1:fp){
    bvec[2] <- mu.rng[i]
    ans <- solve.QP(cov.mat, dvec, Amat, bvec, meq = 2)
    wgt <- ans$sol
    out.mat[i,] <- c(sqrt(wgt%*%cov.mat%*%wgt), wgt%*%mus)
}
plot(out.mat[,1], out.mat[,2], main = "'Efficient' Frontier", ylab = "Mu",
xlab = "Sigma", type = "b")

	[[alternative HTML version deleted]]

