# NAG FL Interfaceg03ccf (factor_​score)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine g03ccf ( nvar, nfac, fl, ldfl, psi, e, r, ldr, fs, ldfs, wk,
 Integer, Intent (In) :: nvar, nfac, ldfl, ldr, ldfs Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: fl(ldfl,nfac), psi(nvar), e(nvar), r(ldr,*) Real (Kind=nag_wp), Intent (Inout) :: fs(ldfs,nfac) Real (Kind=nag_wp), Intent (Out) :: wk(nvar) Character (1), Intent (In) :: method, rotate
#include <nag.h>
 void g03ccf_ (const char *method, const char *rotate, const Integer *nvar, const Integer *nfac, const double fl[], const Integer *ldfl, const double psi[], const double e[], const double r[], const Integer *ldr, double fs[], const Integer *ldfs, double wk[], Integer *ifail, const Charlen length_method, const Charlen length_rotate)
The routine may be called by the names g03ccf or nagf_mv_factor_score.

## 3Description

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×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$.

## 4References

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

## 5Arguments

1: $\mathbf{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: $\mathbf{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: $\mathbf{nvar}$Integer Input
On entry: $p$, the number of observed variables in the factor analysis.
Constraint: ${\mathbf{nvar}}\ge {\mathbf{nfac}}$.
4: $\mathbf{nfac}$Integer Input
On entry: $k$, the number of factors in the factor analysis.
Constraint: ${\mathbf{nfac}}\ge 1$.
5: $\mathbf{fl}\left({\mathbf{ldfl}},{\mathbf{nfac}}\right)$Real (Kind=nag_wp) array Input
On entry: $\Lambda$, the matrix of unrotated factor loadings as returned by g03caf.
6: $\mathbf{ldfl}$Integer Input
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: $\mathbf{psi}\left({\mathbf{nvar}}\right)$Real (Kind=nag_wp) array Input
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: $\mathbf{e}\left({\mathbf{nvar}}\right)$Real (Kind=nag_wp) array Input
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: $\mathbf{r}\left({\mathbf{ldr}},*\right)$Real (Kind=nag_wp) array Input
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: $\mathbf{ldr}$Integer Input
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 ${\mathbf{ldr}}\ge 1$.
11: $\mathbf{fs}\left({\mathbf{ldfs}},{\mathbf{nfac}}\right)$Real (Kind=nag_wp) array Output
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: $\mathbf{ldfs}$Integer Input
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: $\mathbf{wk}\left({\mathbf{nvar}}\right)$Real (Kind=nag_wp) array Workspace
14: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{ldfl}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nvar}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldfl}}\ge {\mathbf{nvar}}$.
On entry, ${\mathbf{ldfs}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nvar}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldfs}}\ge {\mathbf{nvar}}$.
On entry, ${\mathbf{ldr}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nfac}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldr}}\ge {\mathbf{nfac}}$.
On entry, ${\mathbf{method}}=⟨\mathit{\text{value}}⟩$
Constraint: ${\mathbf{method}}=\text{'B'}$ or $\text{'R'}$.
On entry, ${\mathbf{nfac}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nfac}}\ge 1$.
On entry, ${\mathbf{nvar}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nfac}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nvar}}\ge {\mathbf{nfac}}$.
On entry, ${\mathbf{rotate}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{rotate}}=\text{'R'}$ or $\text{'U'}$.
${\mathbf{ifail}}=2$
On entry, $i=⟨\mathit{\text{value}}⟩$ and ${\mathbf{e}}\left(i\right)\le 1.0$.
Constraint: ${\mathbf{e}}\left(i\right)>1.0$.
On entry, $i=⟨\mathit{\text{value}}⟩$ and ${\mathbf{psi}}\left(i\right)\le 0.0$.
Constraint: ${\mathbf{psi}}\left(i\right)>0.0$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

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

## 8Parallelism and Performance

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

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.
If principal component analysis is required the routine g03aaf computes the principal component scores directly. Hence, the factor score coefficients are not needed.

## 10Example

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.

### 10.1Program Text

Program Text (g03ccfe.f90)

### 10.2Program Data

Program Data (g03ccfe.d)

### 10.3Program Results

Program Results (g03ccfe.r)