Accelerating the pace of engineering and science

# Documentation

## Estimate Efficient Frontiers

Whereas Estimate Efficient Portfolios focused on estimation of efficient portfolios, this section focuses on the estimation of efficient frontiers. For information on the workflow when using Portfolio objects, see Portfolio Object Workflow.

### Obtaining Portfolio Risks and Returns

Given any portfolio and, in particular, efficient portfolios, the methods estimatePortReturn, estimatePortRisk, and estimatePortMoments provide estimates for the return (or return proxy), risk (or the risk proxy), and, in the case of mean-variance portfolio optimization, the moments of expected portfolio returns. 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 ];
pwgt0 = [ 0.3; 0.3; 0.2; 0.1 ];
p = Portfolio('AssetMean', m, 'AssetCovar', C, 'InitPort', pwgt0);
p = setDefaultConstraints(p);
pwgt = estimateFrontier(p);
```

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, pret0] = estimatePortMoments(p, pwgt0);
[prsk, pret] = estimatePortMoments(p, pwgt);
```

or

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

In either case, you obtain these risks and returns:

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

0.1103

pret0 =

0.0870

prsk =

0.0769
0.0831
0.0994
0.1217
0.1474
0.1750
0.2068
0.2487
0.2968
0.3500

pret =

0.0590
0.0725
0.0859
0.0994
0.1128
0.1262
0.1397
0.1531
0.1666
0.1800
```

Note the returns and risks are at the periodicity of the moments of asset returns so that, if you have values for AssetMean and AssetCovar in terms of monthly returns, the estimates for portfolio risk and return are in terms of monthly returns as well. In addition, the estimate for portfolio risk in the mean-variance case is the standard deviation of portfolio returns, not the variance of portfolio returns.

### 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 Portfolio 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 ];
pwgt0 = [ 0.3; 0.3; 0.2; 0.1 ];

p = Portfolio('Name', 'Asset Allocation Portfolio', 'InitPort', pwgt0);
p = setAssetMoments(p, m, C);
p = setDefaultConstraints(p);
plotFrontier(p);```

The Name property appears as the title of the efficient frontier plot if you set it in the Portfolio 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 Portfolio 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.0590    0.0769
0.0654    0.0784
0.0718    0.0825
0.0781    0.0890
0.0845    0.0973
0.0909    0.1071
0.0972    0.1179
0.1036    0.1296
0.1100    0.1418
0.1163    0.1545
0.1227    0.1676
0.1291    0.1810
0.1354    0.1955
0.1418    0.2128
0.1482    0.2323
0.1545    0.2535
0.1609    0.2760
0.1673    0.2995
0.1736    0.3239
0.1800    0.3500```

#### 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 ];
pwgt0 = [ 0.3; 0.3; 0.2; 0.1 ];

p = Portfolio('Name', 'Asset Allocation Portfolio', 'InitPort', pwgt0);
p = setAssetMoments(p, m, C);
p = setDefaultConstraints(p);
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 ];
pwgt0 = [ 0.3; 0.3; 0.2; 0.1 ];

p = Portfolio('Name', 'Asset Allocation Portfolio', 'InitPort', pwgt0);
p = setAssetMoments(p, m, C);
p = setDefaultConstraints(p);
[prsk, pret] = estimatePortMoments(p, p.estimateFrontier(20));
plotFrontier(p, prsk, pret);```