Varimax Algorithm

As observed in section Rotation, we seek an m × m orthogonal rotation U  = [uij] of the factor matrix such that the rows represent the existing factors and the columns represent the new factors. The most popular rotation approach is called Varimax, which maximizes the differences between the loading factors while maintaining orthogonal axes. Varimax attempts to maximize the value of V where

Varimax formulaThe algorithm used is iterative and consists of the following steps. We illustrate each step using starting with the loading factors matrix from Figure 2 of Determining the Number of Factors.

Step 0: Normalize the loading factors matrix so that each row in the resulting matrix is a unit vector. This is done as usual by dividing each cell by the square root of the sum of squares in that row.

Normalize factor loadings matrix

Figure 1 – Normalization of the Loading Factors matrix 

Range A4:D12 contains the original loading factors. The communalities are listed in column E. For example, cell E4 contains the formula =SUMSQ(A4:D4). The normalized matrix is shown in range G4:J12. For example, cell G4 contains the formula =A4/SQRT($E4).

Step 1: Each step consists of C(m, 2) substeps. In each substep two columns in the loading factors matrix are rotated. Since there are m columns there are C(m, 2) such pairwise rotations. In our example we first rotate columns 1 and 2, then 1 and 1 and 3, then 1 and 4, then 2 and 3, then 2 and 4, and finally 3 and 4.

Note that a rotation of a matrix with two columns consists of multiplication by a matrix of the following form

Rotation matrix

where θ is the angle of rotation.

Each such rotation produces a new loading factors matrix which is used in the next substep. We start in step 1 with the normalized loading factors matrix in range G4:J12 of Figure C11.1.

We illustrate this first substep in Figure 2.

Varimax algorithm Excel 1

Figure 2 – Varimax step 1:  rotate columns 1 and 2

Range A16:D24 is the normalized matrix calculated in step 0. This is calculated by the array formula = G4:J12.

Cells F15 and G15 show the numbers of the two columns being rotated. Ranges F16:F24 and G16:G24 are simply the two columns being rotated. We can use the INDEX function to select the correct columns. E.g. cell F16 contains the formula =INDEX(A16:D24,,F15).

Columns I, J, K and L are calculated using the following formulas:

Each element in column I (headed by u) is equal to the difference in the squares of the elements in the corresponding row of the two columns being rotated. E.g. cell I16 contains the formula =F16^2–G16^2.

Each element in column J (headed by v) is equal to 2 times the product of the elements in the corresponding row of the two columns being rotated. E.g. cell J16 contains the formula =2*F16*G16.

Columns K and L are defined by their headings. E.g., cell K16 contains the formula =I16^2–J16^2 and cell L16 contains the formula =I16*J16.

Cells I25, J25, K25 and L25 (labeled A; B, C and D) contain the sum of the elements above them. E.g. cell I25 contains the formula =SUM(I16:I24).

Cells O16 and O17 (labeled X and Y respectively) are calculated as follows:

X = 2(Dk – AB)               Y = Ck – (A2 B2)

where k = the number of rows in the original loading factors matrix. Thus cell O16 contains the formula =2*(L25*B26–I25*J25) and cell O17 contains the formula =K25*B26– (I25^2–J25^2).

The angle of rotation is θ = ¼arctan(X/Y). The 2 × 2 matrix N20:O21 now contains the rotation matrix corresponding to θ. Thus cell O18 contains the formula =0.25*ATAN(O16/O17), cell N20 contains the formula =COS(O18), cell N21 contains the formula =SIN(O18), cell O20 contains the formula =N21 and cell O21 contains the formula =–N20.

Finally we need to perform the rotation of columns F and G. The result appears in columns Q and R. Here the range Q16:R24 is calculated by the array formula =MMULT(F16:G24,N20:O21).

We next replace columns 1 and 2 in range A16:D24 by the rotated columns. The resulting matrix is shown in Figure 3 as range A29:D37.

Varimax algorithm Excel 2Figure 3 – Varimax step 1:  rotate columns 1 and 3

For example, cell A29 of the range A29:D37 can be calculated by the formula


and similarly for the other cells in the matrix. In fact, the rest of the matrix can be calculated by placing this formula cell A29, highlighting the range A29:D37 and pressing Ctrl-R and Ctrl-D.

The procedure described above is repeated, this time rotating columns 1 and 3. After the rotation of columns 1 and 4, 2 and 3, 2 and 4, and 3 and 4, we arrive at step 2 where we start the process from the beginning (using the latest version of the loading factors matrix).

The process is repeated until either there is little change in the resulting matrix or a predefined number of iterations have occurred. In fact after 12 iterations we arrive at the configuration shown in Figure 4.

Variamax algorithm ExcelFigure 4 – Varimax convergence

As you can see (cell O954) the angle of rotation pretty close to zero and so no rotation is occurring. The matrix in range A952:D960 is therefore the result of the Varimax rotation in normalized form. We now unnormalize the result, as shown in Figure 5.

Varimax algorithm Excel rotation

Figure 5 – Varimax final result

Here the matrix on the left (range L4:O12) is simply a copy of range A952:D960 from Figure 4. The final version of the loading factors matrix after Varimax rotation is given in range Q4:T12. For example, cell Q4 contains the formula =L4*SQRT($E4) where E4 is defined in Figure 1. Note that we can use SUMSQ(L4:O4) in place of E4 and get the same result.

6 Responses to Varimax Algorithm

  1. Dippies says:

    Nice explanation. Thanks.
    I would like to go one step further in understanding how we got the equations:
    X = 2(Dk – AB)
    Y = Ck – (A2 – B2)
    Can you help me understand that please?

    • Dippies says:

      Also, how the u, v, u^2-v^2 & uv was considered to produce X & Y. Thanks in advance. I must say this article is excellent to move to further steps of deeper understanding.

    • Charles says:

      I used these formulas since these are part of the Varimax transformation.
      Unfortunately, I don’t recall why these formulas yield the results desired by Varimax.

  2. Aleksey Oschepkov says:

    It’s brilliant. This algorithm was very useful in my varimax problem. Thank you very much!

  3. Felipe Freitas says:

    Congratulations! Amazing explanation that helped me so much! Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *