NAG Library Routine Document

g03baf (rot_orthomax)


    1  Purpose
    7  Accuracy


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


Fortran Interface
Subroutine g03baf ( stand, g, nvar, k, fl, ldfl, flr, r, ldr, acc, maxit, iter, wk, ifail)
Integer, Intent (In):: nvar, k, ldfl, ldr, maxit
Integer, Intent (Inout):: ifail
Integer, Intent (Out):: iter
Real (Kind=nag_wp), Intent (In):: g, acc
Real (Kind=nag_wp), Intent (Inout):: fl(ldfl,k), flr(ldfl,k), r(ldr,k)
Real (Kind=nag_wp), Intent (Out):: wk(2*nvar+k*k+5*(k-1))
Character (1), Intent (In):: stand
C Header Interface
#include nagmk26.h
void  g03baf_ (const char *stand, const double *g, const Integer *nvar, const Integer *k, double fl[], const Integer *ldfl, double flr[], double r[], const Integer *ldr, const double *acc, const Integer *maxit, Integer *iter, double wk[], Integer *ifail, const Charlen length_stand)


Let Λ 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, λij*, of the rotated matrix, Λ*, are either relatively large or small. The rotations may be found by minimizing the criterion:
V=j=1ki=1p λij* 4-γpj=1k i=1p λij* 2 2  
where the constant γ gives a family of rotations with γ=1 giving varimax rotations and γ=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 Λ*=Λ 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


1:     stand – Character(1)Input
On entry: indicates if the matrix of loadings is to be row standardized before rotation.
The loadings are row standardized.
The loadings are left unstandardized.
Constraint: stand='S' or 'U'.
2:     g – Real (Kind=nag_wp)Input
On entry: γ, the criterion constant with γ=1.0 giving varimax rotations and γ=0.0 giving quartimax rotations.
Constraint: g0.0.
3:     nvar – IntegerInput
On entry: p, the number of original variables.
Constraint: nvark.
4:     k – IntegerInput
On entry: k, the number of derived variates or factors.
Constraint: k2.
5:     flldflk – Real (Kind=nag_wp) arrayInput/Output
On entry: Λ, the matrix of loadings. flij must contain the loading for the ith variable on the jth factor, for i=1,2,,p and j=1,2,,k.
On exit: if stand='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 stand='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: ldflnvar.
7:     flrldflk – Real (Kind=nag_wp) arrayOutput
On exit: the rotated matrix of loadings, Λ*. flrij will contain the rotated loading for the ith variable on the jth factor, for i=1,2,,p and j=1,2,,k.
8:     rldrk – 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: ldrk.
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 acc×max1.0,V. If acc is greater than or equal to 0.0 but less than machine precision or if acc is greater than 1.0, machine precision will be used instead.
Suggested value: 0.00001.
Constraint: acc0.0.
11:   maxit – IntegerInput
On entry: the maximum number of iterations.
Suggested value: 30.
Constraint: maxit1.
12:   iter – IntegerOutput
On exit: the number of iterations performed.
13:   wk2×nvar+k×k+5×k-1 – Real (Kind=nag_wp) arrayWorkspace
14:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ 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 argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry,k<2,
orstand'S' or 'U'.
The singular value decomposition has failed to converge. This is an unlikely error exit.
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.
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


The accuracy is determined by the value of acc.

Parallelism and Performance

g03baf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

Further Comments

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 argument 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.


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.

Program Text

Program Text (g03bafe.f90)

Program Data

Program Data (g03bafe.d)

Program Results

Program Results (g03bafe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017