You are on page 1of 26

Investment Analysis GBF459

Short notes on Matrix Algebra Dr. Dimitris A. Tsouknidis

Key Concepts
Matrix Algebra Finding the inverse matrix Solving systems of equations

Matrix Algebra
A matrix is simply a rectangular array of numbers. Some examples:

The dimensions of a matrix is given by the number of rows and columns, so that the above matrices have dimensions 3x3, 2x2, 3x1, and 1x1.

Matrix Algebra
The elements of a matrix are addressed by row and column so that, for example:

A is an example of a square matrix, i.e. One with equally many rows as columns. Examples of symmetric and diagonal matrices are

The diagonal where A_2 has its non-zero entries is called the principal or the main diagonal.
4

Matrix Addition and Subtraction


And we can define addition and subtraction between matrices:

For addition and subtraction to be defined, the matrices need to be of the same dimensions, i.e. have the same number of rows and columns. Note that these operations also can be described by

...and Multiplication too...

For multiplication to be defined, the first matrix must have the same number Of columns as the second matrix has row. The result will have as many rows as the first matrix, and as many columns as the second one. Again, note:

...and Multiplication too... (contd)


5 6 3 4 9 7 6 4 12 5 1 = 2 7 9 12 56 + 41 + 912 136 142 66 + 41 + 1212 = 170 184 36 + 21 + 712 94 104

57 + 45 + 99 67 + 45 + 129 37 + 25 + 79

...but Division needs some thought


The number 1 is replaced by the Identity Matrix and the inverse to A is defined by

For example:

Note that AB is usually not equal to BA, and both are defined only when both A and B are square matrices. And not every matrix has an inverse.
8

Finally, some more definitions


A matrix with only one row or column is called a vector:

And the transpose of a matrix is defined by

How to find the inverse ?


Recall that A x A-1 = I, A matrix that has an inverse is called invertible Only square matrices have inverses and are called nonsingular There are many techniques to define the inverse of a matrix, we will discuss the Gauss-Jordan method: 2 4 Say you need to find the inverse of A = 4 2 The first step is to augment it with the identity matrix: 2 4 1 0 , we will refer to this augmented matrix as matrix A. 4 2 0 1 Next a series of row operations will be performed until the identity matrix appears on the left side of matrix A. Since the same row operations will be applied on both sides, the right side elements will comprise the inverse matrix A-1
10

How to find the inverse ?


Step 1: Replace the upper left corner value 2 with 1: 1 2 0.5 0 , 1A x 0.5 = 1B , 1A refers to the new row 4 2 0 1
Step 2: Obtain a zero in the lower left corner by multiplying row 2 in A by and subtracting the result from the row 1A: 1 0 2 0.5 0 1 , 1.5 0.5 4 1A x 0.5 = 1B, 1B-(2A x )
1 4

Step 3: Obtain an 1 in the lower right corner of the left side matrix by multiplying row 2B by 2/3: 1 0 0 2 0.5 1 1 , 1 3 6 2B x ( ) = 2C
11

2 3

How to find the inverse ?


Step 4: Obtain a zero in the upper left right corner of the left side matrix by multiplying row 2C by 2 and subtracting from 1B:
1 0 0 1
1 6 1 3 1 3

1 6

1B - (2C x 2) = 1C

The left side of the augmented matrix is the identity matrix and the right side is the A-1, the inverse of matrix A.

12

How to find the inverse ?


Allowable row operations include the following:
Multiply a given row by any nonzero constant. Each element in the row must be multiplied by the same constant. Add a given row to any other row in the matrix. Each element in a row is added to the corresponding element in the same column of another row. Any combination of the above. For example, a row may be multiplied by a negative constant before it is added to another row.
13

Solving systems of equations


0.011 + 0.242 = 0.1 0.21 + 0.62 = 0.16
In matrix format, this system can be represented as: 0.1 0.24 1 0.1 = 0.2 0.6 2 0.16

