G03 Chapter Contents
G03 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG03CCF

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

G03CCF computes factor score coefficients from the result of fitting a factor analysis model by maximum likelihood as performed by G03CAF.

## 2  Specification

 SUBROUTINE G03CCF ( METHOD, ROTATE, NVAR, NFAC, FL, LDFL, PSI, E, R, LDR, FS, LDFS, WK, IFAIL)
 INTEGER NVAR, NFAC, LDFL, LDR, LDFS, IFAIL REAL (KIND=nag_wp) FL(LDFL,NFAC), PSI(NVAR), E(NVAR), R(LDR,*), FS(LDFS,NFAC), WK(NVAR) CHARACTER(1) METHOD, ROTATE

## 3  Description

A factor analysis model aims to account for the covariances among $p$ variables, observed on $n$ individuals, in terms of a smaller number, $k$, of unobserved variables or factors. The values of the factors for an individual are known as factor scores. G03CAF fits the factor analysis model by maximum likelihood and returns the estimated factor loading matrix, $\Lambda$, and the diagonal matrix of variances of the unique components, $\Psi$. To obtain estimates of the factors, a $p$ by $k$ matrix of factor score coefficients, $\Phi$, is formed. The estimated vector of factor scores, $\stackrel{^}{f}$, is then given by:
 $f^=xTΦ,$
where $x$ is the vector of observed variables for an individual.
There are two commonly used methods of obtaining factor score coefficients.
The regression method:
 $Φ=Ψ-1ΛI+ΛTΨ-1Λ -1,$
and Bartlett's method:
 $Φ=Ψ-1ΛΛTΨ-1Λ -1.$
See Lawley and Maxwell (1971) for details of both methods. In the regression method as given above, it is assumed that the factors are not correlated and have unit variance; this is true for models fitted by G03CAF. Further, for models fitted by G03CAF,
 $ΛTΨ-1Λ=Θ-I,$
where $\Theta$ is the diagonal matrix of eigenvalues of the matrix ${S}^{*}$, as described in G03CAF.
The factors may be orthogonally rotated using an orthogonal rotation matrix, $R$, as computed by G03BAF. The factor scores for the rotated matrix are then given by $\Lambda R$.

## 4  References

Lawley D N and Maxwell A E (1971) Factor Analysis as a Statistical Method (2nd Edition) Butterworths

## 5  Parameters

