nag_mv_factor (g03cac) (PDF version)
g03 Chapter Contents
g03 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_mv_factor (g03cac)

 Contents

    1  Purpose
    7  Accuracy

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 p  variables, x 1 , x 2 , , x p , with variance-covariance matrix Σ  be observed. The aim of factor analysis is to account for the covariances in these p  variables in terms of a smaller number, k , of hypothetical variables, or factors, f 1 , f 2 , , f k . 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:
x i = j=1 k λ ij f j + e i  
λ ij , for i=1,2,,p and j=1,2,,k, are the factor loadings and e i , for i=1,2,,p, are independent random variables with variances ψ i , for i=1,2,,p. The ψ i  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 k  factors and the e i 's follow independent Normal distributions.
The model for the variance-covariance matrix, Σ , can be written as:
Σ = Λ ΛT + Ψ (1)
where Λ  is the matrix of the factor loadings, λ ij , and Ψ  is a diagonal matrix of unique variances, ψ i , for i=1,2,,p.
The estimation of the arguments of the model, Λ  and Ψ , by maximum likelihood is described by Lawley and Maxwell (1971). The log-likelihood is:
- 1 2 n-1 log Σ - 1 2 n-1 trace S Σ -1 + constant,  
where n  is the number of observations, S  is the sample variance-covariance matrix or, if weights are used, S  is the weighted sample variance-covariance matrix and n  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 F Ψ , which is, up to a constant, -2 / n-1  times the log-likelihood maximized over Λ . This is then minimized with respect to Ψ  to give the estimates, Ψ ^ , of Ψ . The function F Ψ  can be written as:
F Ψ = j = k + 1 p θ j - logθ j - p-k ,  
where values θ j , for j=1,2,,p are the eigenvalues of the matrix:
S * = Ψ - 1 / 2 S Ψ - 1 / 2 .  
The estimates Λ ^ , of Λ , are then given by scaling the eigenvectors of S * , which are denoted by V :
Λ ^ = Ψ 1/2 V Θ-I 1/2 .  
where Θ  is the diagonal matrix with elements θ i , and I  is the identity matrix.
The minimization of F Ψ  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 S *  as described above, the singular value decomposition of the matrix R Ψ - 1 / 2  is used, where R  is obtained either from the QR  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 ψ i  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 C - Λ ΛT + Ψ  where C  is the sample correlation matrix. nag_mv_factor (g03cac) also returns the test statistic:
χ 2 = n - 1 - 2 p + 5 / 6 - 2 k / 3 F Ψ ^  
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:     matrix Nag_FacMatInput
On entry: selects the type of matrix on which factor analysis is to be performed.
matrix=Nag_DataCorr (Data input)
The data matrix will be input in x and factor analysis will be computed for the correlation matrix.
matrix=Nag_DataCovar
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.
matrix=Nag_MatCorr_Covar
The correlation/variance-covariance matrix will be input in x and factor analysis computed for this matrix.
Constraint: matrix=Nag_DataCorr, Nag_DataCovar or Nag_MatCorr_Covar.
2:     n IntegerInput
On entry: if matrix=Nag_DataCorr or Nag_DataCovar the number of observations in the data array x.
If matrix=Nag_MatCorr_Covar the (effective) number of observations used in computing the (possibly weighted) correlation/variance-covariance matrix input in x.
Constraint: n>nvar .
3:     m IntegerInput
On entry: the number of variables in the data/correlation/variance-covariance matrix.
Constraint: mnvar .
4:     x[dim1×tdx] const doubleInput
On entry: the input matrix.
matrix=Nag_DataCorr or Nag_DataCovar
x must contain the data matrix, i.e., x[i-1×tdx+j-1]  must contain the i th observation for the j th variable, for i=1,2,,n and j=1,2,,m.
matrix=Nag_MatCorr_Covar
x must contain the correlation or variance-covariance matrix. Only the upper triangular part is required.
5:     tdx IntegerInput
On entry: the stride separating matrix column elements in the array x.
Constraint: tdxm .
6:     nvar IntegerInput
On entry: the number of variables in the factor analysis, p .
Constraint: nvar2 .
7:     isx[m] const IntegerInput
On entry: isx[j-1]  indicates whether or not the j th variable is to be included in the factor analysis.
If isx[j-1] 1 , then the variable represented by the j th column of x is included in the analysis; otherwise it is excluded, for j=1,2,,m.
Constraint: isx[j-1] > 0  for nvar values of j .
8:     nfac IntegerInput
On entry: the number of factors, k .
Constraint: 1 nfac nvar .
9:     wt[n] const doubleInput
On entry: if matrix=Nag_DataCorr or Nag_DataCovar 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 wt[i-1] = 0.0  then the i th observation is not included in the analysis.
If matrix=Nag_MatCorr_Covar or wt is NULLthen wt is not referenced and the effective number of observations is n .
Constraint: if wt is referenced, then wt[i-1] 0  for i = 1 , 2 , , n , and the sum of the weights > nvar .
10:   e[nvar] doubleOutput
On exit: the eigenvalues θ i , for i=1,2,,p.
11:   stat[4] doubleOutput
On exit: the test statistics.
stat[0]  contains the value F Ψ ^ .
stat[1]  contains the test statistic, χ 2 .
stat[2]  contains the degrees of freedom associated with the test statistic.
stat[3]  contains the significance level.
12:   com[nvar] doubleOutput
On exit: the communalities.
13:   psi[nvar] doubleOutput
On exit: the estimates of ψ i , for i=1,2,,p.
14:   res[nvar×nvar-1/2] doubleOutput
On exit: the residual correlations. The residual correlation for the i th and j th variables is stored in res[ j-1 j-2 / 2 + i - 1 ] , i<j .
15:   fl[nvar×tdfl] doubleOutput
On exit: the factor loadings. fl[i-1×tdfl+j-1]  contains λ ij , for i=1,2,,p and j=1,2,,k.
16:   tdfl IntegerInput
On entry: the stride separating matrix column elements in the array fl.
Constraint: tdflnfac .
17:   options 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:   eps doubleInput
On entry: a lower bound for the value of Ψ i .
Constraint: machine precision eps < 1.0 .
19:   fail 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, nfac=value  while nvar=value . These arguments must satisfy nfacnvar .
NE_2_INT_ARG_LE
On entry, n=value  while nvar=value . These arguments must satisfy n>nvar .
NE_2_INT_ARG_LT
On entry, m=value  while nvar=value . These arguments must satisfy mnvar .
On entry, tdfl=value  while nfac=value . These arguments must satisfy tdflnfac .
On entry, tdx=value  while m=value . These arguments must satisfy tdxm .
NE_2_REAL_ARG_LT
On entry, step_max=value  while optim_tol=value . These arguments must satisfy step_maxoptim_tol .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument matrix had an illegal value.
On entry, argument print_level had an illegal value.
NE_INT_ARG_LT
On entry, nfac=value.
Constraint: nfac1.
On entry, nvar=value.
Constraint: nvar2.
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 value given to max_iter is not valid. Correct range is max_iter0 .
NE_INVALID_REAL_RANGE_EF
Value value given to eps is not valid. Correct range is machine precision optim_tol < 1.0 .
NE_INVALID_REAL_RANGE_FF
Value value given to linesearch_tol is not valid. Correct range is 0.0 linesearch_tol < 1.0 .
NE_MAT_RANK
On entry, matrix=Nag_DataCorr or matrix=Nag_DataCovar and the data matrix is not of full column rank, or matrix=Nag_MatCorr_Covar and the input correlation/variance-covariance matrix is not positive definite. This exit may also be caused by two of the eigenvalues of S *  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, wt[value] = value.
Constraint: when referenced, all elements of wt must be non-negative.
NE_NOT_APPEND_FILE
Cannot open file string  for appending.
NE_NOT_CLOSE_FILE
Cannot close file string .
NE_OBSERV_LT_VAR
With weighted data, the effective number of observations given by the sum of weights =value , while the number of variables included in the analysis, nvar=value .
Constraint: effective number of observations > nvar + 1 .
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 =value , while number of variables included in the analysis via array isx=value .
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, value, 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.

9  Further Comments

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 ψ i  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)


nag_mv_factor (g03cac) (PDF version)
g03 Chapter Contents
g03 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016