Mean-variance efficient frontier

As an alternative to frontcon, use the Portfolio object (Portfolio) for mean-variance portfolio optimization. This object supports gross or net portfolio returns as the return proxy, the variance of portfolio returns as the risk proxy, and a portfolio set that is any combination of the specified constraints to form a portfolio set. For information on the workflow when using Portfolio objects, see Portfolio Object Workflow.


[PortRisk, PortReturn, PortWts] = frontcon(ExpReturn,
ExpCovariance, NumPorts, PortReturn, AssetBounds, Groups,
GroupBounds, varargin)



1 by number of assets (NASSETS) vector specifying the expected (mean) return of each asset.


NASSETS-by-NASSETS matrix specifying the covariance of asset returns.


(Optional) Number of portfolios generated along the efficient frontier. Returns are equally spaced between the maximum possible return and the minimum risk point. If NumPorts is empty (entered as [], frontcon computes 10 equally spaced points. When entering a target rate of return (PortReturn), enter NumPorts as an empty matrix [].


(Optional) Vector of length equal to the number of portfolios (NPORTS) containing the target return values on the frontier. If PortReturn is not entered or [], NumPorts equally spaced returns between the minimum and maximum possible values are used.


(Optional) 2-by-NASSETS matrix containing the lower and upper bounds on the weight allocated to each asset in the portfolio. Default lower bound = all 0s (no short-selling). Default upper bound = all 1s (any asset may constitute the entire portfolio).


(Optional) Number of groups (NGROUPS)-by-NASSETS matrix specifying NGROUPS asset groups or classes. Each row specifies a group. Groups(i,j) = 1 (jth asset belongs in the ith group). Groups(i,j) = 0 (jth asset not a member of the ith group).


(Optional) NGROUPS-by-2 matrix specifying, for each group, the lower and upper bounds of the total weights of all assets in that group. Default lower bound = all 0s. Default upper bound = all 1s.


(Optional) varargin supports the following parameter-value pairs:

  • 'algorithm' – Defines which algorithm to use with frontcon. Use either a value of 'lcprog' or 'quadprog' to indicate the algorithm to use. The default is 'lcprog'.

  • 'maxiter' – Maximum number of iterations before termination of algorithm. The default is 100000.

  • 'tiebreak' – Method to break ties for pivot selection. This value pair applies only to 'lcprog' algorithm. The default is 'first'. Options are:

    • 'first' – Selects pivot with lowest index.

    • 'last' – Selects pivot with highest index.

    • 'random' – Selects pivot at random.

  • 'tolcon' – Tolerance for constraint violations. This value pair applies only to 'lcprog' algorithm. The default is 1.0e-6.

  • 'tolpiv' – Pivot value below which a number is considered to be zero. This value pair applies only to 'lcprog'algorithm. The default is 1.0e-9.


[PortRisk, PortReturn, PortWts] = frontcon(ExpReturn, ExpCovariance, NumPorts, PortReturn, AssetBounds, Groups, GroupBounds, varargin) returns the mean-variance efficient frontier with user-specified asset constraints, covariance, and returns. For a collection of NASSETS risky assets, computes a portfolio of asset investment weights that minimize the risk for given values of the expected return. The portfolio risk is minimized subject to constraints on the asset weights or on groups of asset weights.

PortRisk is an NPORTS-by-1 vector of the standard deviation of each portfolio.

PortReturn is a NPORTS-by-1 vector of the expected return of each portfolio.

PortWts is an NPORTS-by-NASSETS matrix of weights allocated to each asset. Each row represents a portfolio. The total of all weights in a portfolio is 1.

frontcon generates a plot of the efficient frontier if you invoke it without output arguments.

The asset returns are assumed to be jointly normal, with expected mean returns of ExpReturn and return covariance ExpCovariance. The variance of a portfolio with 1-by-NASSETS weights PortWts is given by PortVar = PortWts*ExpCovariance*PortWts'. The portfolio expected return is PortReturn = dot(ExpReturn, PortWts).


expand all

Compute the Mean-Variance Efficient Frontier

This example shows how to compute the mean-variance efficient frontier for four points, given three assets with expected returns and expected covariance.

ExpReturn = [0.1 0.2 0.15];

ExpCovariance = [ 0.0100   -0.0061    0.0042
                 -0.0061    0.0400   -0.0252
                  0.0042   -0.0252    0.0225];
NumPorts = 4;

[PortRisk, PortReturn, PortWts] = frontcon(ExpReturn,...
ExpCovariance, NumPorts)
PortRisk =


PortReturn =


PortWts =

    0.2134    0.3518    0.4348
    0.0096    0.4352    0.5552
         0    0.7128    0.2872
         0    1.0000         0

Was this topic helpful?