BIOL 582 Supplemental Material Matrices, Matrix calculations, GLM using matrix algebra.

Slides:



Advertisements
Similar presentations
Matrices A matrix is a rectangular array of quantities (numbers, expressions or function), arranged in m rows and n columns x 3y.
Advertisements

Matrix Algebra Matrix algebra is a means of expressing large numbers of calculations made upon ordered sets of numbers. Often referred to as Linear Algebra.
Refresher: Vector and Matrix Algebra Mike Kirkpatrick Department of Chemical Engineering FAMU-FSU College of Engineering.
3_3 An Useful Overview of Matrix Algebra
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 12 System of Linear Equations.
Review of Matrix Algebra
CSci 6971: Image Registration Lecture 2: Vectors and Matrices January 16, 2004 Prof. Chuck Stewart, RPI Dr. Luis Ibanez, Kitware Prof. Chuck Stewart, RPI.
1 Neural Nets Applications Vectors and Matrices. 2/27 Outline 1. Definition of Vectors 2. Operations on Vectors 3. Linear Dependence of Vectors 4. Definition.
MOHAMMAD IMRAN DEPARTMENT OF APPLIED SCIENCES JAHANGIRABAD EDUCATIONAL GROUP OF INSTITUTES.
Pam Perlich Urban Planning 5/6020
Linear regression models in matrix terms. The regression function in matrix terms.
Matrix Approach to Simple Linear Regression KNNL – Chapter 5.
Intro to Matrices Don’t be scared….
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
Stats & Linear Models.
Lecture 10A: Matrix Algebra. Matrices: An array of elements Vectors Column vector Row vector Square matrix Dimensionality of a matrix: r x c (rows x columns)
1 Chapter 2 Matrices Matrices provide an orderly way of arranging values or functions to enhance the analysis of systems in a systematic manner. Their.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 Statistical Analysis Professor Lynne Stokes Department of Statistical Science Lecture 5QF Introduction to Vector and Matrix Operations Needed for the.
Linear Algebra Review By Tim K. Marks UCSD Borrows heavily from: Jana Kosecka Virginia de Sa (UCSD) Cogsci 108F Linear.
Basics of Linear Algebra A review?. Matrix  Mathematical term essentially corresponding to an array  An arrangement of numbers into rows and columns.
Compiled By Raj G. Tiwari
Linear Algebra Review 1 CS479/679 Pattern Recognition Dr. George Bebis.
1 February 24 Matrices 3.2 Matrices; Row reduction Standard form of a set of linear equations: Chapter 3 Linear Algebra Matrix of coefficients: Augmented.
ECON 1150 Matrix Operations Special Matrices
BIOL 582 Lecture Set 19 Matrices, Matrix calculations, Linear models using linear algebra.
Presentation on Matrices and some special matrices In partial fulfillment of the subject Vector calculus and linear algebra ( ) Submitted by: Agarwal.
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Review for Chapter 4 Important Terms, Symbols, Concepts 4.1. Systems of Linear Equations in Two Variables.
Modern Navigation Thomas Herring
Some matrix stuff.
Statistics and Linear Algebra (the real thing). Vector A vector is a rectangular arrangement of number in several rows and one column. A vector is denoted.
Matrices Addition & Subtraction Scalar Multiplication & Multiplication Determinants Inverses Solving Systems – 2x2 & 3x3 Cramer’s Rule.
Matrix Algebra and Regression a matrix is a rectangular array of elements m=#rows, n=#columns  m x n a single value is called a ‘scalar’ a single row.
Multivariate Statistics Matrix Algebra I W. M. van der Veld University of Amsterdam.
Linear algebra: matrix Eigen-value Problems Eng. Hassan S. Migdadi Part 1.
Introduction to Matrices and Matrix Approach to Simple Linear Regression.
Introduction to Linear Algebra Mark Goldman Emily Mackevicius.
Special Topic: Matrix Algebra and the ANOVA Matrix properties Types of matrices Matrix operations Matrix algebra in Excel Regression using matrices ANOVA.
Chiang & Wainwright Mathematical Economics
Review of Matrix Operations Vector: a sequence of elements (the order is important) e.g., x = (2, 1) denotes a vector length = sqrt(2*2+1*1) orientation.
3.4 Solution by Matrices. What is a Matrix? matrix A matrix is a rectangular array of numbers.
Matrices and Determinants
Instructor: Mircea Nicolescu Lecture 8 CS 485 / 685 Computer Vision.
Linear System of Simultaneous Equations Warm UP First precinct: 6 arrests last week equally divided between felonies and misdemeanors. Second precinct:
Boot Camp in Linear Algebra TIM 209 Prof. Ram Akella.
If A and B are both m × n matrices then the sum of A and B, denoted A + B, is a matrix obtained by adding corresponding elements of A and B. add these.
Matrix Algebra Definitions Operations Matrix algebra is a means of making calculations upon arrays of numbers (or data). Most data sets are matrix-type.
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
Lecture 1 Linear algebra Vectors, matrices. Linear algebra Encyclopedia Britannica:“a branch of mathematics that is concerned with mathematical structures.
10.4 Matrix Algebra. 1. Matrix Notation A matrix is an array of numbers. Definition Definition: The Dimension of a matrix is m x n “m by n” where m =
MATRICES A rectangular arrangement of elements is called matrix. Types of matrices: Null matrix: A matrix whose all elements are zero is called a null.
1 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices.
Matrices Introduction.
College Algebra Chapter 6 Matrices and Determinants and Applications
MTH108 Business Math I Lecture 20.
Introduction to Vectors and Matrices
Linear Algebra review (optional)
CS479/679 Pattern Recognition Dr. George Bebis
L5 matrix.
Matrices Definition: A matrix is a rectangular array of numbers or symbolic elements In many applications, the rows of a matrix will represent individuals.
Dr Huw Owens Room B44 Sackville Street Building Telephone Number 65891
Matrix Algebra.
Basics of Linear Algebra
Introduction to Vectors and Matrices
Linear Algebra review (optional)
Math review - scalars, vectors, and matrices
Presentation transcript:

