Algebra Matricial
Algebra Matricial
Algebra Matricial
The intension with these notes is to go through the matrix algebra and statistics which are useful
in the course Advanced animal breeding.
1. Matrix algebra
1.1. Definition and Notation
A matrix is an ordered array of numbers arranged in rows and columns. Bold face upper case
letters are normally used to denote matrices and it will be used in this text.
The number of rows (r) and columns (c) determine the order or size or dimension of a matrix.
A matrix X with r rows and c columns has it's size denoted as X rc , but the order is often not
written for simplicity.
The elements of a matrix can be numbers, symbols for variables or even functions and it is the
position of the elements of the matrix that usually determines it's meaning. Lower case letters
are used to symbolize elements with subscripts denoting the specific position of the element in
row i and column j. Elements of a matrix are enclosed in solid square brackets. A (2 3) matrix
X is
The most commonly used vectors in biometrics are denoted as y, b and u. Usually the y-vector
contains the observed performances of animals for the trait in question. The b and u vectors are
"solution"-vectors and the elements are obtained by solving the equation system in question.
Usually the b-vector contains the estimated fixed effects and the u-vector the predicted breeding
values.
1.1.2. Square matrix
A matrix with r = c is called a square matrix. If r = c = 1 the matrix contains only one element
and is termed a scalar. The square matrix is common and very important in statistical
operations. Special terms apply to this matrix.
The element x11, (the element in the upper left corner) is the leading element. The diagonal is
the string of elements from the upper left corner to the lower right corner of a square matrix, and
the diagonal elements are xii (i.e. x11, x22, ...xnn ). The sum of the diagonal elements are called
4
the trace of the matrix and is denoted as tr(X). All elements which are not diagonal elements
are off diagonal elements, i.e. the xij elements for which i j ( x12, x21, x23, etc.). The upper
triangular part of a square matrix contains the off-diagonal elements above the diagonal and the
lower triangular part of a square matrix contains the elements below the diagonal.
A triangular matrix is a matrix where all lower or upper triangular elements are zero and
it is called an upper triangular (U) or lower triangular matrix (L), respectively.
1.2.1. Equality
Two matrices are said to be equal if they are of the same order and all corresponding elements
are identical.
1.2.2. Addition and subtraction
Addition and subtraction require that the two matrices in question are conformable, which means
that they in this case must be of the same order.
Arc+ Brc = Crc
The operation is performed element by element, i.e. aij bij = cij. An example
6
1.2.3. Multiplication
1.2.3.1. Scalar multiplication
Multiplication of a matrix by a scalar is accomplished by multiplying every element in the matrix
by the scalar. Let k = 5 and A be defined as above, then
The two matrices has to be conformable for multiplication, i.e. the number of columns of the
matrix to the left must be equal to the number of rows in the matrix to the right.
Arc Bcd
The order of the product matrix is r d. In AB, A is postmultiplied by B and B is premultiplied
7
by A.
Provided that the matrices are conformable for multiplication the following rules can be used:
ABC = (AB)C = A(BC)
A(B + C) = AB + AC
(A + B)2 = (A + B)(A + B) = AA + AB + BA + BB = A2 +AB+BA+B2
AB = BA only if A and B are symmetric, thus usually AB BA. The ordinary algebra
rule ab=ba does not apply to matrix algebra.
dA = Ad; dAB = AdB = ABd; (dA)(hB) = dhAB = ABdh
If Ak = 0, A is said to be a nilpotent matrix. A does not have to be 0, but can for example be
1.2.4. Transpose
The transpose of a matrix X is denoted X' and is obtained by interchanging rows and columns.
Thus if X has the order r c then X' has the order c r, i.e.
Note that if e is of the order 1n then e'e is of the order 11 and ee' is of the order nn. In this
case e is a row vector and e' is a column vector.
Some useful rules are
(A) = A
(A + B) = A + B = B + A
(ABCD) = DCBA
If S is symmetric then S = S
If S and R are symmetric matrices then SR is generally not symmetric
If X is a rectangular matrix then XX is symmetric and square because (XX) = X(X)
= XX
1.2.5. Partitioning a matrix
It is often useful to partition a matrix into submatrices with a special structure. Later it will be
shown that it is useful to look at the mixed model equation system W'Wt = W'y as
9
1.2.6. Matrix inversion
In matrix algebra divisions cannot be performed. However, we have from ordinary algebra that
a / b = a b-1, i.e. division can be performed as a multiplication by the reciprocal or the inverse.
Thus in matrix algebra division by a matrix B is performed with multiplication by the inverse
of B, which is denoted as B-1. Not all matrices have inverses. Only a particular kind of square
matrices has a unique inverse.
The inverse of a matrix is difficult to compute by hand and if the order of a matrix is larger than
3 3 it is difficult, time consuming and the result will probably be wrong, thus it is
recommended to use computer programmes.
Inversion involves two components; the determinant and the adjugate.
1.2.6.1. Determinant and adjugate
The determinant of matrix A is denoted *A* and it is a value. The determinant of a scalar is the
scalar it self. The determinant of A22 is
In general the determinant of an nn matrix is defined in terms of determinants of some (n-l)(n1) matrices called minors. The minor of the element aij in A is obtained by deleting the i'th row
and the j'th column of A and is denoted as mij. The "signed" minor of aij is (-1)i+j mij and it is
called the cofactor of aij. If
10
the minor of 1 is
and it's cofactor is (-1)1+1 (2) = 2. The minor of 2 is -2 and it's cofactor is (-1)1+2 (-2) = 2. The
minor of 3 is -3 and it's cofactor is -3. The determinant of B is the sum of the product of the
elements in a row and their cofactors. Thus for row one we have
1) set i=1
2) for row j=i+1 to n make zeros in column i by
a) compute the weightfactor w as w = - (vji/vii)
b) replace the vector vj by (vj - w vi)
3) Update i, and if i<n then go to 2) else go to 4.
4) Compute the determinant as the product of the diagonal elements; *V* = Ai=1,..,n vii.
An example: Consider the matrix B again, and set i=1 (i.e. setting zeros below the diagonal of
11
the 1. column).
Set j= i+1=2. The 1. weight factor becomes -(4/1) and the 2. row is replaced by [4 5 6] - (-4)[1
2 3] = [0 -3 -6]
We now have
Set j=j+1 = 3 (=n). The 2. weight factor becomes -(7/1) and the 3. Row is replaced by [7 8 10
] - (-7)[1 2 3] = [0 -6 -11]. We now have
Since j=n then update i, i=i+1=1+1=2 (Setting zeros below the diagonal of the 2. column). Set
j=i+1=3 (=n). The 3. weight factor becomes - [(-6)/(-3)] = -2, and the 3. row is replaced by [0
-6 -11] - (-2)[0 -3 -6] = [0 0 1]. We now have
Since j=n we update i, i=i+1=3 (=n), and we stop. Now all lower triangular elements are zero and
the determinant can be computed as *B* = 1(-3)1 = -3. As before. Note, it is a role that the
determinant of a triangular matrix is the product of its diagonal elements, and it is this role that
is utilizied here, in what is known as Forward Doolittle.
12
The inverse of a matrix is simply obtained by multiplying the adjugate of a matrix with the
reciprocal of it's determinant. For B we have that
The definition of a unique inverse is that BB-1 = B-1B = I, which often is used to check the
computed inverse. In this way it can be seen that B-1 is indeed a unique inverse of B. If the
determinant is zero the matrix has no inverse and it is said to be singular. The inverse of a
diagonal matrix is simply the reciprocal of the diagonal elements.
*A-1* = 1 / *A*
(A)-1 = (A-1)
(A-1) = A-1 if A is symmetric
(ABCD)-1 = D-1 C-1 B-1 A-1 if all matrices are square and non-singular
The introduced procedure for obtaining a unique inverse is only one among many. Others may
be more efficient, but all requires lengthy arithmetic computation. However, the chosen
procedure shows the importance of the determinant and how it affects the existence of a unique
inverse. When a computer programme is used for inversion roundoff errors is always a potential
problem. Suppose a matrix has a determinant of zero, i.e. on unique inverse, and we use a
13
computer to do the job. Due to accumulation of small roundoff errors the computer may come
up with a small non-zero determinant and produce an inverse anyway. One should always be
careful when a matrix to be inverted has very large elements and when the elements are very
different in magnitude. One should always check that X-1X = I, but unfortunately even if this
equality holds the inverse may still be wrong. Thus, one should always be careful in the choice
of inversion algorithm.
It can be seen that row 1 and 2 sum to row 3, column 1 and 2 sum to column 4 and 3 times
column 1 equals column 3. Thus the rank of A, denoted as r(A), is 2 which is the largest nonsingular square submatrix of A. If the rank of a matrix is equal to it's order the matrix is of full
rank. If a matrix is not of full rank a unique inverse cannot be obtained, but a general inverse
can. The general inverse of the above A is denoted A- and not A-1. Consider
Here row 1 and column 1 is the sum of row and column 2 and 3, respectively. To obtain a
general inverse the dependent row and column are set to zero, i.e.
14
and
Obviously, we could have set the second or third row and column to zero, respectively, and
obtained a general inverse. "Setting to zero" is only one way to obtain general inverses. There
has been developed other ways to find general inverses but they will not be dealt with here.
Some rules are
A-A I
AA-A = A
if G = (XX)- then G is also a general inverse of X'X
if G = (XX)- then XGXX = X, i.e. GX is a general inverse of X
if G = (XX)- then XGX' is invariant, i.e. XGX is unique for any G
XGX' is symmetric whether G is or not
15
where aij is the additive genetic relationship between the 2 animals. The expression can be
written as
where q denotes an operation on A and G0 which is called the direct Kronecker product. Let Apq
and Bmn, then
A q B = Cpnqn
(A q B ) = A q B
x q y = yx = y q x
k q A = kA = A q k, with k being a scalar
[A1 A2 ] q B = [ A1 q B A2 q B ]
A q [ B1 B2 ] [ A q B1 A q B2 ]
( A q B )( x q y ) = Ax q By, provided conformability
( A q B )-1 = A-1 q B-1, if A and B are non-singular
rank(AqB) = rank(A) rank(B)
tr(A q B ) = tr(A) tr(B)
| Mmm q Nnn | = | M |n | N |m
(AqB)qC=Aq(BqC)
16
kA q B = A q kB = k( A q B )
( A + B ) q C = (A q C ) + ( B q C )
These operations are all useful in genetic evaluation with multiple traits.
The direct sum of of Apq and Bmn gives S(p+m)(q+n) and it denoted as ArB = S. The following
rules apply to direct sums:
(A r B) + (C r D) = (A+C)r(B+D), because
(A r B) (C r D) = ACrBD, because
17
1.4. Exersices
A. Compute AB and BA . Do the ordinary algebra ab=ba apply in this situation? If not,
comstruct two new matrices so that it does.
E. Given the matrices below, is tr(A) defined and if so what is it? Compute tr(AB) and tr(BA)
and comment the result.
18