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$p$ variables, observed on n$n$ individuals, in terms of a smaller number, k$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$p$ by k$k$ matrix of factor score coefficients, Φ$\Phi$, is formed. The estimated vector of factor scores, $\stackrel{^}{f}$, is then given by:
 f̂ = xTΦ, $f^=xTΦ,$
where x$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, $Φ=Ψ-1Λ(I+ΛTΨ-1Λ) -1,$
and Bartlett's method:
 Φ = Ψ − 1Λ(ΛTΨ − 1Λ) − 1. $Φ=Ψ-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, $ΛTΨ-1Λ=Θ-I,$
where Θ$\Theta$ is the diagonal matrix of eigenvalues of the matrix S*${S}^{*}$, as described in nag_mv_factor (g03ca).
The factors may be orthogonally rotated using an orthogonal rotation matrix, R$R$, as computed by nag_mv_rot_orthomax (g03ba). The factor scores for the rotated matrix are then given by ΛR$\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:     method – string (length ≥ 1)
Indicates which method is to be used to compute the factor score coefficients.
method = 'R'${\mathbf{method}}=\text{'R'}$
The regression method is used.
method = 'B'${\mathbf{method}}=\text{'B'}$
Bartlett's method is used.
Constraint: method = 'B'${\mathbf{method}}=\text{'B'}$ or 'R'$\text{'R'}$.
2:     rotate – string (length ≥ 1)
Indicates whether a rotation is to be applied.
rotate = 'R'${\mathbf{rotate}}=\text{'R'}$
A rotation will be applied to the coefficients and the rotation matrix, R$R$, must be given in r.
rotate = 'U'${\mathbf{rotate}}=\text{'U'}$
No rotation is applied.
Constraint: rotate = 'R'${\mathbf{rotate}}=\text{'R'}$ or 'U'$\text{'U'}$.
3:     fl(ldfl,nfac) – double array
ldfl, the first dimension of the array, must satisfy the constraint ldflnvar$\mathit{ldfl}\ge {\mathbf{nvar}}$.
Λ$\Lambda$, the matrix of unrotated factor loadings as returned by nag_mv_factor (g03ca).
4:     psi(nvar) – double array
nvar, the dimension of the array, must satisfy the constraint ${\mathbf{nvar}}\ge {\mathbf{nfac}}$.
The diagonal elements of Ψ$\Psi$, as returned by nag_mv_factor (g03ca).
Constraint: psi(i) > 0.0${\mathbf{psi}}\left(\mathit{i}\right)>0.0$, for i = 1,2,,p$\mathit{i}=1,2,\dots ,p$.
5:     e(nvar) – double array
nvar, the dimension of the array, must satisfy the constraint ${\mathbf{nvar}}\ge {\mathbf{nfac}}$.
The eigenvalues of the matrix S*${S}^{*}$, as returned by nag_mv_factor (g03ca).
Constraint: e(i) > 1.0${\mathbf{e}}\left(\mathit{i}\right)>1.0$, for i = 1,2,,p$\mathit{i}=1,2,\dots ,p$.
6:     r(ldr, : $:$) – double array
The first dimension, ldr, of the array r must satisfy
• if rotate = 'R'${\mathbf{rotate}}=\text{'R'}$, ldrnfac$\mathit{ldr}\ge {\mathbf{nfac}}$;
• otherwise 1$1$.
The second dimension of the array must be at least 1$1$ if rotate = 'U'${\mathbf{rotate}}=\text{'U'}$ and at least nfac${\mathbf{nfac}}$ if rotate = 'R'${\mathbf{rotate}}=\text{'R'}$
If rotate = 'R'${\mathbf{rotate}}=\text{'R'}$, r must contain the orthogonal rotation matrix, R$R$, as returned by nag_mv_rot_orthomax (g03ba).
If rotate = 'U'${\mathbf{rotate}}=\text{'U'}$, r need not be set.

### Optional Input Parameters

