NAG Library Routine Document
g03caf
(factor)
1
Purpose
g03caf computes the maximum likelihood estimates of the arguments of a factor analysis model. Either the data matrix or a correlation/covariance matrix may be input. Factor loadings, communalities and residual correlations are returned.
2
Specification
Fortran Interface
Subroutine g03caf ( |
matrix,
weight,
n,
m,
x,
ldx,
nvar,
isx,
nfac,
wt,
e,
stat,
com,
psi,
res,
fl,
ldfl,
iop,
iwk,
wk,
lwk,
ifail) |
Integer, Intent (In) | :: |
n,
m,
ldx,
nvar,
isx(m),
nfac,
ldfl,
iop(5),
lwk | Integer, Intent (Inout) | :: |
ifail | Integer, Intent (Out) | :: |
iwk(4*nvar+2) | Real (Kind=nag_wp), Intent (In) | :: |
x(ldx,m),
wt(*) | Real (Kind=nag_wp), Intent (Inout) | :: |
fl(ldfl,nfac) | Real (Kind=nag_wp), Intent (Out) | :: |
e(nvar),
stat(4),
com(nvar),
psi(nvar),
res(nvar*(nvar-1)/2),
wk(lwk) | Character (1), Intent (In) | :: |
matrix,
weight |
|
C Header Interface
#include nagmk26.h
void |
g03caf_ (
const char *matrix,
const char *weight,
const Integer *n,
const Integer *m,
const double x[],
const Integer *ldx,
const Integer *nvar,
const Integer isx[],
const Integer *nfac,
const double wt[],
double e[],
double stat[],
double com[],
double psi[],
double res[],
double fl[],
const Integer *ldfl,
const Integer iop[],
Integer iwk[],
double wk[],
const Integer *lwk,
Integer *ifail,
const Charlen length_matrix,
const Charlen length_weight) |
|
3
Description
Let
variables,
, with variance-covariance matrix
be observed. The aim of factor analysis is to account for the covariances in these
variables in terms of a smaller number,
, of hypothetical variables, or factors,
. These are assumed to be independent and to have unit variance. The relationship between the observed variables and the factors is given by the model:
where
, for
and
, are the factor loadings and
, for
, are independent random variables with variances
, for
. The
represent the unique component of the variation of each observed variable. The proportion of variation for each variable accounted for by the factors is known as the communality. For this routine it is assumed that both the
factors and the
's follow independent Normal distributions.
The model for the variance-covariance matrix,
, can be written as:
where
is the matrix of the factor loadings,
, and
is a diagonal matrix of unique variances,
, for
.
The estimation of the arguments of the model,
and
, by maximum likelihood is described by
Lawley and Maxwell (1971). The log-likelihood is:
where
is the number of observations,
is the sample variance-covariance matrix or, if weights are used,
is the weighted sample variance-covariance matrix and
is the effective number of observations, that is, the sum of the weights. The constant is independent of the arguments of the model. A two stage maximization is employed. It makes use of the function
, which is, up to a constant,
times the log-likelihood maximized over
. This is then minimized with respect to
to give the estimates,
, of
. The function
can be written as:
where values
, for
are the eigenvalues of the matrix:
The estimates
, of
, are then given by scaling the eigenvectors of
, which are denoted by
:
where
is the diagonal matrix with elements
, and
is the identity matrix.
The minimization of
is performed using
e04lbf which uses a modified Newton algorithm. The computation of the Hessian matrix is described by
Clark (1970). However, instead of using the eigenvalue decomposition of the matrix
as described above, the singular value decomposition of the matrix
is used, where
is obtained either from the
decomposition of the (scaled) mean centred data matrix or from the Cholesky decomposition of the correlation/covariance matrix. The routine
e04lbf ensures that the values of
are greater than a given small positive quantity,
, so that the communality is always less than one. This avoids the so called Heywood cases.
In addition to the values of
,
and the communalities,
g03caf returns the residual correlations, i.e., the off-diagonal elements of
where
is the sample correlation matrix.
g03caf also returns the test statistic:
which can be used to test the goodness-of-fit of the model
(1), see
Lawley and Maxwell (1971) and
Morrison (1967).
4
References
Clark M R B (1970) A rapidly convergent method for maximum likelihood factor analysis British J. Math. Statist. Psych.
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl. 20(3) 2–25
Lawley D N and Maxwell A E (1971) Factor Analysis as a Statistical Method (2nd Edition) Butterworths
Morrison D F (1967) Multivariate Statistical Methods McGraw–Hill
5
Arguments
- 1: – Character(1)Input
-
On entry: selects the type of matrix on which factor analysis is to be performed.
- The data matrix will be input in x and factor analysis will be computed for the correlation matrix.
- The data matrix will be input in x and factor analysis will be computed for the covariance matrix, i.e., the results are scaled as described in Section 9.
- The correlation/variance-covariance matrix will be input in x and factor analysis computed for this matrix.
Constraint:
, or .
- 2: – Character(1)Input
-
On entry: if
or
,
weight indicates if weights are to be used.
- No weights are used.
- Weights are used and must be supplied in wt.
Note: if
,
weight is not referenced.
Constraint:
if or , or .
- 3: – IntegerInput
-
On entry: if
or
the number of observations in the data array
x.
If
the (effective) number of observations used in computing the (possibly weighted) correlation/variance-covariance matrix input in
x.
Constraint:
.
- 4: – IntegerInput
-
On entry: the number of variables in the data/correlation/variance-covariance matrix.
Constraint:
.
- 5: – Real (Kind=nag_wp) arrayInput
-
On entry: the input matrix.
If
or
,
x must contain the data matrix, i.e.,
must contain the
th observation for the
th variable, for
and
.
If
,
x must contain the correlation or variance-covariance matrix. Only the upper triangular part is required.
- 6: – IntegerInput
-
On entry: the first dimension of the array
x as declared in the (sub)program from which
g03caf is called.
Constraints:
- if or , ;
- if , .
- 7: – IntegerInput
-
On entry: , the number of variables in the factor analysis.
Constraint:
.
- 8: – Integer arrayInput
-
On entry:
indicates whether or not the
th variable is included in the factor analysis. If
, the variable represented by the
th column of
x is included in the analysis; otherwise it is excluded, for
.
Constraint:
for
nvar values of
.
- 9: – IntegerInput
-
On entry: , the number of factors.
Constraint:
.
- 10: – Real (Kind=nag_wp) arrayInput
-
Note: the dimension of the array
wt
must be at least
if
and
or
, and at least
otherwise.
On entry: if
and
or
,
wt must contain the weights to be used in the factor analysis. The effective number of observations in the analysis will then be the sum of weights. If
, the
th observation is not included in the analysis.
If
or
,
wt is not referenced and the effective number of observations is
.
Constraint:
if , , , for .
- 11: – Real (Kind=nag_wp) arrayOutput
-
On exit: the eigenvalues
, for .
- 12: – Real (Kind=nag_wp) arrayOutput
-
On exit: the test statistics.
- Contains the value .
- Contains the test statistic, .
- Contains the degrees of freedom associated with the test statistic.
- Contains the significance level.
- 13: – Real (Kind=nag_wp) arrayOutput
-
On exit: the communalities.
- 14: – Real (Kind=nag_wp) arrayOutput
-
On exit: the estimates of
, for .
- 15: – Real (Kind=nag_wp) arrayOutput
-
On exit: the residual correlations. The residual correlation for the th and th variables is stored in , .
- 16: – Real (Kind=nag_wp) arrayOutput
-
On exit: the factor loadings.
contains , for and .
- 17: – IntegerInput
-
On entry: the first dimension of the array
fl as declared in the (sub)program from which
g03caf is called.
Constraint:
.
- 18: – Integer arrayInput
-
On entry: options for the optimization. There are four options to be set:
| controls iteration monitoring; |
| if , there is no printing of information else if , information is printed at every iprint iterations. The information printed consists of the value of at that iteration, the number of evaluations of , the current estimates of the communalities and an indication of whether or not they are at the boundary. |
| the maximum number of function evaluations. |
| the required accuracy for the estimates of . |
| a lower bound for the values of , see Section 3. |
Let
then if
, the following default values are used:
If
, then
- where
- where
Constraint:
if , must be such that , and , for .
- 19: – Integer arrayWorkspace
- 20: – Real (Kind=nag_wp) arrayWorkspace
- 21: – IntegerInput
-
On entry: the dimension of the array
wk as declared in the (sub)program from which
g03caf is called. The length of the workspace.
Constraints:
- if or , ;
- if , .
- 22: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, because for this routine the values of the output arguments may be useful even if
on exit, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Note: g03caf may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
-
On entry, | , |
or | , |
or | , |
or | , |
or | , |
or | , |
or | or and , |
or | and , |
or | , or , |
or | or and or , |
or | and is such that , |
or | and is such that , |
or | and is such that , |
or | and is such that , |
or | and is such that , |
or | and , |
or | or and . |
-
On entry, | and a value of . |
-
On entry, there are not exactly
nvar elements of
, or the effective number of observations
.
-
On entry, or and the data matrix is not of full column rank, or and the input correlation/variance-covariance matrix is not positive definite.
This exit may also be caused by two of the eigenvalues of
being equal; this is rare (see
Lawley and Maxwell (1971)), and may be due to the data/correlation matrix being almost singular.
-
A singular value decomposition has failed to converge. This is a very unlikely error exit.
-
The estimation procedure has failed to converge in the given number of iterations. Change
iop to either increase number of iterations
or increase the value of
.
-
The convergence is not certain but a lower point could not be found. See
e04lbf for further details. In this case all results are computed.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
The accuracy achieved is discussed in
e04lbf with the value of the argument
xtol given by
as described in parameter
iop.
8
Parallelism and Performance
g03caf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g03caf 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.
The factor loadings may be orthogonally rotated by using
g03baf and factor score coefficients can be computed using
g03ccf. The maximum likelihood estimators are invariant to a change in scale. This means that the results obtained will be the same (up to a scaling factor) if either the correlation matrix or the variance-covariance matrix is used. As the correlation matrix ensures that all values of
are between
and
it will lead to a more efficient optimization. In the situation when the data matrix is input the results are always computed for the correlation matrix and then scaled if the results for the covariance matrix are required. When you input the covariance/correlation matrix the input matrix itself is used and you are advised to input the correlation matrix rather than the covariance matrix.
10
Example
This example is taken from
Lawley and Maxwell (1971). The correlation matrix for nine variables is input and the arguments of a factor analysis model with three factors are estimated and printed.
10.1
Program Text
Program Text (g03cafe.f90)
10.2
Program Data
Program Data (g03cafe.d)
10.3
Program Results
Program Results (g03cafe.r)