Modelling the efficient frontier

I’ve got a model with 30 stocks in it, but whenever I run solver to try to minimize variance, it says it can’t find a feasible solution. Is the efficient frontier just not going to work with 30 stocks?

So you’re doing this in excel? You don’t provide much on how you’re doing it. I would rather do it in matlab, but here’s some tips on excel. Off hand, I would guess that the issue is that you have set the expected return higher than is possible given the constraints. Solver will fail if you set the return constraint bigger (smaller) than the value of the strongest (weakest) stock and have weights summing to 1. Alternately, try running it with an expected return you KNOW will work. If this isn’t the issue, I assume you calculated the covariance matrix properly. For portfolio variance, you might try doing everything with matrix math (so mmult(mmult(transpose(wgt),sigma),wgt) would be the relevant formula for portfolio variance, similarly mmult(transpose(wgt),return) for portfolio return). Also, try running it with only a constraint summing the weights 1 and avoid any inequality constraints. Inequality constraints are generally slower and could be causing a problem if the other things are working properly. If you’re okay with short positions, you can just use the following formula and adjust the risk aversion coefficient to get the optimal portfolios: wmin+(1/RA)*sigma-1*(I-1*wmin’)*u, where wmin is the minimum variance portfolio, RA is risk aversion, sigma-1 is the inverse of the covariance matrix, I is an nxn identity matrix, 1 is a nx1 vectors of 1s, and u is expected returns. Solver is really only needed if you want to include inequality constraints.

Depending how you are trying to solve this, you can have problems with the covariance matrix not being positive definite. Covariances matrices are supposed to be positive definite but if you don’t do a good job with missing data you aren’t guaranteed to get one. Since the way that everyone starts out making covariance matrices is to just fill in the pairwise covariances for whatever days they have data, you can get nailed. For only a small fee I would send you code for my EM-based guaranteed positive definite high tech wonder covariance matrix calculator… BTW - I think regular Excel Solver is a pretty good tool for the amount that you pay for it (which is something like nothing since everyone has Office for all the other stuff)

I agree with jmh. You have to tell more about what you are actually doing since you are probably not setting up the problem correctly.

Thanks guys, it might be easier if I just email the model to one of you. I’d gladly kick in 10 bucks via pay pal for your services. Or if you don’t want your email public, you can just email me at wblakef@tulane.edu. Basically what I’ve done is taken the monthyl returns for the past 2 years of the 30 stocks, and then used =MMULT(TRANSPOSE(returns),returns)/(COUNT(1st column)-1) and did an array for the varcovar matrix.