What is the rank of a vector or a matrix?

There is an app at the bottom of the page to help answer the question, but there are other ways to answer it.

A simple answer for ranking matrices via their maximum ranks

Asking what is the maximum rank of a matrix is an easy way to answer the rank of a matrix. There are more rows or columns. Take the number of rows or columns you have and divide it by them. That will be the maximum rank value. What if the matrix isn’t empty? It has a zero rank. What if there is only one element? It would have a minimum rank value.

What is the rank and not the maximum rank of a matrix – using the echelon form of the matrix

To answer this, you have to use the matrix in the form of an “e-sh-e-lawn” When reading the values from left to right, the row will start with a 1 if there are no zero values on that row. There is a chance that the row is all zeros. If it’s all zeros, it needs to be the bottom row. There needs to be either a 1 below or a zero below it when there are ones. The scope of this article does not include converting a matrix to echelon form.

You can count how many non-zero rows you have once the matrix is in echelon form, but not the maximum or minimum rank value. This isn’t the number of independent vectors that make up the matrix. When you convert to echelon form, you need to find out what the independent vectors are that make up the matrix. Principal Component Analysis (PCA) is one of the ways in which to calculate independent vectors. There are many PCA types. There is a variety of PCAs. The more popular ones will be covered here. There is a distinction between PCA and the echelon form, which means that you can rank both matrices and vectors.

In regards to matrices, the following was stated on Quora but I added a word that is bolded and in all caps to make it true: the rank of a matrix is defined as (a) the maximum number of linearly independent column vectors in the matrix or (b) the maximum number of linearly independent row vectors in the matrix. Both definitions are equivalent. For an r x c matrix, If r is less than c, then the maximum rank of the matrix is r. Let A be the n×m matrix formed by using these INDEPENDENT vectors as its columns. Then the rank of A is m.

Without the word “INDEPENDENT” above I think it can be confusing.

A more complex answer for ranking BOTH matrices and vectors using PCA

First of all, let’s discuss what PCA is in as few and as simple words as possible, because it is easy to understand and you can easily understand if you go through this material.

First off, imagine you have some matrix A. Commonly, in linear algebra matrices are notated using a bold symbol, or double bars or arrows above or below the A. A vector would have a single bar or arrow above the letter.

A*v = v*lambda, where v = eigenvectors and lambda are the eigenvalues. Note, that the eigenvectors is a vector and the eigenvalues are scalers or just numbers.

If you multiply the following matrix A where it had m-by-n rows and columns by a column vector (which would have to have the same number of elements as the columns in matrix A, then you would end up with a column vector of length m. Why? Because

(m-by-n)*(n-by-1) = remove the n! = m-by-1 = m rows and 1 column!

This applies to matrices as well!

(m-by-n)*(n-by-p) = m-by-p

So A*v = a vector and v*lambda = a vector and both of them are column vectors. Now you can structurally see how the equation is laid out in terms of elements. Now solve for the eigenvectors:

A*v – lambda*v = 0

Note that the 0 above is a column of zeroes!

Factor out the eigenvectors, v:

v(A-lambda) = 0

If you looked at the structure of this though, something is wrong! We have to add the identity matrix, I. Which is a square matrix of 1s along the diagonal. We add it next to the scalar value to make the above statement true:

v(A-lambda*I)=0

Now, before we do PCA, there is one thing we need to do before implementing the above equation. we actually use the covariance matrix of A instead of A. So Cov(A)=M. One other thing to note, is that you also want to normalize all of the columns from 0 to 1 or you can even center the mean at 0 and scale every column from -1 to 1.

So:

v(M-lambda*I)=0; and M is normalized (columns’ means are normalized from 0 to 1 or have their means centered at 0 and are normalized from -1 to 1)

This is the basis behind PCA.

The eigenvectors can be then placed at the origin. Note vectors are scalable and can move around. What is important with the eigenvectors is their direction. All of the eigenvectors will be associated with a variable. I will discuss this in more detail later but what you want to do is calculate the “loadings” by the following:

Loadings = eigenvectors*sqrt(eigenvalues)

The first principal component is what is called the largest dot product. What this means is that the x- axis is aligned most with the vector that is shown. The x- axis and y- axis are in a new space called principal component space when you convert from the traditional x, y-coordinate system to principal components. The maximum number of principal components is the same as the columns or variables that you have. All of these components are independent of each other. It’s hard to imagine a system where all of them are independent of each other, but each variable allows for a degree of freedom.

I will write another article on scores’ plots as well if readers are interested.

Another way you can rank the vectors is by simply ranking them by their eigenvalues. You can rank the vectors’ relative to a specific principal component (usually principal component 1 is used for this) or you can rank them relative to a particular variable’s loading vector (i.e., magnitude of the loading of the variable multiplied by the cosine of the angle (dot product!) between what you are referencing (either the axis or another variable’s loading vector).

A simple app to answer this question is as follows:

Please let me know if anything needs clarification:

Sincerely,

Pharmacoengineering.com