Post on 03-Jan-2016
description
Matrix Algebra - OverviewMatrix Algebra - Overview
Introduction to MatricesR-mode vs. Q-modeLinear AlgebraSpecial Matrices
Trace, Diagonal, Identity, Scalars, Transpose
Matrix AdditionMatrix Multiplication
Matrix AlgebraMatrix Algebra
Matrix algebra is an essential tool for multivariate analysis because most data sets are recorded in a matrix format (rows & columns).
The use of matrices provides a succinct representation of ecological information and with matrix algebra we can perform operations and analyses of whole data sets.
We won’t dive too deeply into this in FISH 560, but it is important to have a basic understanding of matrix algebra to help grasp key concepts in multivariate statistics.
Table Structure of DataTable Structure of Data
Ecological data are typically recorded in a table, or matrix, where each column j corresponds to a descriptor yj (species abundance, habitat variable, diet item) and each row i refers to an object xi (sampling site, individual, etc.).
Objects c1 c2 c3 cj
r1 a11 a12 a13 a1j
r2 a21
r3 a31
ri ai1 aij
Each cell (i,j) of the matrix is the value of ith object for jth descriptor:
Objects and DescriptorsObjects and Descriptors
Sometimes it may not be clear as to what are the objects and what are the descriptors.
A common approach in community ecology is to compare different sampling sites (the objects) based on the assemblage of organisms observed at each one (the descriptors).
In contrast, in fish diet analyses we would consider individual fishes as objects and diet items found in fish stomachs as the descriptors.
It is therefore necessary to define what are objects and descriptors before analyzing the data.
R-mode and Q-mode anlysesR-mode and Q-mode anlyses
The distinction between objects and descriptors has very important implications.
The analysis of relationships among descriptors at the given set of objects is known as R-mode analysis.
In contrast, a Q-mode analysis quantifies the relationships among the objects given a series of descriptors.
Each type of analysis can require very different multivariate techniques
Linear AlgebraLinear Algebra
As described above, a table of ecological data is referred to as a matrix.
Linear algebra is the branch of mathematics that works with matrices.
rcr2r1
2c2221
1c1211
aaa
aaa
aaa
A
A matrix of dimension r X c is a rectangular array of numbers with r rows and c columns.
Matrix FormMatrix Form
Matrices can take many forms: rectangular, square, row or column.
ra
a
a
2
1
a
cbbbb 21
36
161A
A square matrix (r = c)
A column vector (r X 1)
A row vector (1 X c)
A scalar (1 x 1)
Matrix NotationMatrix Notation
Matrix notation provides a mechanism for writing and describing elements of data sets.
As such, it corresponds to the way computers and programming languages interpret tables of data.
Many statistical programs can handle data entered in matrix format.
So, matrices are a very useful when working with multivariate data
Square MatricesSquare Matrices
For a square matrix A (of order n × n), the diagonal elements those with identical subscripts (e.g., a11, a22, etc.). Thus, they are located on the main diagonal of the square matrix (from upper left to lower right).
nnn2n1
44
33
2n2221
1n1211
aaa
a
a
aaa
aaa
AThe sum of the diagonal elements
is known as the trace.
Diagonal MatricesDiagonal Matrices
A diagonal matrix is a square matrix in which only the diagonal elements are non-zero.
An identity matrix, I, is a diagonal matrix in which all the diagonal elements are one.
200
010
004
A
100
010
001
I
Null and Triangular MatricesNull and Triangular Matrices
A matrix where all elements are zero is called a zero matrix or null matrix. It is indicated by 0 or [0].
A square matrix with all elements below (or above) the main diagonal being zero, is called an upper (or lower) triangular matrix.
100
1880
324
A
The transpose of matrix A with dimensions (n × p) is indicated as A’ and is a new matrix of dimensions (p × n) in which a’ij = aji.
Transposing MatricesTransposing Matrices
217
4010A
24
10
710
A
Transposing matrices is very important in many forms of statistical analysis including multivariate analyses.
Symmetric MatricesSymmetric Matrices
A square matrix that is identical to its transpose is said to be symmetric. In this case, the terms aij and aji, which lie on either side of the diagonal, are equal. For example:
3183
1822
324
A
Matrix AdditionMatrix Addition
Matrices must be of the same order to be added.
If you sampled 3 sites and measured the abundance of 2 species on once per month and wanted to know the total abundance sampled, you could use matrix addition:
1015
32
1226
29
02
315
62
20
21
24
10
710
June July August Summer
Site 1
Site 2
Site 3
Sp.1
Sp.2
Matrix MultiplicationMatrix Multiplication
The result of a scalar product of two vectors is equal to the sum of the products of those corresponding order numbers. The scalar product is usually designated by a dot (or by no symbol at all). For example:
pp
p
p cbcbcb
c
c
c
bbbcbbc ...2211
2
1
21 A scalar
Going back to the earlier example, we can multiply a month matrix with a vector of appropriate order.
14
3
41
)3(2)2(4
)3(1)2(0
)3(7)2(10
3
2
24
10
710
JuneSampling efficiency
Total fish abundance
Site 1
Site 2
Site 3
Sp.1
Sp.2
Matrix Multiplication …Matrix Multiplication …
Multiplying two matrices is an extension of the product of a vector by a matrix.
To multiply matrix C by a second matrix B, consider C as a set of column vectors (e.g., c1, c2, etc.).
For example:
230
121
113
201
B
03
12
21
C edC and
Simply multiply B by the vectors d and e.
Matrix Multiplication …Matrix Multiplication …
NB: To multiply two matrices they must be conformable, which means the number of columns of the first matrix must equal the number of rows in the second.
The resulting matrix will have the same no. of rows as B and no. of columns as C.
12
8
8
7
)3(2)2(3)1(0
)3(1)2(2)1(1
)3(1)2(1)1(3
)3(2)2(0)1(1
Bd
3
4
7
2
)0(2)1(3)2(0
)0(1)1(2)2(1
)0(1)1(1)2(3
)0(2)1(0)2(1
Be
312
48
78
27
BC
and
thus