s
C-1 s = x, so we need the inverse of C:

We isolate matrix x: 0.1 0.24 1 0 0.2 0.6 0 1

14

Solving systems of equations (contd)


1 0 1 0 I 2.4 10 0.6 10 0 5
row 1B = 1A*10 row 2B = (5*2A) - 1B

20 0 50 50 25 1 3 3 C-1

row 1C = 1B (2.4*2C) row 2C = 2B*(5/3)

1.8 50 20 0.1 1 50 25 = = 1 0.16 2 3 3 3 C-1 s = x = x


15

Solving systems of equations (contd)


The system of equations

can be written

which can be solved by multiplying from the left by the inverse of A


1 =

which is equal to

i.e. x = - and y = 5.
16

Simplifying the risk and return formulas


We can now simplify the horrendous-looking formulas for mean and variance

Lets re-write what we did with two assets using matrix notation:

The symmetric matrix V is called the covariance matrix for the portfolio.

17

Simplifying the risk and return formulas


And for several assets it looks the same:

where
and the covariance matrix V is given by

18

Benefits of Diversification
If in the variance formula we choose uncorrelated assets, then

and if we choose all W_j to be equal to 1/n, i.e. we allocate equal funds to all n assets, then

assuming that all variances are less than 1 (which is reasonable). So we can conclude that we can make our risk very small by diversifying! The drawback is of course that portfolio performance will be very average.

19

Exercise 7.4
Multiply the following matrices: a. d.

e.

20

Exercise 7.4
4 + 2 2 0 2 2 = a. = 12 4 0 1 6 + 3
2 2 12 4

d.

= 4 4 + 5 5 + 6 6 = 77

16 = 20 24

20 25 30

24 30 36
21

Exercise 7.6
The expected returns for three stocks in portfolio P are 0.07 for stock X, 0.09 for stock Y, and 0.13 for stock Z. The variance of returns for stock X is 0.04, 0.16 for stock Y and 0.36 for stock Z. The covariance between returns on stocks X and Y is 0.01, 0.02 between stocks X and Z, and 0.08 between stocks Y and Z. Stock X comprises 30% of the portfolio, Y comprises 50% of the portfolio, and Z comprises 20%.
Write an expected returns vector for the three stocks Write the covariance matrix for the three stocks. Write the weights vector for the portfolio. What are the dimensions for the three matrices written for parts (a), (b) and (c)? Find the expected return of the portfolio using matrices written for part (a), (b) and (c). Find the variance of returns for the portfolio using matrices written for parts (a), (b) and (c).
22

Exercise 7.6
0.07 a. = 0.09 0.13 b. =

0.04 0.01 0.02 = 0.01 0.16 0.08 0.02 0.08 0.36

Note that: = 2 , = 2 , = 2

0.30 c. w= 0.50 0.20 d. (a) 3x1; b) 3x3; c) 3x1.

23

Exercise 7.6
e.

0.07 = 0.30 0.50 0.20 0.09 = 0.09 0.13 = 0.04 0.01 0.02 0.30 = 0.30 0.50 0.20 0.01 0.16 0.08 0.50 = 0.0794 0.02 0.08 0.36 0.20 =

f.

2
2

24

Exercise 7.7
Invert the following matrices:
a. = 8 = 0.125 1 0 = , the inverse of the identity matrix is the identity matrix. 0 1 0.25 0 c. = 0 2 b. in order to find the invert of a diagonal matrix simply invert each of the principle diagonal elements d. Step 1: augment the matrix with the identity matrix: 1 2 1 0 row 1 3 4 0 1 row 2
1

25

Exercise 7.7
1 0 1 2 1 1 0 0.6 3
1 0 2 1 0 1 1.5 0.5
1a = 1 x 1 1b = 2 x (1/3) (1a)

2a = 1a 2 x (2b)
2b = 2a x (1/(-0.6))

26