Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_mv_factor_score (g03cc)

## Purpose

nag_mv_factor_score (g03cc) computes factor score coefficients from the result of fitting a factor analysis model by maximum likelihood as performed by nag_mv_factor (g03ca).

## Syntax

[fs, ifail] = g03cc(method, rotate, fl, psi, e, r, 'nvar', nvar, 'nfac', nfac)
[fs, ifail] = nag_mv_factor_score(method, rotate, fl, psi, e, r, 'nvar', nvar, 'nfac', nfac)

## 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. nag_mv_factor (g03ca) 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 nag_mv_factor (g03ca). Further, for models fitted by nag_mv_factor (g03ca),
 $ΛTΨ-1Λ=Θ-I,$
where $\Theta$ is the diagonal matrix of eigenvalues of the matrix ${S}^{*}$, as described in nag_mv_factor (g03ca).
The factors may be orthogonally rotated using an orthogonal rotation matrix, $R$, as computed by nag_mv_rot_orthomax (g03ba). The factor scores for the rotated matrix are then given by $\Lambda R$.

## References

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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{method}$ – string (length ≥ 1)
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:     $\mathrm{rotate}$ – string (length ≥ 1)
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:     $\mathrm{fl}\left(\mathit{ldfl},{\mathbf{nfac}}\right)$ – double array
ldfl, the first dimension of the array, must satisfy the constraint $\mathit{ldfl}\ge {\mathbf{nvar}}$.
$\Lambda$, the matrix of unrotated factor loadings as returned by nag_mv_factor (g03ca).
4:     $\mathrm{psi}\left({\mathbf{nvar}}\right)$ – double array
The diagonal elements of $\Psi$, as returned by nag_mv_factor (g03ca).
Constraint: ${\mathbf{psi}}\left(\mathit{i}\right)>0.0$, for $\mathit{i}=1,2,\dots ,p$.
5:     $\mathrm{e}\left({\mathbf{nvar}}\right)$ – double array
The eigenvalues of the matrix ${S}^{*}$, as returned by nag_mv_factor (g03ca).
Constraint: ${\mathbf{e}}\left(\mathit{i}\right)>1.0$, for $\mathit{i}=1,2,\dots ,p$.
6:     $\mathrm{r}\left(\mathit{ldr},:\right)$ – double array
The first dimension, $\mathit{ldr}$, of the array r must satisfy
• if ${\mathbf{rotate}}=\text{'R'}$, $\mathit{ldr}\ge {\mathbf{nfac}}$;
• otherwise $1$.
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'}$.
If ${\mathbf{rotate}}=\text{'R'}$, r must contain the orthogonal rotation matrix, $R$, as returned by nag_mv_rot_orthomax (g03ba).
If ${\mathbf{rotate}}=\text{'U'}$, r need not be set.

### Optional Input Parameters

1:     $\mathrm{nvar}$int64int32nag_int scalar
Default: the dimension of the arrays psi, e and the first dimension of the array fl. (An error is raised if these dimensions are not equal.)
$p$, the number of observed variables in the factor analysis.
Constraint: ${\mathbf{nvar}}\ge {\mathbf{nfac}}$.
2:     $\mathrm{nfac}$int64int32nag_int scalar
Default: the second dimension of the array fl.
$k$, the number of factors in the factor analysis.
Constraint: ${\mathbf{nfac}}\ge 1$.

### Output Parameters

1:     $\mathrm{fs}\left(\mathit{ldfs},{\mathbf{nfac}}\right)$ – double array
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$.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{nfac}}<1$, or ${\mathbf{nvar}}<{\mathbf{nfac}}$, or $\mathit{ldfl}<{\mathbf{nvar}}$, or $\mathit{ldfs}<{\mathbf{nvar}}$, or ${\mathbf{rotate}}=\text{'R'}$ and $\mathit{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$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

Accuracy will depend on the accuracy requested when computing the estimated factor loadings using nag_mv_factor (g03ca).

If principal component analysis is required the function nag_mv_prin_comp (g03aa) computes the principal component scores directly. Hence, the factor score coefficients are not needed.

## 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 nag_mv_factor (g03ca). The factor score coefficients are computed using the regression method.
```function g03cc_example

fprintf('g03cc example results\n\n');

matrix = 'C';
n = int64(220);
x = [1.000 0.439 0.410 0.288 0.329 0.248;
0.439 1.000 0.351 0.354 0.320 0.329;
0.410 0.351 1.000 0.164 0.190 0.181;
0.288 0.354 0.164 1.000 0.595 0.470;
0.329 0.320 0.190 0.595 1.000 0.464;
0.248 0.329 0.181 0.470 0.464 1.000];

nvar = int64(size(x,1));
isx  = ones(nvar,1,'int64');
nfac = int64(2);
iop  = [int64(1); -1;  500;  3;  5];

% Fit factor analysis model
[e, stat, com, psi, res, fl, ifail] = ...
g03ca( ...
matrix, n, x, nvar, isx, nfac, iop);

for i = 1:nvar
fprintf('%8.3f', fl(i,1:nfac), com(i), psi(i));
fprintf('\n');
end

% Compute factor scores
method = 'R';
rotate = 'U';
r      = ;
[fs, ifail] = g03cc( ...
method, rotate, fl, psi, e, r);

mtitle = 'Factor score coefficients';
matrix = 'General';
diag   = ' ';

fprintf('\n');
[ifail] = x04ca( ...
matrix, diag, fs, mtitle);

```
```g03cc example results

0.553  -0.429   0.490   0.510
0.568  -0.288   0.406   0.594
0.392  -0.450   0.356   0.644
0.740   0.273   0.623   0.377
0.724   0.211   0.569   0.431
0.595   0.132   0.372   0.628

Factor score coefficients
1       2
1   0.1932 -0.3920
2   0.1703 -0.2265
3   0.1085 -0.3262
4   0.3495  0.3374
5   0.2989  0.2286
6   0.1688  0.0978
```