NAG Library Function Document
nag_mv_factor (g03cac)
1 Purpose
nag_mv_factor (g03cac) 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
#include <nag.h> |
#include <nagg03.h> |
void |
nag_mv_factor (Nag_FacMat matrix,
Integer n,
Integer m,
const double x[],
Integer tdx,
Integer nvar,
const Integer isx[],
Integer nfac,
const double wt[],
double e[],
double stat[],
double com[],
double psi[],
double res[],
double fl[],
Integer tdfl,
Nag_E04_Opt *options,
double eps,
NagError *fail) |
|
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:
, 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 function 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
nag_opt_bounds_2nd_deriv (e04lbc) 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 function
nag_opt_bounds_2nd_deriv (e04lbc) 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, nag_mv_factor (g03cac) returns the residual correlations, i.e., the off-diagonal elements of
where
is the sample correlation matrix. nag_mv_factor (g03cac) 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:
– Nag_FacMatInput
-
On entry: selects the type of matrix on which factor analysis is to be performed.
- (Data input)
- 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:
– 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:
.
- 3:
– IntegerInput
-
On entry: the number of variables in the data/correlation/variance-covariance matrix.
Constraint:
.
- 4:
– const doubleInput
-
On entry: the input matrix.
- or
- x must contain the data matrix, i.e., must contain the th observation for the th variable, for and .
- x must contain the correlation or variance-covariance matrix. Only the upper triangular part is required.
- 5:
– IntegerInput
-
On entry: the stride separating matrix column elements in the array
x.
Constraint:
.
- 6:
– IntegerInput
-
On entry: the number of variables in the factor analysis, .
Constraint:
.
- 7:
– const IntegerInput
-
On entry:
indicates whether or not the
th variable is to be included in the factor analysis.
If
, then the variable represented by the
th column of
x is included in the analysis; otherwise it is excluded, for
.
Constraint:
for
nvar values of
.
- 8:
– IntegerInput
-
On entry: the number of factors, .
Constraint:
.
- 9:
– const doubleInput
-
On entry: if
or
then the elements of
wt must contain the weights to be used in the factor analysis. The effective number of observations is the sum of the weights. If
then the
th observation is not included in the analysis.
If
or
wt is
NULLthen
wt is not referenced and the effective number of observations is
.
Constraint:
if
wt is referenced, then
for
, and the sum of the weights
.
- 10:
– doubleOutput
-
On exit: the eigenvalues , for .
- 11:
– doubleOutput
-
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.
- 12:
– doubleOutput
-
On exit: the communalities.
- 13:
– doubleOutput
-
On exit: the estimates of , for .
- 14:
– doubleOutput
-
On exit: the residual correlations. The residual correlation for the th and th variables is stored in , .
- 15:
– doubleOutput
-
On exit: the factor loadings. contains , for and .
- 16:
– IntegerInput
-
On entry: the stride separating matrix column elements in the array
fl.
Constraint:
.
- 17:
– Nag_E04_Opt *Input/Output
-
On entry/exit: a pointer to a structure of type Nag_E04_Opt whose members are optional parameters for
nag_opt_bounds_2nd_deriv (e04lbc). These structure members offer the means of adjusting some of the argument values of the algorithm.
If the optional parameters are not required the NAG defined null pointer,
E04_DEFAULT, can be used in the function call. See the document for
nag_opt_bounds_2nd_deriv (e04lbc) for further details.
- 18:
– doubleInput
-
On entry: a lower bound for the value of .
Constraint:
.
- 19:
– NagError *Input/Output
-
The NAG error argument (see
Section 2.7 in How to Use the NAG Library and its Documentation).
6 Error Indicators and Warnings
- NE_2_INT_ARG_GT
-
On entry, while . These arguments must satisfy .
- NE_2_INT_ARG_LE
-
On entry, while . These arguments must satisfy .
- NE_2_INT_ARG_LT
-
On entry, while . These arguments must satisfy .
On entry, while . These arguments must satisfy .
On entry, while . These arguments must satisfy .
- NE_2_REAL_ARG_LT
-
On entry, while . These arguments must satisfy .
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
- NE_BAD_PARAM
-
On entry, argument
matrix had an illegal value.
On entry, argument had an illegal value.
- NE_INT_ARG_LT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INTERNAL_ERROR
-
Additional error messages are output if the optimization fails to converge or if the options are set incorrectly. Details of these can be found in the
nag_opt_bounds_2nd_deriv (e04lbc) document.
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_INVALID_INT_RANGE_1
-
Value given to is not valid. Correct range is .
- NE_INVALID_REAL_RANGE_EF
-
Value
given to
eps is not valid. Correct range is
machine precision .
- NE_INVALID_REAL_RANGE_FF
-
Value given to is not valid. Correct range is .
- NE_MAT_RANK
-
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.
- NE_NEG_WEIGHT_ELEMENT
-
On entry,
.
Constraint: when referenced, all elements of
wt must be non-negative.
- NE_NOT_APPEND_FILE
-
Cannot open file for appending.
- NE_NOT_CLOSE_FILE
-
Cannot close file .
- NE_OBSERV_LT_VAR
-
With weighted data, the effective number of observations given by the sum of
weights , while the number of variables included in the analysis, .
Constraint: effective number of observations .
- NE_OPT_NOT_INIT
-
Options structure not initialized.
- NE_SVD_NOT_CONV
-
A singular value decomposition has failed to converge. This is a very unlikely error exit.
- NE_VAR_INCL_INDICATED
-
The number of variables,
nvar in the analysis
, while number of variables included in the analysis via array
.
Constraint: these two numbers must be the same.
- NW_COND_MIN
-
The conditions for a minimum have not all been satisfied but a lower
point could not be found. Note that in this case all the results are computed. See
nag_opt_bounds_2nd_deriv (e04lbc) for further details.
- NW_TOO_MANY_ITER
-
The maximum number of iterations, , have been performed.
7 Accuracy
The accuracy achieved is discussed in
nag_opt_bounds_2nd_deriv (e04lbc).
8 Parallelism and Performance
nag_mv_factor (g03cac) is not threaded in any implementation.
The factor loadings may be orthogonally rotated by using
nag_mv_orthomax (g03bac) and factor score coefficients can be computed using
nag_mv_fac_score (g03ccc). 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 0 and 1 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 so you are advised to input the correlation matrix rather than the covariance matrix.
10 Example
The 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 (g03cace.c)
10.2 Program Data
Program Data (g03cace.d)
10.3 Program Results
Program Results (g03cace.r)