Professional Documents
Culture Documents
Abstract
The efrontier Stata command estimates the efficient frontier given
a set of financial assets. The command receives a list of asset returns
and estimates N portfolios that lie in the efficient frontier. It is possible
to include restrictions to form portfolios such as minimum or maximum
weights. The purpose of this tutorial is to illustrate how to use the
efrontier command
1
1.2. Brief description of the efrontier command
The efrontier command uses the mvport command in a loop to estimate a set
of minimum variance portfolios given a range of portfolio returns.
The efrontier command estimates two frontiers: one allowing for short sales,
and another without allowing for short sales.
2
> 36
The weight vector of the Global Minimum Variance Portfolio (NOT Allow Short Sal
> es) is:
Weights
r_AMZN 0
r_ADBE .38931191
r_MSFT 0
r_TSLA .02671568
r_GE .27712718
r_BBT .30684523
r_BWA 0
The return of the Global Minimum Variance Portfolio is: .01274005
The standard deviation (risk) of the Global Minimum Variance Portfolio is: .034
> 73642
Figure 1: Efficient frontier, stocks: AMZN ADBE MSFT TSLA GE BBT BWA
3
To calculate the efficient frontier, the expected returns of the assets are calculated
using geometric average returns using all history of the asset returns. The
variance-covariance matrix is also estimated using continuously compounded
returns.
If you do not specify the number of portfolios to be created the default is 100.
All portfolios in the frontier are part of the estimated results of the command.
To see these results:
. return list
scalars:
r(N) = 7
matrices:
r(exprets) : 7 x 1
r(cov) : 7 x 7
r(sdefws) : 101 x 1
r(sdefwos) : 101 x 1
r(refws) : 101 x 1
r(refwos) : 101 x 1
r(wefws) : 101 x 7
r(wefwos) : 101 x 7
You can see the details of these scalars and matrices using the help of the
command.
To better understand this command, I will use the simport command that
also comes with the mvport package. The simport simulates portfolios using
random weights for the assets. If I generate many random portfolios, it is possible
to appreciate the complete frontier, the efficient and the non-efficient frontier:
. simport r_*, nport(10000)
Random portfolios were generated with no negative weights.
Descriptive statistics of the set of portfolio returns are below:
Variable Obs Mean Std. Dev. Min Max
w1 w2 w3 w4 w5 w6 w7
This commands displays the expected risk, return and weights of the random
portfolio with the least variance.
4
Figure 2: Feasible random portfolios, stocks: AMZN ADBE MSFT TSLA GE
BBT BWA
5
r_AMZN .0108092
r_ADBE .3
r_MSFT .13035701
r_TSLA .08891515
r_GE .28701332
r_BBT .3
r_BWA -.11709467
The return of the Global Minimum Variance Portfolio is: .01453091
The standard deviation (risk) of the Global Minimum Variance Portfolio is: .033
> 82529
Figure 3: For red portfolios, weights are restricted between 5 and 30%
It is also possible to estimate the portfolios using different expected returns and
expected variance-covariance matrix. You can create the vector for expected
returns using any methodology, and the same for the variance-covariance matrix.
Then, you can just input both the vector of expected returns and the variance-
covariance matrix as options.
For example, I can estimate the expected returns assigning more relevance to
the most recent periods. I can use the Exponential Weighted Moving Average
(EWMA) method to assign exponential weights to the periods. Here the example:
. meanrets r_* , lew(0.95)
Expected simple returns (Geometric means):
Exp ret
r_AMZN .0323127
r_ADBE .0291448
r_MSFT .0254862
r_TSLA .0124862
6
r_GE -.0193464
r_BBT .0140553
r_BWA .007895
Observations to calculate expected simple returns: 36
The weights used for the computations is stored in r(W)
Note: the meanrets is a command that comes with the mvport package. I used
a lamda=0.95, so 5% weight will be assigned to the last period, and 95% to the
previous periods using the EWMA method.
I save the vector result in a matrix:
. matrix mrets=r(meanrets)
Now I can use the matrix mrets as option in the efrontier command. Before
this, I will also estimate the variance-covariance matrix using the EWMA method
with lamda=0.95:
. varrets r_* , lew(0.95)
The Variance-Covariance matrix is:
r_AMZN r_ADBE r_MSFT r_TSLA r_GE r_BBT
> r_BWA
r_AMZN .0042676
>
r_ADBE .0024469 .002962
>
r_MSFT .0019524 .0016694 .0028229
>
r_TSLA .0010279 .0012785 .0004686 .0085226
>
r_GE -.0003749 -.0008689 .0002752 .0008513 .0034752
>
r_BBT .0003263 -.0000749 .0002308 -.0002303 .0005797 .002575
>
r_BWA .0013379 .0013393 .0012672 .0022702 .0008258 .0022024
> .0083678
Observations to calculate the var-cov matrix: 36
The weights used for the computations is stored in r(W)
7
r_BWA 0
The return of the Global Minimum Variance Portfolio is: .01041345
The standard deviation (risk) of the Global Minimum Variance Portfolio is: .029
> 77441