## 3.10 Problems: Matrix Algebra Review

Exercise 3.1 Use R to answer the following questions.
1. Create the following matrices and vectors $\mathbf{A}=\left[\begin{array}{ccc} 1 & 4 & 7\\ 2 & 4 & 8\\ 6 & 1 & 3 \end{array}\right],\,\mathbf{B}=\left[\begin{array}{ccc} 4 & 4 & 0\\ 5 & 9 & 1\\ 2 & 2 & 5 \end{array}\right],\,\mathbf{x}=\left[\begin{array}{c} 1\\ 2\\ 3 \end{array}\right],\,\mathbf{y}=\left[\begin{array}{c} 5\\ 2\\ 7 \end{array}\right]$
2. Compute the transposes of the above matrices and vectors.
3. Compute $$\mathbf{A}+\mathbf{B},\:\mathbf{A}-\mathbf{B},\,2\mathbf{A},\,\mathbf{Ax},\,\mathbf{AB,\,y^{\prime}Ax}$$
Exercise 3.2 Consider the system of linear equations $\begin{eqnarray*} x+y & = & 1\\ 2x+4y & = & 2 \end{eqnarray*}$
1. Plot the two lines and note the solution to the system of equations. Hint: you can use the R functions abline() or curve() to plot the lines.
2. Write the system in matrix notation as $$\mathbf{Az}=\mathbf{b}$$ and solve for $$\mathbf{z}$$ by computing $$\mathbf{z}=\mathbf{A}^{-1}\mathbf{b}$$.
Exercise 3.3 Consider creating an equally weighted portfolio of three assets denoted A, B, and C. Assume the following information $\mu=\left[\begin{array}{c} 0.01\\ 0.04\\ 0.02 \end{array}\right],\,\Sigma=\left[\begin{array}{ccc} 0.10 & 0.30 & 0.10\\ 0.30 & 0.15 & -0.20\\ 0.10 & -0.20 & 0.08 \end{array}\right].$ Use R to answer the following questions.
1. Create the vector of portfolio weights.
2. Compute the expected return on the portfolio.
3. Compute the variance and standard deviation of the portfolio.
Exercise 3.4 Let $$R_{i}$$ be a random variable denoting the simple return on asset $$i\,(i=1,\ldots,N)$$ with $$E[R_{i}]=\mu_{i},$$ $$\mathrm{var}(R_{i})=\sigma_{i}^{2}$$ and $$\mathrm{cov}(R_{i},R_{j})=\sigma_{ij}.$$ Define the $$N\times1$$ vectors $$\mathbf{R}=(R_{1},\ldots,R_{N})^{\prime},$$ $$\mu=(\mu_{1},\ldots,\mu_{N})^{\prime},$$ $$\mathbf{x}=(x_{1},\ldots,x_{N})^{\prime},$$ $$\mathbf{y}=(y_{1},\ldots,y_{N})^{\prime},$$ and $$\mathbf{1}=(1,\ldots,1)^{\prime}$$, and the $$N\times N$$ covariance matrix $\Sigma=\left(\begin{array}{cccc} \sigma_{1}^{2} & \sigma_{12} & \cdots & \sigma_{1N}\\ \sigma_{12} & \sigma_{2}^{2} & \cdots & \sigma_{2N}\\ \vdots & \vdots & \ddots & \vdots\\ \sigma_{1N} & \sigma_{2N} & \cdots & \sigma_{N}^{2} \end{array}\right).$ The vectors $$\mathbf{x}$$ and $$\mathbf{y}$$ contain portfolio weights (investment shares) that sum to one. Using simple matrix algebra, answer the following questions.
1. For the portfolios defined by the vectors $$\mathbf{x}$$ and $$\mathbf{y}$$ give the matrix algebra expressions for the portfolio returns $$R_{p,x}$$ and $$R_{p,y}$$ and the portfolio expected returns $$\mu_{p,x}$$ and $$\mu_{p,y}$$.
2. For the portfolios defined by the vectors $$\mathbf{x}$$ and $$\mathbf{y}$$ give the matrix algebra expressions for the constraint that the portfolio weights sum to one.
3. For the portfolios defined by the vectors $$\mathbf{x}$$ and $$\mathbf{y}$$ give the matrix algebra expressions for the portfolio variances $$\sigma_{p,x}^{2}$$ and $$\sigma_{p,y}^{2}$$, and the covariance between $$R_{p,x}$$ and $$R_{p,y}$$.
4. In the expression for the portfolio variance $$\sigma_{p,x}^{2}$$, how many variance terms are there? How many unique covariance terms are there?