NAG FL Interface
g03ccf (factor_​score)

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

Fortran Interface
Subroutine g03ccf ( method, rotate, nvar, nfac, fl, ldfl, psi, e, r, ldr, fs, ldfs, wk, ifail)
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
C Header Interface
#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.

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, Λ, and the diagonal matrix of variances of the unique components, Ψ. To obtain estimates of the factors, a p by k matrix of factor score coefficients, Φ, is formed. The estimated vector of factor scores, 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 Θ 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 ΛR.

4 References

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

5 Arguments

1: method Character(1) Input
On entry: indicates which method is to be used to compute the factor score coefficients.
method='R'
The regression method is used.
method='B'
Bartlett's method is used.
Constraint: method='B' or 'R'.
2: rotate Character(1) Input
On entry: indicates whether a rotation is to be applied.
rotate='R'
A rotation will be applied to the coefficients and the rotation matrix, R, must be given in r.
rotate='U'
No rotation is applied.
Constraint: rotate='R' or 'U'.
3: nvar Integer Input
On entry: p, the number of observed variables in the factor analysis.
Constraint: nvarnfac.
4: nfac Integer Input
On entry: k, the number of factors in the factor analysis.
Constraint: nfac1.
5: flldflnfac Real (Kind=nag_wp) array Input
On entry: Λ, the matrix of unrotated factor loadings as returned by g03caf.
6: ldfl Integer Input
On entry: the first dimension of the array fl as declared in the (sub)program from which g03ccf is called.
Constraint: ldflnvar.
7: psinvar Real (Kind=nag_wp) array Input
On entry: the diagonal elements of Ψ, as returned by g03caf.
Constraint: psii>0.0, for i=1,2,,p.
8: envar Real (Kind=nag_wp) array Input
On entry: the eigenvalues of the matrix S*, as returned by g03caf.
Constraint: ei>1.0, for i=1,2,,p.
9: rldr* Real (Kind=nag_wp) array Input
Note: the second dimension of the array r must be at least 1 if rotate='U' and at least nfac if rotate='R'.
On entry: if rotate='R', r must contain the orthogonal rotation matrix, R, as returned by g03baf.
If rotate='U', r need not be set.
10: 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 rotate='R', ldrnfac;
  • otherwise ldr1.
11: fsldfsnfac Real (Kind=nag_wp) array Output
On exit: the matrix of factor score coefficients, Φ. fsij contains the factor score coefficient for the jth factor and the ith observed variable, for i=1,2,,p and j=1,2,,k.
12: ldfs Integer Input
On entry: the first dimension of the array fs as declared in the (sub)program from which g03ccf is called.
Constraint: ldfsnvar.
13: wknvar Real (Kind=nag_wp) array Workspace
14: 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 -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).

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:
ifail=1
On entry, ldfl=value and nvar=value.
Constraint: ldflnvar.
On entry, ldfs=value and nvar=value.
Constraint: ldfsnvar.
On entry, ldr=value and nfac=value.
Constraint: ldrnfac.
On entry, method=value
Constraint: method='B' or 'R'.
On entry, nfac=value.
Constraint: nfac1.
On entry, nvar=value and nfac=value.
Constraint: nvarnfac.
On entry, rotate=value.
Constraint: rotate='R' or 'U'.
ifail=2
On entry, i=value and ei1.0.
Constraint: ei>1.0.
On entry, i=value and psii0.0.
Constraint: psii>0.0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

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

8 Parallelism 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.

9 Further Comments

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.

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

10.1 Program Text

Program Text (g03ccfe.f90)

10.2 Program Data

Program Data (g03ccfe.d)

10.3 Program Results

Program Results (g03ccfe.r)