1:     METHOD – CHARACTER(1)Input
On entry: indicates which method is to be used to compute the factor score coefficients.
${\mathbf{METHOD}}=\text{'R'}$
The regression method is used.
${\mathbf{METHOD}}=\text{'B'}$
Bartlett's method is used.
Constraint: ${\mathbf{METHOD}}=\text{'B'}$ or $\text{'R'}$.
2:     ROTATE – CHARACTER(1)Input
On entry: indicates whether a rotation is to be applied.
${\mathbf{ROTATE}}=\text{'R'}$
A rotation will be applied to the coefficients and the rotation matrix, $R$, must be given in R.
${\mathbf{ROTATE}}=\text{'U'}$
No rotation is applied.
Constraint: ${\mathbf{ROTATE}}=\text{'R'}$ or $\text{'U'}$.
3:     NVAR – INTEGERInput
On entry: $p$, the number of observed variables in the factor analysis.
Constraint: ${\mathbf{NVAR}}\ge {\mathbf{NFAC}}$.
4:     NFAC – INTEGERInput
On entry: $k$, the number of factors in the factor analysis.
Constraint: ${\mathbf{NFAC}}\ge 1$.
5:     FL(LDFL,NFAC) – REAL (KIND=nag_wp) arrayInput
On entry: $\Lambda$, the matrix of unrotated factor loadings as returned by G03CAF.
6:     LDFL – INTEGERInput
On entry: the first dimension of the array FL as declared in the (sub)program from which G03CCF is called.
Constraint: ${\mathbf{LDFL}}\ge {\mathbf{NVAR}}$.
7:     PSI(NVAR) – REAL (KIND=nag_wp) arrayInput
On entry: the diagonal elements of $\Psi$, as returned by G03CAF.
Constraint: ${\mathbf{PSI}}\left(\mathit{i}\right)>0.0$, for $\mathit{i}=1,2,\dots ,p$.
8:     E(NVAR) – REAL (KIND=nag_wp) arrayInput
On entry: the eigenvalues of the matrix ${S}^{*}$, as returned by G03CAF.
Constraint: ${\mathbf{E}}\left(\mathit{i}\right)>1.0$, for $\mathit{i}=1,2,\dots ,p$.
9:     R(LDR,$*$) – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array R must be at least $1$ if ${\mathbf{ROTATE}}=\text{'U'}$ and at least ${\mathbf{NFAC}}$ if ${\mathbf{ROTATE}}=\text{'R'}$.
On entry: if ${\mathbf{ROTATE}}=\text{'R'}$, R must contain the orthogonal rotation matrix, $R$, as returned by G03BAF.
If ${\mathbf{ROTATE}}=\text{'U'}$, R need not be set.
10:   LDR – INTEGERInput
On entry: the first dimension of the array R as declared in the (sub)program from which G03CCF is called.
Constraints:
• if ${\mathbf{ROTATE}}=\text{'R'}$, ${\mathbf{LDR}}\ge {\mathbf{NFAC}}$;
• otherwise $1$.
11:   FS(LDFS,NFAC) – REAL (KIND=nag_wp) arrayOutput
On exit: the matrix of factor score coefficients, $\Phi$. ${\mathbf{FS}}\left(\mathit{i},\mathit{j}\right)$ contains the factor score coefficient for the $\mathit{j}$th factor and the $\mathit{i}$th observed variable, for $\mathit{i}=1,2,\dots ,p$ and $\mathit{j}=1,2,\dots ,k$.
12:   LDFS – INTEGERInput
On entry: the first dimension of the array FS as declared in the (sub)program from which G03CCF is called.
Constraint: ${\mathbf{LDFS}}\ge {\mathbf{NVAR}}$.
13:   WK(NVAR) – 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{NFAC}}<1$, or ${\mathbf{NVAR}}<{\mathbf{NFAC}}$, or ${\mathbf{LDFL}}<{\mathbf{NVAR}}$, or ${\mathbf{LDFS}}<{\mathbf{NVAR}}$, or ${\mathbf{ROTATE}}=\text{'R'}$ and ${\mathbf{LDR}}<{\mathbf{NFAC}}$, or ${\mathbf{METHOD}}\ne \text{'R'}$ or $\text{'B'}$, or ${\mathbf{ROTATE}}\ne \text{'R'}$ or $\text{'U'}$.
${\mathbf{IFAIL}}=2$
 On entry, a value of ${\mathbf{PSI}}\le 0.0$, or a value of ${\mathbf{E}}\le 1.0$.

## 7  Accuracy

Accuracy will depend on the accuracy requested when computing the estimated factor loadings using G03CAF.

To compute the factor scores using the factor score coefficients the values for the observed variables first need to be standardized by subtracting the sample means and, if the factor analysis is based upon a correlation matrix, dividing by the sample standard deviations. This may be performed using G03ZAF. The standardized variables are then post-multiplied by the factor score coefficients. This may be performed using routines from Chapter F06, for example F06YAF (DGEMM).
If principal component analysis is required the routine G03AAF computes the principal component scores directly. Hence, the factor score coefficients are not needed.

## 9  Example

This example is taken from Lawley and Maxwell (1971). The correlation matrix for 220 observations on six school subjects is input and a factor analysis model with two factors fitted using G03CAF. The factor score coefficients are computed using the regression method.

### 9.1  Program Text

Program Text (g03ccfe.f90)

### 9.2  Program Data

Program Data (g03ccfe.d)

### 9.3  Program Results

Program Results (g03ccfe.r)