Você está na página 1de 17

2

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

In general for a r c matrix

1.1.1. Rectangular matrix and vector


A matrix where r c is called a rectangular matrix. The most common rectangular matrices
used in biometrics are so called design or incidence matrices with elements which takes the
value of either 0 or 1. The design matrices are mostly denoted as X or Z. If r=l or c=1 the
rectangular matrix is called a vector, which is denoted by boldface lower case letters. If r=1 the
vector is called a row vector
vl3 = [ v1 v2 v3 ]
and if c=1 the vector is called a column vector

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.

1.1.3. Special matrices


The null matrix is a matrix where all elements are zero, and is denoted as 0. The null vector is
denoted as o.
A J matrix is a matrix with all elements equal to 1, and a l-vector has all elements equal to unity.
A symmetric matrix is a square matrix where the upper triangular elements is the mirror image
of the lower triangular elements, i.e. xij = xji.

Several types of symmetric matrices are useful:


The diagonal matrix, D, is a matrix with all off-diagonal elements equal to zero. If all
diagonal elements in a diagonal matrix are equal it is said to be a scalar matrix, S, and
if the elements in a scalar matrix equal unity the matrix is an identity matrix, which is
denoted as I.

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. Matrix operations


Matrix operations must follow special rules which may or may not follow the rules of ordinary
algebra. The most important concept in matrix operations involving two or more matrices is
conformability. Two matrices must be conformable in order to equate, add, subtract or multiply.

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

Note that A B = B A and A B C = (A B) C = A (B C).

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

Note that kA = Ak.


A scalar matrix is often written as

1.2.3.2. Matrix multiplication


Matrix multiplication is performed as a series of row and column operations. Each element in
the product matrix is obtained by multiplying elements in a row of the matrix to the left with
elements in the corresponding column of the matrix to the right and summing the products.

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

The rotation rule for trace of matrix products are


tr( AB) = tr(BA)
tr(ABCD) = tr(BCDA) = tr(CDAB) = tr(DABC)
but recall that the trace exists only if the product matrix is a square.
For special matrices we have
III = II = I
IA = AI = A
AIIB = AIB = AB
Thus the identity matrix can be inserted or dropped from the matrix expression whenever
it is convenient.
If A = Ak the matrix A is idempotent. An idempotent matrix is square, but not necessarily I or
0. For example, the following matrix is idempotent

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

*B* = 1(2) + 2(2) + 3(-3) = -3


Had row 2 or 3 been used, the same result would had been found. The adjugate of B is obtained
by replacing each element in B by their cofactors and then transposing. Thus the adjugate of B
is

Another way to obtain the determinant is to follow the below algorithm:


Consider the matrix V of order n=3:

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.

1.2.6.2. Unique inverse

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.

For a unique inverse the following properties are useful:


AA-1 = AA = I
(A-1)-1 = A

*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.

1.2.6.3. Rank and general inverse


It is not necessary to compute the determinant of a matrix in order to evaluate if the matrix is non
singular and thus has a unique inverse. If there are linear dependencies of rows or columns the
matrix is non-singular. A square matrix with linearly independent rows and columns are said
to be of full rank. Consider

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

1.3. Direct products and direct sums


Consider a situation with information on 2 traits (y and z) for each of 2 animals. Each animal has
a breeding value for each trait (a @). Let the additive genetic (co)-variance matrix between the
traits be

15

then the (co)-variance matrix of the breeding values become

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

(A r B)-1 = (A-1 r B-1) , because

|ArB| = |A| |B|


The direct matrix operations are all useful in genetic evaluation with multiple traits.

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.

B. Make two matrices, A and B, such that AB is defined and BA isnt.,


C. Give examples of a identity matrix, a scalar matrix and a diagonal matrix that isnt a scalar.
That class of matrices do these matrices belong to?
D. What are the products Mv, ve and ev (NB. note the order) when

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.

F. Show that A is idempotent and that B is nilpotent.

Find and compare the r(A) and the tr(A).


G. Use matrix algebra to solve the problem:
-x + 3y = 7
2y + z = 13
x + 4z = 5
H. Obtain determinants of the following matrices

18

I. Show that the solution to Ax = y is x = A-1y.


J. Derive the inverses of the following matrices:

Você também pode gostar