Matrix Algebra in R

Matrix algebra sounds intimidating. If I could start somewhere else, I would, but psychometrics is too painful without matrix notation. Spending time to become familiar with matrix algebra makes a lot of otherwise difficult things easy. I am continually amazed and surprised by the diverse ways in which learning this material has paid dividends to me. I use matrix algebra to solve problems not just in “mathy” applications like psychometrics and statistics but in domains I never imagined it would have utility (e.g., art, design, and music). Trust me. This is potent stuff, and its power can be yours.

Matrix algebra refers to performing arithmetic operations and algebraic manipulations on numbers arranged in rectangular arrays.For now, we will focus solely on numeric data, setting aside the possibility of creating vectors and matrices with non-numeric data such as logical (Boolean) values, nominal data, ordinal values, dates, or complex structures such as lists.

Despite appearances, matrix algebra is not so hard. In my opinion, learning regular algebra is the hard part. If you made it through high school with a strong understanding of algebra, you will see that matrix algebra is mostly an extension of what you already know. Give it a try and see what happens. If learning matrix algebra seems hard, firming up your foundational knowledge of regular algebra may be a better place to start.

Algebra uses symbols in formulas to represent numbers. You are probability familiar with using algebraic methods to solve for unknown values in equations. For example, in the equation below, there is only one possible value of x that makes the equation true:

\begin{aligned} &x-1&=&~0\\ &x-1+1&=&~0+1\\ &x+0&=&~1\\ &x&=&~1 \end{aligned}

Matrix algebra allows us to use one symbol to represent more than one number at a time. So, instead of using one symbol to represent one number (e.g., x=4), a single symbol can represent a sequence of numbers: \mathbf{x}=\{3,1,5,9\}

Or just one symbol can represent a rectangular array of numbers:

\mathbf{A}=\begin{bmatrix} 5&7&9&2\\ 7&0&1&4\\ 3&2&8&0 \end{bmatrix}

In this way, we can perform the same operations (e.g., addition, multiplication, exponentiation) on many numbers at once (e.g., creating statistical models from many rows of data). The notation of matrix algebra often makes what would otherwise be large, messy, complex statistical formulas look simple, tidy, and compact.

In matrix algebra, we can arrange numbers as scalars (single values), vectors (sequences of values), and matrices (values in rectangular arrays).