Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

## Estimate Efficient Frontiers

Whereas Estimate Efficient Portfolios focused on estimation of efficient portfolios, this section focuses on the estimation of efficient frontiers.

### Obtaining CVaR Portfolio Risks and Returns

Given any portfolio and, in particular, efficient portfolios, the methods estimatePortReturn and estimatePortRisk provide estimates for the return (or return proxy), risk (or the risk proxy). Each method has the same input syntax but with different combinations of outputs. Suppose you have this following portfolio optimization problem that gave you a collection of portfolios along the efficient frontier in pwgt:

```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 = p.setScenarios(AssetScenarios);
p = p.setDefaultConstraints;
p = p.setProbabilityLevel(0.95);

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

p = p.setInitPort(pwgt0);
pwgt = p.estimateFrontier;
```

 Note:   Remember that the risk proxy for CVaR portfolio optimization is CVaR.

Given pwgt0 and pwgt, use the portfolio risk and return estimation methods to obtain risks and returns for your initial portfolio and the portfolios on the efficient frontier:

```prsk0 = p.estimatePortRisk(pwgt0);
pret0 = p.estimatePortReturn(pwgt0);
prsk = p.estimatePortRisk(pwgt);
pret = p.estimatePortReturn(pwgt);
```

You obtain these risks and returns:

```display(prsk0);
display(pret0);
display(prsk);
display(pret);```
```prsk0 =

0.0582

pret0 =

0.0073

prsk =

0.0411
0.0441
0.0520
0.0629
0.0754
0.0891
0.1046
0.1263
0.1535
0.1920

pret =

0.0051
0.0061
0.0071
0.0081
0.0092
0.0102
0.0112
0.0122
0.0132
0.0142```

### Obtaining Portfolio Standard Deviation and VaR

The PortfolioCVaR object has methods to compute standard deviations of portfolio returns and the value-at-risk of portfolios with the methods estimatePortStd and estimatePortVaR. The methods work with any portfolios, not necessarily efficient portfolios. For example, the following example obtains five portfolios (pwgt) on the efficient frontier and also has an initial portfolio in pwgt0. Various portfolio statistics are computed that include the return, risk, standard deviation, and value-at-risk. The listed estimates are for the initial portfolio in the first row followed by estimates for each of the five efficient portfolios in subsequent rows.

```m = [ 0.0042; 0.0083; 0.01; 0.15 ];
C = [ 0.005333 0.00034 0.00016 0;
0.00034 0.002408 0.0017 0.000992;
0.00016 0.0017 0.0048 0.0028;
0 0.000992 0.0028 0.010208 ];

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

p = PortfolioCVaR('initport', pwgt0);
p = p.simulateNormalScenariosByMoments(m, C, 20000);
p = p.setDefaultConstraints;
p = p.setProbabilityLevel(0.9);

pwgt = p.estimateFrontier(5);

pret = p.estimatePortReturn([pwgt0, pwgt]);
prsk = p.estimatePortRisk([pwgt0, pwgt]);
pstd = p.estimatePortStd([pwgt0, pwgt]);
pvar = p.estimatePortVaR([pwgt0, pwgt]);

[pret, prsk, pstd, pvar]```
```ans =

0.0206    0.0465    0.0378    0.0282
0.0996    0.0208    0.0686   -0.0120
0.1119    0.0211    0.0759   -0.0153
0.1243    0.0220    0.0835   -0.0178
0.1367    0.0233    0.0914   -0.0205
0.1490    0.0255    0.0997   -0.0223```

### Plotting the Efficient Frontier

The plotFrontier method creates a plot of the efficient frontier for a given portfolio optimization problem. This method 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 will 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 = p.setScenarios(AssetScenarios);
p = p.setDefaultConstraints;
p = p.setProbabilityLevel(0.95);

p.plotFrontier;```

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 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] = p.plotFrontier(20);
display([pret, prsk]);```
```ans =

0.0051    0.0413
0.0055    0.0422
0.0060    0.0447
0.0064    0.0487
0.0069    0.0537
0.0073    0.0596
0.0078    0.0661
0.0082    0.0730
0.0087    0.0802
0.0091    0.0877
0.0096    0.0954
0.0100    0.1032
0.0105    0.1119
0.0109    0.1219
0.0114    0.1329
0.0118    0.1448
0.0123    0.1574
0.0127    0.1705
0.0132    0.1841
0.0136    0.1979```

#### Plotting Existing Efficient Portfolios

If you already have efficient portfolios from any of the "estimateFrontier" methods (see Estimate Efficient Portfolios), 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 = p.setScenarios(AssetScenarios);
p = p.setDefaultConstraints;
p = p.setProbabilityLevel(0.95);

pwgt = p.estimateFrontier(20);
p.plotFrontier(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 = p.setScenarios(AssetScenarios);
p = p.setDefaultConstraints;
p = p.setProbabilityLevel(0.95);

pwgt = p.estimateFrontier;

pret= p.estimatePortReturn(pwgt)
prsk = p.estimatePortRisk(pwgt)

p.plotFrontier(prsk, pret);```