# NAG CL Interfaceg03ccc (factor_​score)

Settings help

CL Name Style:

## 1Purpose

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

## 2Specification

 #include
 void g03ccc (Nag_FacScoreMethod method, Nag_FacRotation rotate, Integer nvar, Integer nfac, const double fl[], Integer tdfl, const double psi[], const double e[], const double r[], Integer tdr, double fs[], Integer tdfs, NagError *fail)
The function may be called by the names: g03ccc, nag_mv_factor_score or nag_mv_fac_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. g03cac 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 g03cac. Further, for models fitted by g03cac,
 $Λ T Ψ -1 Λ = Θ - I ,$
where $\Theta$ is the diagonal matrix of eigenvalues of the matrix ${S}^{*}$, as described in g03cac.
The factors may be orthogonally rotated using an orthogonal rotation matrix, $R$, as computed by g03bac. The factor scores for the rotated matrix are then given by $\Lambda R$.
Lawley D N and Maxwell A E (1971) Factor Analysis as a Statistical Method (2nd Edition) Butterworths

## 5Arguments

1: $\mathbf{method}$Nag_FacScoreMethod Input
On entry: indicates which method is to be used to compute the factor score coefficients.
${\mathbf{method}}=\mathrm{Nag_FacScoreRegsn}$
The regression method is used.
${\mathbf{method}}=\mathrm{Nag_FacScoreBart}$
Bartlett's method is used.
Constraint: ${\mathbf{method}}=\mathrm{Nag_FacScoreRegsn}$ or $\mathrm{Nag_FacScoreBart}$.
2: $\mathbf{rotate}$Nag_FacRotation Input
On entry: indicates whether a rotation is to be applied.
${\mathbf{rotate}}=\mathrm{Nag_FacRotate}$
A rotation will be applied to the coefficients and the rotation matrix, $R$, must be given in r.
${\mathbf{rotate}}=\mathrm{Nag_FacNoRotate}$
No rotation is applied.
Constraint: ${\mathbf{rotate}}=\mathrm{Nag_FacRotate}$ or $\mathrm{Nag_FacNoRotate}$.
3: $\mathbf{nvar}$Integer Input
On entry: the number of observed variables in the factor analysis, $p$.
Constraint: ${\mathbf{nvar}}\ge {\mathbf{nfac}}$.
4: $\mathbf{nfac}$Integer Input
On entry: the number of factors in the factor analysis, $k$.
Constraint: ${\mathbf{nfac}}\ge 1$.
5: $\mathbf{fl}\left[{\mathbf{nvar}}×{\mathbf{tdfl}}\right]$const double Input
Note: the $\left(i,j\right)$th element of the matrix is stored in ${\mathbf{fl}}\left[\left(i-1\right)×{\mathbf{tdfl}}+j-1\right]$.
On entry: the matrix of unrotated factor loadings, $\Lambda$, as returned by g03cac.
6: $\mathbf{tdfl}$Integer Input
On entry: the stride separating matrix column elements in the array fl.
Constraint: ${\mathbf{tdfl}}\ge {\mathbf{nfac}}$.
7: $\mathbf{psi}\left[{\mathbf{nvar}}\right]$const double Input
On entry: the diagonal elements of $\Psi$, as returned by g03cac.
Constraint: ${\mathbf{psi}}\left[\mathit{i}-1\right]>0.0$, for $\mathit{i}=1,2,\dots ,p$.
8: $\mathbf{e}\left[{\mathbf{nvar}}\right]$const double Input
On entry: the eigenvalues of the matrix ${S}^{*}$, as returned by g03cac.
Constraint: ${\mathbf{e}}\left[\mathit{i}-1\right]>1.0$, for $\mathit{i}=1,2,\dots ,p$.
9: $\mathbf{r}\left[{\mathbf{nfac}}×{\mathbf{tdr}}\right]$const double Input
Note: the $\left(i,j\right)$th element of the matrix $R$ is stored in ${\mathbf{r}}\left[\left(i-1\right)×{\mathbf{tdr}}+j-1\right]$.
On entry: if ${\mathbf{rotate}}=\mathrm{Nag_FacRotate}$, then r must contain the orthogonal rotation matrix, $R$, as returned by g03bac.
If ${\mathbf{rotate}}=\mathrm{Nag_FacNoRotate}$ then r need not be set.
10: $\mathbf{tdr}$Integer Input
On entry: the stride separating matrix column elements in the array r.
Constraint: if ${\mathbf{rotate}}=\mathrm{Nag_FacRotate}$ then ${\mathbf{tdr}}\ge {\mathbf{nfac}}$.
11: $\mathbf{fs}\left[{\mathbf{nvar}}×{\mathbf{tdfs}}\right]$double Output
On exit: the matrix of factor score coefficients, $\Phi$. ${\mathbf{fs}}\left[\left(\mathit{i}-1\right)×{\mathbf{tdfs}}+\mathit{j}-1\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{tdfs}$Integer Input
On entry: the stride separating matrix column elements in the array fs.
Constraint: ${\mathbf{tdfs}}\ge {\mathbf{nfac}}$.
13: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_2_INT_ARG_ENUM_CONS
On entry, ${\mathbf{tdr}}=⟨\mathit{\text{value}}⟩$ while ${\mathbf{nfac}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{rotate}}=\mathrm{Nag_FacRotate}$. These arguments must satisfy ${\mathbf{tdr}}\ge {\mathbf{nfac}}$ when ${\mathbf{rotate}}=\mathrm{Nag_FacRotate}$.
NE_2_INT_ARG_LT
On entry, ${\mathbf{nvar}}=⟨\mathit{\text{value}}⟩$ while ${\mathbf{nfac}}=⟨\mathit{\text{value}}⟩$. These arguments must satisfy ${\mathbf{nvar}}\ge {\mathbf{nfac}}$.
On entry, ${\mathbf{tdfl}}=⟨\mathit{\text{value}}⟩$ while ${\mathbf{nfac}}=⟨\mathit{\text{value}}⟩$. These arguments must satisfy ${\mathbf{tdfl}}\ge {\mathbf{nfac}}$.
On entry, ${\mathbf{tdfs}}=⟨\mathit{\text{value}}⟩$ while ${\mathbf{nfac}}=⟨\mathit{\text{value}}⟩$. These arguments must satisfy ${\mathbf{tdfs}}\ge {\mathbf{nfac}}$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument method had an illegal value.
On entry, argument rotate had an illegal value.
NE_INT_ARG_LT
On entry, ${\mathbf{nfac}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nfac}}\ge 1$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_REAL_ARRAY_INPUT
On entry, ${\mathbf{e}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{e}}\left[⟨\mathit{\text{value}}⟩\right]>1.0$.
On entry, ${\mathbf{psi}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{psi}}\left[⟨\mathit{\text{value}}⟩\right]>0.0$.

## 7Accuracy

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

## 8Parallelism and Performance

g03ccc is not threaded in any implementation.

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 g03zac. The standardized variables are then post-multiplied by the factor score coefficients. This may be performed using functions from the F16 Chapter Introduction, for example f16yac.
If principal component analysis is required, the function g03aac computes the principal component scores directly. Hence, the factor score coefficients are not needed.

## 10Example

The 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 g03cac. The factor score coefficients are computed using the regression method.

### 10.1Program Text

Program Text (g03ccce.c)

### 10.2Program Data

Program Data (g03ccce.d)

### 10.3Program Results

Program Results (g03ccce.r)