Plotting the Efficient Frontier for a PortfolioCVaR Object

The plotFrontier function creates a plot of the efficient frontier for a given portfolio optimization problem. This function accepts several types of inputs and generates a plot with an optional possibility to output the estimates for portfolio risks and returns along the efficient frontier. plotFrontier has four different ways that it can be used. In addition to a plot of the efficient frontier, if you have an initial portfolio in the InitPort property, plotFrontier also displays the return versus risk of the initial portfolio on the same plot. If you have a well-posed portfolio optimization problem set up in a PortfolioCVaR object and you use plotFrontier, you get a plot of the efficient frontier with the default number of portfolios on the frontier (the default number is currently 10 and is maintained in the hidden property defaultNumPorts). This example illustrates a typical use of plotFrontier to create a new plot:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioCVaR;
p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.95);

plotFrontier(p);

The Name property appears as the title of the efficient frontier plot if you set it in the PortfolioCVaR object. Without an explicit name, the title on the plot would be “Efficient Frontier.” If you want to obtain a specific number of portfolios along the efficient frontier, use plotFrontier with the number of portfolios that you want. Suppose that you have the PortfolioCVaR object from the previous example and you want to plot 20 portfolios along the efficient frontier and to obtain 20 risk and return values for each portfolio:

[prsk, pret] = plotFrontier(p, 20);
display([pret, prsk]);
ans =

    0.0051    0.0406
    0.0056    0.0414
    0.0061    0.0437
    0.0066    0.0471
    0.0071    0.0515
    0.0076    0.0567
    0.0082    0.0624
    0.0087    0.0687
    0.0092    0.0753
    0.0097    0.0821
    0.0102    0.0891
    0.0107    0.0962
    0.0112    0.1044
    0.0117    0.1142
    0.0122    0.1251
    0.0127    0.1369
    0.0133    0.1496
    0.0138    0.1628
    0.0143    0.1766
    0.0148    0.1907

Plotting Existing Efficient Portfolios

If you already have efficient portfolios from any of the "estimateFrontier" functions (see Estimate Efficient Portfolios for Entire Frontier for PortfolioCVaR Object), pass them into plotFrontier directly to plot the efficient frontier:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

pwgt0 = [ 0.3; 0.3; 0.2; 0.1 ];

p = PortfolioCVaR('Name', 'Asset Allocation Portfolio', 'InitPort', pwgt0);

p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.95);

pwgt = estimateFrontier(p, 20);
plotFrontier(p, pwgt);

Plotting Existing Efficient Portfolio Risks and Returns

If you already have efficient portfolio risks and returns, you can use the interface to plotFrontier to pass them into plotFrontier to obtain a plot of the efficient frontier:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
      0.00408 0.0289 0.0204 0.0119;
      0.00192 0.0204 0.0576 0.0336;
      0 0.0119 0.0336 0.1225 ];

AssetScenarios = mvnrnd(m, C, 20000);

pwgt0 = [ 0.3; 0.3; 0.2; 0.1 ];

p = PortfolioCVaR('Name', 'Asset Allocation Portfolio', 'InitPort', pwgt0);

p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.95);

pwgt = estimateFrontier(p);

pret= estimatePortReturn(p, pwgt);
prsk = estimatePortRisk(p, pwgt);

plotFrontier(p, prsk, pret);

See Also

| | | |

Related Examples

More About

External Websites