Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working through this paper.

I want to implement the robust Bayesian optimization (see pages 6 onward) in Matlab using fmincon.

Here is a brief overview of my problem:

Let $\alpha$ be the vector of returns and let $w$ be ta set of weights representing a portfolio.

Then, our usual mean-variance problem is to find the resultant portfolio weights that minimize the portfolio variance $\sigma^2(x)=w' \Sigma w$.

In the robust framework, the vector of returns is assumed to lie in some uncertainty region, call it $U$. Here, the authors define that region to be the sphere centered at $\alpha$ with radius equal to $|\chi| \cdot \alpha$ with $\chi \in [0,1]$.

In other words, our optimization problem now becomes:

$\min_\omega\omega'\Sigma\omega$ subject to $\min_Ur_p \geq r_0$

where $\Sigma$ is a positive definite matrix and $\omega$ is a vector of weights that sum to 1.
Also: $r_p=\alpha'\omega$.

The authors show that:

$$\min_U r_p=|\alpha||w|[cos(\phi)-\chi]$$

where $\phi$ is the angle between the two vectors $\alpha$ and $\omega$.$

They give the formula for the "the robust covariance matrix family" - (see page 7 eq 13) as well as the formula for the optimized weights (see page 7 eq 12).

I am trying to implement this in Matlab. However, one cannot use equations 12 or 13 as both equations require the optimized weights to be known.

My question is therefore, is there a method to implement a robust optimization such as this OR any suggestions as to how I could go about doing this???

share|improve this question
up vote 3 down vote accepted

From a general point of view and to answer directly to your originial question, you should only have to modify the inputs to the MATLAB function you refer to. As a matter of fact, fmincon is an optimizer looking to process a broad variety of problems as explained in the documentation:

fmincon attempts to find a constrained minimum of a scalar function of several variables starting at an initial estimate. This is generally referred to as constrained nonlinear optimization or nonlinear programming.

You will not have to modify anything to the algorithm per say. You just need to make sure to get the inputs right which in this case is the target function you pass to fmincon.

For example, if you only want to use a shrinked matrix (given by equation 9 on page 5) to obtain a more robust mean variance portfolio, you can do the following:

robustMinVar = fmincon(@(x)(x' * SigmaHat * x), ...);

where SigmaHat is the shrinked covariance matrix you previously computed.

I assume you are willing to compute the following:

$$\underset{w}{\arg \min} ~ \sigma^2(w) \quad \text{s.t.} \quad \underset{U_\alpha}{\arg \min} ~ r_P \geq r_0$$

You need to generate two functions:

  • $f(w)$, the target function
  • $c(w)$ a constraint function.

The constraint function is supposed to return the value of $\underset{U_\alpha}{\arg \min} ~ r_P$ and can be computed as mentioned in the formula.

So in your script, simply do:

% Here I define my variables
function r=bayesConst(w)
  r= -(alpha' * w - chi* sqrt(sum(alpha.^2))*sqrt(sum(w.^2))-r0);

Note here that you create a function within the script to inject the variable alpha and chi and r0. Notice also that I set up the function such that it has the form $c(w) \leq 0$. You have to input this in fmincon as a non-linear constraint (the nonloncon argument).

Now the other function is just computing the minimum variance with $w$, but I don't know if we should use the shrinked covariance matrix (of page 7) or not I would say yes intuitively.

share|improve this answer
Thanks for your response! – Geraldine Bailey Jan 29 '13 at 17:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.