G03 Chapter Contents
G03 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG03BAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G03BAF computes orthogonal rotations for a matrix of loadings using a generalized orthomax criterion.

## 2  Specification

 SUBROUTINE G03BAF ( STAND, G, NVAR, K, FL, LDFL, FLR, R, LDR, ACC, MAXIT, ITER, WK, IFAIL)
 INTEGER NVAR, K, LDFL, LDR, MAXIT, ITER, IFAIL REAL (KIND=nag_wp) G, FL(LDFL,K), FLR(LDFL,K), R(LDR,K), ACC, WK(2*NVAR+K*K+5*(K-1)) CHARACTER(1) STAND

## 3  Description

Let $\Lambda$ be the $p$ by $k$ matrix of loadings from a variable-directed multivariate method, e.g., canonical variate analysis or factor analysis. This matrix represents the relationship between the original $p$ variables and the $k$ orthogonal linear combinations of these variables, the canonical variates or factors. The latter are only unique up to a rotation in the $k$-dimensional space they define. A rotation can then be found that simplifies the structure of the matrix of loadings, and hence the relationship between the original and the derived variables. That is, the elements, ${\lambda }_{ij}^{*}$, of the rotated matrix, ${\Lambda }^{*}$, are either relatively large or small. The rotations may be found by minimizing the criterion:
 $V=∑j=1k∑i=1p λij* 4-γp∑j=1k ∑i=1p λij* 2 2$
where the constant $\gamma$ gives a family of rotations with $\gamma =1$ giving varimax rotations and $\gamma =0$ giving quartimax rotations.
It is generally advised that factor loadings should be standardized, so that the sum of squared elements for each row is one, before computing the rotations.
The matrix of rotations, $R$, such that ${\Lambda }^{*}=\Lambda R$, is computed using first an algorithm based on that described by Cooley and Lohnes (1971), which involves the pairwise rotation of the factors. Then a final refinement is made using a method similar to that described by Lawley and Maxwell (1971), but instead of the eigenvalue decomposition, the algorithm has been adapted to incorporate a singular value decomposition.
Cooley W C and Lohnes P R (1971) Multivariate Data Analysis Wiley
Lawley D N and Maxwell A E (1971) Factor Analysis as a Statistical Method (2nd Edition) Butterworths

## 5  Parameters

1:     STAND – CHARACTER(1)Input
On entry: indicates if the matrix of loadings is to be row standardized before rotation.
${\mathbf{STAND}}=\text{'S'}$
${\mathbf{STAND}}=\text{'U'}$
Constraint: ${\mathbf{STAND}}=\text{'S'}$ or $\text{'U'}$.
2:     G – REAL (KIND=nag_wp)Input
On entry: $\gamma$, the criterion constant with $\gamma =1.0$ giving varimax rotations and $\gamma =0.0$ giving quartimax rotations.
Constraint: ${\mathbf{G}}\ge 0.0$.
3:     NVAR – INTEGERInput
On entry: $p$, the number of original variables.
Constraint: ${\mathbf{NVAR}}\ge {\mathbf{K}}$.
4:     K – INTEGERInput
On entry: $k$, the number of derived variates or factors.
Constraint: ${\mathbf{K}}\ge 2$.
5:     FL(LDFL,K) – REAL (KIND=nag_wp) arrayInput/Output
On entry: $\Lambda$, the matrix of loadings. ${\mathbf{FL}}\left(\mathit{i},\mathit{j}\right)$ must contain the loading for the $\mathit{i}$th variable on the $\mathit{j}$th factor, for $\mathit{i}=1,2,\dots ,p$ and $\mathit{j}=1,2,\dots ,k$.
On exit: if ${\mathbf{STAND}}=\text{'S'}$, the elements of FL are standardized so that the sum of squared elements for each row is $1.0$ and then after the computation of the rotations are rescaled; this may lead to slight differences between the input and output values of FL.
If ${\mathbf{STAND}}=\text{'U'}$, FL will be unchanged on exit.
6:     LDFL – INTEGERInput
On entry: the first dimension of the arrays FL and FLR as declared in the (sub)program from which G03BAF is called.
Constraint: ${\mathbf{LDFL}}\ge {\mathbf{NVAR}}$.
7:     FLR(LDFL,K) – REAL (KIND=nag_wp) arrayOutput
On exit: the rotated matrix of loadings, ${\Lambda }^{*}$. ${\mathbf{FLR}}\left(\mathit{i},\mathit{j}\right)$ will contain the rotated loading for the $\mathit{i}$th variable on the $\mathit{j}$th factor, for $\mathit{i}=1,2,\dots ,p$ and $\mathit{j}=1,2,\dots ,k$.
8:     R(LDR,K) – REAL (KIND=nag_wp) arrayOutput
On exit: the matrix of rotations, $R$.
9:     LDR – INTEGERInput
On entry: the first dimension of the array R as declared in the (sub)program from which G03BAF is called.
Constraint: ${\mathbf{LDR}}\ge {\mathbf{K}}$.
10:   ACC – REAL (KIND=nag_wp)Input
On entry: indicates the accuracy required. The iterative procedure of Cooley and Lohnes (1971) will be stopped and the final refinement computed when the change in $V$ is less than ${\mathbf{ACC}}×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1.0,V\right)$. If ACC is greater than or equal to $0.0$ but less than machine precision or if ACC is greater than $1.0$, then machine precision will be used instead.
Suggested value: $0.00001$.
Constraint: ${\mathbf{ACC}}\ge 0.0$.
11:   MAXIT – INTEGERInput
On entry: the maximum number of iterations.
Constraint: ${\mathbf{MAXIT}}\ge 1$.
12:   ITER – INTEGEROutput
On exit: the number of iterations performed.
13:   WK($2×{\mathbf{NVAR}}+{\mathbf{K}}×{\mathbf{K}}+5×\left({\mathbf{K}}-1\right)$) – REAL (KIND=nag_wp) arrayWorkspace
14:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{K}}<2$, or ${\mathbf{NVAR}}<{\mathbf{K}}$, or ${\mathbf{G}}<0.0$, or ${\mathbf{LDFL}}<{\mathbf{NVAR}}$, or ${\mathbf{LDR}}<{\mathbf{K}}$, or ${\mathbf{ACC}}<0.0$, or ${\mathbf{MAXIT}}\le 0$, or ${\mathbf{STAND}}\ne \text{'S'}$ or $\text{'U'}$.
${\mathbf{IFAIL}}=2$
The singular value decomposition has failed to converge. This is an unlikely error exit.
${\mathbf{IFAIL}}=3$
The algorithm to find $R$ has failed to reach the required accuracy in the given number of iterations. You should try increasing ACC or increasing MAXIT. The returned solution should be a reasonable approximation.

## 7  Accuracy

The accuracy is determined by the value of ACC.

If the results of a principal component analysis as carried out by G03AAF are to be rotated, the loadings as returned in the array P by G03AAF can be supplied via the parameter FL to G03BAF. The resulting rotation matrix can then be used to rotate the principal component scores as returned in the array V by G03AAF. The routine F06YAF (DGEMM) may be used for this matrix multiplication.

## 9  Example

This example is taken from page 75 of Lawley and Maxwell (1971). The results from a factor analysis of ten variables using three factors are input and rotated using varimax rotations without standardizing rows.

### 9.1  Program Text

Program Text (g03bafe.f90)

### 9.2  Program Data

Program Data (g03bafe.d)

### 9.3  Program Results

Program Results (g03bafe.r)