BIOL 582 Supplemental Material Matrices, Matrix calculations, GLM using matrix algebra

Compact method of expressing mathematical operations (including statistics) Generalize from one to many variables (i.e. vectors to matrices) Matrix operations have geometric interpretations in data spaces Many data types (e.g., morphometric data) cannot be measured with a single variable, so multivariate methods are required to properly address hypotheses BIOL 582 Why bother with matrices?

Scalar: a number Vector: an ordered list (array) of scalars (n rows x 1 cols ) Matrix: a rectangular array of scalars (n rows x p cols ) BIOL 582 Scalars, vectors, and matrices

Reverse rows and columns Represent by A t or A′ Vector transpose works identically BIOL 582 Matrix transpose

Matrices must have same dimensions Add/subtract element-wise Vector addition/subtraction works identically Addition Subtraction BIOL 582 Matrix addition and subtraction

inner Scalar multiplication: Multiply scalar by each element in matrix or vector Matrix/vector multiplication is a summed multiplication Inner dimensions allow multiplication Outer dimensions determine size of result Order of matrices makes a difference: AB  BA BIOL 582 Matrix multiplication AB n 1 × p 1 * n 2 × p 2

Scalar multiplication: Matrix multiplication: Inner dimensions MUST AGREE!!! BIOL 582 Matrix multiplication

Inner (scalar) product: vector multiplication resulting in a scalar (weighted linear combination) Outer (matrix) product: vector multiplication resulting in a matrix Inner Product Outer Product Inner dimensions MUST AGREE!!! BIOL 582 Matrix multiplication: inner and outer products

I: Identity matrix (equivalent to ‘ 1 ’ for matrices) 1: A matrix of all ones 0: A matrix of all zeros Diagonal: diagonal contains non-zero elements Square: n = p Symmetric: off-diagonal elements same: BIOL 582 Special matrices

BIOL 582 Special matrices