1:     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$p$, the number of observed variables in the factor analysis.
Constraint: ${\mathbf{nvar}}\ge {\mathbf{nfac}}$.
2:     nfac – int64int32nag_int scalar
Default: The second dimension of the array fl.
k$k$, the number of factors in the factor analysis.
Constraint: nfac1${\mathbf{nfac}}\ge 1$.

ldfl ldr ldfs wk

### Output Parameters

1:     fs(ldfs,nfac) – double array
ldfsnvar$\mathit{ldfs}\ge {\mathbf{nvar}}$.
The matrix of factor score coefficients, Φ$\Phi$. fs(i,j)${\mathbf{fs}}\left(\mathit{i},\mathit{j}\right)$ contains the factor score coefficient for the j$\mathit{j}$th factor and the i$\mathit{i}$th observed variable, for i = 1,2,,p$\mathit{i}=1,2,\dots ,p$ and j = 1,2,,k$\mathit{j}=1,2,\dots ,k$.
2:     ifail – int64int32nag_int scalar
${\mathrm{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:
ifail = 1${\mathbf{ifail}}=1$
 On entry, nfac < 1${\mathbf{nfac}}<1$, or ${\mathbf{nvar}}<{\mathbf{nfac}}$, or ldfl < nvar$\mathit{ldfl}<{\mathbf{nvar}}$, or ldfs < nvar$\mathit{ldfs}<{\mathbf{nvar}}$, or rotate = 'R'${\mathbf{rotate}}=\text{'R'}$ and ldr < nfac$\mathit{ldr}<{\mathbf{nfac}}$, or method ≠ 'R'${\mathbf{method}}\ne \text{'R'}$ or 'B'$\text{'B'}$, or rotate ≠ 'R'${\mathbf{rotate}}\ne \text{'R'}$ or 'U'$\text{'U'}$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, a value of psi ≤ 0.0${\mathbf{psi}}\le 0.0$, or a value of e ≤ 1.0${\mathbf{e}}\le 1.0$.

## 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

```function nag_mv_factor_score_example
method = 'R';
rotate = 'U';
fl = [0.5533188537924767, -0.4285636478848139;
0.568155945618757, -0.2883165515607369;
0.3921781680583233, -0.4499647969874735;
0.7404217621764928, 0.2728004512944507;
0.7238701315235972, 0.2113108264190836;
0.5953586397783871, 0.1316911981935982];
psi = [0.5101714468054336;
0.5940723866877339;
0.6437279642693183;
0.3773554593674197;
0.4313596544519335;
0.6282055268211231];
e = [5.61418330106997;
2.142797556801369;
1.092257889179389;
1.026411127333595;
0.9908235560038364;
0.8905078592462671];
r = [0.001066610312409233];
[fs, ifail] = nag_mv_factor_score(method, rotate, fl, psi, e, r)
```
```

fs =

0.1932   -0.3920
0.1703   -0.2265
0.1085   -0.3262
0.3495    0.3374
0.2989    0.2286
0.1688    0.0978

ifail =

0

```
```function g03cc_example
method = 'R';
rotate = 'U';
fl = [0.5533188537924767, -0.4285636478848139;
0.568155945618757, -0.2883165515607369;
0.3921781680583233, -0.4499647969874735;
0.7404217621764928, 0.2728004512944507;
0.7238701315235972, 0.2113108264190836;
0.5953586397783871, 0.1316911981935982];
psi = [0.5101714468054336;
0.5940723866877339;
0.6437279642693183;
0.3773554593674197;
0.4313596544519335;
0.6282055268211231];
e = [5.61418330106997;
2.142797556801369;
1.092257889179389;
1.026411127333595;
0.9908235560038364;
0.8905078592462671];
r = [0.001066610312409233];
[fs, ifail] = g03cc(method, rotate, fl, psi, e, r)
```
```

fs =

0.1932   -0.3920
0.1703   -0.2265
0.1085   -0.3262
0.3495    0.3374
0.2989    0.2286
0.1688    0.0978

ifail =

0

```