\section{The Markowitz Portfolio Model}\label{S:PortfolioModel}

\newpar
The Markowitz Portfolio Model, created by economist
Harry Max Markowitz, provides a means of maximizing return on an investment portfolio
while at the same time accounting for an investor's attitude toward risk.\footnote{Based upon
Straffin, \cite{Straffin}, (1996)}

\newpar
Suppose we wish to construct a portfolio consisting of four stocks and a certificate of deposit

\be
\item
Pick four stocks and determine the prices of each over an extended period of time. For example,
you may wish to determine the monthly closing price of the stock over a period of several years. Various means exist for acquiring such data. Internet resources, such as Yahoo! Finance, allows the user to specify the
dates of interest for a given stock and whether the closing prices are to be
sampled daily, weekly, or monthly. Data
can then be downloaded in Excel format.

\newpar
Maple's \mf{ExcelTools}\index{Maple!\mf{ExcelTools}} package provides the means to import this data into a Maple worksheet. Suppose closing prices for the first stock has been saved in cells A1 to A100 of a sheet
labeled "stock1" within the Excel file, "stockdata.xls" and that this file is
located in the ``C:$\backslash \backslash$Users'' directory. Then the following syntax imports this data into an $100$ by 1 array, \mf{S}:

\begin{maplelist}
\item \mf{with(ExcelTools):}
\item \mf{S:=Import("C:$\backslash \backslash$Users$\backslash \backslash$","stockdata.xls","stock1", "A1:A100"):}
\end{maplelist}

\newpar
For each stock, we wish to compute its average rate of return per unit time period. For example, if the 100 values described above are collected on the last day of each month, then the rate
of return for month $j$ is given by
\begin{equation}\label{E:MarkowtizePortfolioReturnRateFormula}
r_j = \frac{\mbox{closing price for month $j$-closing price for month $(j-1)$}}{\mbox{closing price for month $(j-1)$}}.
\end{equation}

\item For each stock you selected, compute the corresponding rates of return.


\newpar
The mean\index{mean} and variance\index{variance} of a list of numbers, $\ds \left\{r_1,r_2,\ldots,r_N\right\}$,
are given by
\begin{equation*}
\mu = \frac{1}{N} \sum_{j=1}^{N} r_j \quad \mbox{and}
\quad \sigma^2=\frac{1}{N} \sum_{j=1}^{N} (r_j-\mu)^2,
\end{equation*}
respectively. The second of these measures the extent to which the data deviates
from the mean. Thus a larger variance corresponds to more ``volatility'' in the data.

\item For each of the stocks, compute the corresponding mean and variance of the rates of return.
One way to do
this in Maple is to create a list of these rates of return, one list for each stock. The \mf{Mean}
command\index{Maple!\mf{Mean}} takes each list as its argument and computes the corresponding mean. The \mf{Variance}\index{Maple!\mf{Variance}} command works similarly. Both commands are located in the \mf{Statistics} package. (Note: At this stage, it is highly desirable to make sure at least one of the stocks has a positive mean rate of return. If this is not the case, then we should replace one of our
stocks with one having this property.)

\item Suppose that, in addition to the four stocks, we wish to include a risk-free investment
in our portfolio, such
as a certificate of deposit (CD). If we use a CD, then we must determine its rate of return
per unit time period, where the time period is the same as that used for the stocks, be it daily,
monthly, etc. Select a CD, whose \emph{annual percentage yield} (APY) is known to you.
Use the compound interest formula to determine the rate of return per unit time period that
corresponds to this APY. Call the resulting value, $\mu_5$. Then show that the corresponding
variance is zero, which makes sense for a risk-free investment.

\newpar
With means and variances in hand for the five different investments, we are now in a position to
construct a portfolio. Suppose we let $x_i$, where $1 \leq i \leq 5$, denote the fraction
of our available funds we will devote to investment $i$. Given a sense of how much risk we are willing
to tolerate, we seek to determine values of these weights that maximize the return on our portfolio.
	
\newpar
Suppose we had used specific values of these weights to construct a portfolio for the time period
corresponding to the original data. Then our rate of return of the portfolio for
that given time period would have been
\begin{equation*}
R_j=x_1 r_{1,j}+x_2 r_{2,j}+x_3 r_{3,j}+x_4 r_{4,j}+x_5 r_{5,j} .
\end{equation*}
where $r_{i,j}$ denotes the rate of return during time period $j$ for investment type $i$. In other
words, the daily rate of return for the portfolio would have been merely the weighted sum of the individual rates of return of the five investment types. Suppose we assume that the stocks are diverse enough in nature the rates of return for any pair of them are uncorrelated. Then, elementary statistics dictates that for such a weighted sum, the portfolio mean and variance of $\ds \left\{R_1,R_2,\ldots,R_N\right\}$ are given
by

\begin{align}\label{E:MarkowtizePortfolioPortfolioMeanVariance}
\mu_p &=x_1\mu_1+x_2\mu_2 + x_3\mu_3 +x_4\mu_5+x_5\mu_5 \notag \\
\intertext{and}
\sigma_p^2& =x_1^2\sigma^2_1+x_2^2\sigma^2_2 + x_3^2\sigma^2_3 +x_4^2\sigma^2_4+x_5^2\sigma^2_5.
\end{align}

\newpar
While past performance of a stock is no guarantee of how it will fare in the future, we can still
use the mean and variance in (\ref{E:MarkowtizePortfolioPortfolioMeanVariance}) to estimate
the performance and volatility of a portfolio for a given set of weights.

\newpar
The goal of the investor is to maximize $\mu_p$ and, simultaneously, minimize $\sigma_p^2$. As these are competing goals, we create a single objective function, one that seeks
to determine weights, $x_1$, $x_2$, $x_3$, $x_4$, $x_5$, that maximize $\mu_p$ while assigning a
penalty to large values of $\sigma_p^2$.
The magnitude of the penalty\index{penalty function}
is a function of the investor's risk tolerance. We use the term
\emph{risk aversion parameter} to describe this quantity and denote it
by $\alpha$.

\newpar
We therefore seek to solve the following NLP:
\begin{align}\label{E:MarkowitzModel}
 \mbox{maximize }
 f(x_1,x_2,x_3,x_4,x_5) &=\sum_{i=1}^5 x_i \mu_i - \alpha \sum_{i=1}^5 x_i^2 \sigma_i^2 \\
 \mbox{subject to }
	\sum_{i=1}^5 x_i &=1 \notag \\
  \mbox{and }  x_i \geq 0 \mbox{ for } 1 &\leq i \leq 5.\notag
	\end{align}	


\item The nonlinear programming model (\ref{E:MarkowitzModel}) is a quadratic programming
problem\index{quadratic programming}. By defining a new function, $f$, express it in the standard form:
\begin{align}\label{E:MarkowitzModel2}
 \mbox{ minimize }  f(\vecx ) &= \frac{1}{2}\vecx^t Q \vecx + \vecp^t \vecx \\
	\mbox{ subject to} & \ph \notag\\
	A\vecx &= \vecb \notag \\
    C\vecx &\leq \vecd, \notag
	\end{align}	
where $\vecx$ belongs to $\R^5$ and the remaining matrices and vectors are of appropriate dimensions.
The matrix, $Q$, is a diagonal matrix depending upon $\alpha$ and the individual investment variances.

\item Experiment with various risk aversion parameters and solve
(\ref{E:MarkowitzModel2}) for each value you choose. Describe what happens to the weights and objective function value as $\alpha$ increases, and provide an economic interpretation of the nonzero Lagrange multipliers.
 	
\ee