Orthogonal: square matrix with property: VERY useful for statistics and other fields (e.g, morphometrics) Orthogonal matrices can be thought of as rigid rotations of data sets (shown later) Orthonormal Example: BIOL 582 Special matrices

Can ’ t divide matrices, so calculate the inverse (reciprocal) of denominator and multiply Inverses have property that: Inverses are tedious to calculate, so in practice we use a computer Only works for square matrices whose determinant  0!!! Determinant: combination of diagonal and off-diagonal elements A matrix whose determinant = 0 is Singular (has no inverse) For: BIOL 582 Matrix inversion

For the 2 x 2 case: Example: Confirm: BIOL 582 Matrix inversion: example

Multiplying data and other matrices has geometric interpretations XI=X: No change to X cIX=Y: Change of scale (e.g, enlargement) XD=Y: Stretching if D is diagonal XT=Y: Rigid rotation if T is p×p orthogonal XT=Y: Shear if T is not orthogonal (T can be decomposed into rotation, dilation, rotation) X = data matrix BIOL 582 Matrix multiplication: geometric interpretations

(images from C.A.B. Smith, 1969) Original Scalar (2) Scalar (1/2) Rotations Shears and Projections BIOL 582 Matrix multiplication: visual examples

The GLM model: Independent Variable/s: Dependent Variable/s: Solve for ‘regression coefficients’  found from: BIOL 582 GLM in matrix form Note, in general vectors are lower case and matrices are upper case, but using upper case is more encompassing

Multiply by inverse: Why this equation? Start with: Make ‘ X ’ a square matrix: BIOL 582 GLM in matrix form: Solving for β This is the model

and: 1. Expand matrixes: where: 2. Begin rewrite: BIOL 582 GLM in matrix form: Deriving univariate regression

2. From before: 4. Multiply 3. Calculate inverse: BIOL 582 GLM in matrix form: Deriving univariate regression

F-ratio is: SSM/SSE (with df corrections) Need to calculate full and reduced model SS Full model (contains all terms) Reduced model (X # has 1 less term – column of x values – in it) Significance based on: Or one can always use a random permutation approach… BIOL 582 GLM in matrix form: Calculating sums of squares (SS)

The Data: (for matrix form): SourcedfSSMS (SS/df)FP RegressionΔk = 1SSEr -SSEf = < Errorn - Δk – 1 = 3SSEf = Totaln – 1 = 4SST = SSEr = 10 BIOL 582 Regression example

BIOL 582 Using GLM for ANOVA Analysis of Variance (ANOVA) is the standard way of comparing means among multiple groups. ANOVA is the cornerstone of most applied stats courses in life science fields Linear regression equation ANOVA equation

Same idea, but must use special X-matrix coding Recode k groups in k-1 dummy variables columns) of X Generally, column 1 yields, column 2 yields deviation from for mean of group 1, etc. BIOL 582 Using GLM for ANOVA

The Data: n 1 =5 n 2 =5 BIOL 582 Using GLM for ANOVA: Example 1 SourcedfSSMS (SS/df)FP GroupΔk = 1SSEr -SSEf = Errorn - Δk – 1 = 8SSEf = 45 Totaln – 1 = 9SST = SSEr = 14 (Reduced model is one column of 1s) DEMO

BIOL 582 GLM final comments As we will learn, ANOVA, ANCOVA, Multiple Regression, MANOVA, MANCOVA, and Multivariate Multiple Regression, are all variants of the same GLM procedure. All of these “ different ” analytical approaches are no different to a computer using matrix calculations to perform GLM If there are 4 groups, then 4 – 1 = 3 dummy variables are needed. If there are 88 groups, then 88 – 1 = 87 dummy variables are needed. ALWAYS, there are a -1 “ factor ” levels for a groups.

BIOL 582 GLM final comments Dummy variables are “ indicator ” variables E.g., can be written as where Z is an indicator: 1 if in the group; 0 if not in the group. There are two ways to form the design matrix (X): Groups 2-4 means are expressed as deviations from the first group mean All group means are expressed as deviations from the overall group mean Analytically, these are no different, but different software packages use different approaches!