View
216
Download
0
Embed Size (px)
Citation preview
1
MF-852 Financial Econometrics
Lecture 1
Overview of Matrix Algebra and Excel
Roy J. EpsteinFall 2003
3
Matrices—Some Definitions A matrix is a rectangular array
of real numbers. Denote a matrix with an upper
case italic letter, e.g.,
mnm2m1
n22221
n11211
ij
)(
aaa
aaa
aaa
aA
4
Matrices—Some Definitions A has m rows and n columns. The dimension of A is “m x n” (m by n). A vector is a matrix with a single row or
a single column (denoted with a lower case letter without a subscript), e.g,
m
2
1
a
a
a
a
5
Matrices—Some Definitions If n = m then A is a square matrix. If A is square and aij = aji then A is
symmetric, e.g.,
is a symmetric matrix.
4 5 7
5 1 3
7 3 2
6
Scalar Multiplication Let k be a scalar (i.e., a given
real number). kA is a new matrix where each element equals kaij.
4 6
8 2
2 3
4 1 2
7
Matrix Addition A + B is a new matrix where
each element is the sum of the corresponding elements of A and B.
5 8
6 1-
3 5
2 2- ,
2 3
4 1
BA
BA
8
Matrix Addition Addition is only defined if the
matrices have the same dimensions.
makes no sense.
0 45 1
3 2
9
Matrix Subtraction A – B = A + (–1)B. So
subtraction also requires the matrices to have the same dimensions.
1- 2-
2 3
3 5
2 2- ,
2 3
4 1
BA
BA
10
Matrix Transpose The transpose of a matrix is a new
matrix where the rows and columns are switched. The transpose of A is denoted A .
6 5
4 3
2 1
,6 4 2
5 3 1
5) (2 ,5
2
2 4
3 1 ,
2 3
4 1
CC
bb
AA
12
Summation Operator We often need to add up the
elements of a vector or matrix. We use a convenient notation for this.
Suppose a = (a1, a2, …, an). Define
n
1in21 aaaa
13
“Dot” (or “Inner”) Product The “dot” product “multiplies” two vectors
(we ignore other vector multiplication concepts).
The dot product of a and b is defined as ab = ∑aibi (a and b must have the same number of elements).
Suppose
then ab = 1 x 0 + 4 x 2 + 2(-3) = 2.
3
2
0
,
2
4
1
ba
14
Matrix Multiplication Matrix multiplication AB is defined
in terms of dot products. The result is a new matrix C.
Each cij is a dot product. The dot product involves the ith
row of A and the jth column of B.
15
Matrix Multiplication Example:
2- 4
15 23
4x10x21x6- 4x30x01x8-
5x12x21x6 3x50x28x1
1 3
2 0
6 8
,4 0 1
5 2 1
AB
BA
16
Matrix Multiplication # columns in A = # rows in B or
matrix multiplication is not defined.
Questions: Does AB = BA? Do A and B have to be square in
order to multiply them? Is AA square?
17
Matrix Rules for MultiplicationA(BC ) = (AB)C
A(B+C) = AB + AC
(B+C)A = BA + CA
(AB) = B A
(ABC) = C BA
18
The Identity Matrix An identity matrix has 1’s on the
diagonal and 0 everywhere else. aii = 1, aij=0 i j
is a 3 x 3 identity matrix.
1 0 0
0 1 0
0 0 1
I
19
The Identity Matrix and Multiplication For scalars, 1 is the multiplicative
identity: 1() = ()1 = . For matrices, AI = IA = A.
2 3
4 1
1 0
0 1
2 3
4 1
2 3
4 1
2 3
4 1
1 0
0 1
20
Matrix Inverse For 0, –1 is the multiplicative
inverse: –1() = ()–1 = 1. For matrices, A –1 is the inverse of
A: A –1A = A A –1 = I. Excel (and other programs) will
calculate A –1.
22
Singular Matrix For = 0, –1 does not exist. Sometimes A –1 does not exist. In
this case A is called singular or non-invertible.
Excel sometimes calculates an inverse of a singular matrix when there is a lot of roundoff error—be aware!
24
Block Diagonal Matrix Suppose A has sub-matrices
along its main diagonal and is zero elsewhere. Then A is block diagonal, e.g.,
8 4 0 0
5 7 0 0
0 0 1 3
0 0 3 2
25
Matrices and a System of Linear Equations Suppose we have a system of 2
linear equations in 2 unknowns, e.g.,
Matrices lead to a simple solution.
123
241
21
21
xx
xx
26
Matrix Representation The equation coefficients are a
matrix A:
The unknowns are a vector x:
The constants are a vector c.
2 3
4 1A
2
1
x
xx
1
2c
27
Matrix Solution The equation system can be
written
Multiply both sides by A –1
Solution is (since A –1A =I)
cAx
cAAxA 11
cAx 1
29
Excel and Matrices SUMPRODUCT
Dot product MMULT
Matrix and vector multiplication TRANSPOSE
Matrix and vector transpose MINVERSE
Matrix inverse