g11sac fits a latent variable model (with a single factor) to data consisting of a set of measurements on individuals in the form of binary-valued sequences (generally referred to as score patterns). Various measures of goodness-of-fit are calculated along with the factor (theta) scores.
The function may be called by the names: g11sac, nag_contab_binary or nag_binary_factor.
3Description
Given a set of dichotomous variables , where denotes vector or matrix transpose, the objective is to investigate whether the association between them can be adequately explained by a latent variable model of the form (see Bartholomew (1980) and Bartholomew (1987))
(1)
The are called item responses and take the value or . denotes the latent variable assumed to have a standard Normal distribution over a population of individuals to be tested on items. Call the item response function: it represents the probability that an individual with latent ability will produce a positive response (1) to item . and are item parameters which can assume any real values. The set of parameters, , for , being coefficients of the unobserved variable , can be interpreted as ‘factor loadings’.
is a function selected by you as either or logit, mapping the interval onto the whole real line. Data from a random sample of individuals takes the form of the matrices and defined below:
where denotes the th score pattern in the sample, the frequency with which occurs and the number of different score patterns observed. (Thus ). It can be shown that the log-likelihood function is proportional to
where
(2)
( being the probability density function of a standard Normal random variable).
denotes the unconditional probability of observing score pattern . The integral in (2) is approximated using Gauss–Hermite quadrature. If we take in (1) and reparameterise as follows,
An E-M algorithm (see Bock and Aitkin (1981)) is used to maximize the log-likelihood function. The number of quadrature points used is set initially to and once convergence is attained increased to .
The theta score of an individual responding in score pattern is computed as the posterior mean, i.e., . For the logit model the component score is also calculated. (Note that in calculating the theta scores and measures of goodness-of-fit g11sac automatically reverses the coding on item if ; it is assumed in the model that a response at the one level is showing a higher measure of latent ability than a response at the zero level.)
The frequency distribution of score patterns is required as input data. If your data is in the form of individual score patterns (uncounted), then g11sbc may be used to calculate the frequency distribution.
4References
Bartholomew D J (1980) Factor analysis for categorical data (with Discussion) J. Roy. Statist. Soc. Ser. B42 293–321
Bartholomew D J (1987) Latent Variable Models and Factor Analysis Griffin
Bock R D and Aitkin M (1981) Marginal maximum likelihood estimation of item parameters: Application of an E-M algorithm Psychometrika46 443–459
5Arguments
1: – Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by . See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint:
or .
2: – IntegerInput
On entry: , the number of dichotomous variables.
Constraint:
.
3: – IntegerInput
On entry: , the number of individuals in the sample.
Constraint:
.
4: – Nag_BooleanInput
On entry: must be set equal to Nag_TRUE if and Nag_FALSE if .
5: – IntegerInput
On entry: ns must be set equal to the number of different score patterns in the sample, .
Constraint:
.
6: – Nag_BooleanInput/Output
Note: the dimension, dim, of the array
x
must be at least
when ;
when .
where appears in this document, it refers to the array element
when ;
when .
On entry: the first rows of x must contain the different score patterns. The th row of x must contain the th score pattern with set equal to Nag_TRUE if and Nag_FALSE if . All rows of x must be distinct.
On exit: given a valid parameter set then the first rows of x still contain the different score patterns. However, the following points should be noted:
(i)If the estimated factor loading for the th item is negative then that item is re-coded, i.e., s and s (or Nag_TRUE and Nag_FALSE) in the th column of x are interchanged.
(ii)The rows of x will be reordered so that the theta scores corresponding to rows of x are in increasing order of magnitude.
7: – IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
if ,
;
if , .
8: – IntegerInput/Output
On entry: the th component of irl must be set equal to the frequency with which the th row of x occurs.
Constraints:
, for ;
.
On exit: given a valid parameter set then the first components of irl are reordered as are the rows of x.
9: – doubleInput/Output
On entry: must be set equal to an initial estimate of . In order to avoid divergence problems with the E-M algorithm you are strongly advised to set all the to .
On exit: contains the latest estimate of , for . (Because of possible recoding all elements of a will be positive.)
10: – doubleInput/Output
On entry: must be set equal to an initial estimate of . In order to avoid divergence problems with the E-M algorithm you are strongly advised to set all the to .
On exit: contains the latest estimate of , for .
11: – IntegerInput
On entry: the frequency with which the maximum likelihood search function is to be monitored.
The search is monitored once every iprint iterations, and when the number of quadrature points is increased, and again at the final solution point.
The search is monitored once at the final point.
The search is not monitored at all.
iprint should normally be set to a small positive number.
Suggested value:
.
12: – const char *Input
On entry: the name of a file to which diagnostic output will be directed. If outfile is NULL the diagnostic output will be directed to standard output.
13: – doubleInput
On entry: the accuracy to which the solution is required.
If cgetol is set to and on exit NE_NOERROR or NE_ZERO_DF, then all elements of the gradient vector will be smaller than in absolute value. For most practical purposes the value should suffice. You should be wary of setting cgetol too small since the convergence criterion may then have become too strict for the machine to handle.
If cgetol has been set to a value which is less than the square root of the machine precision, , then g11sac will use the value instead.
14: – IntegerInput
On entry: the maximum number of iterations to be made in the maximum likelihood search. There will be an error exit (see Section 6) if the search function has not converged in maxit iterations.
Suggested value:
.
Constraint:
.
15: – Nag_BooleanInput
On entry: if chisqr is set equal to Nag_TRUE, a likelihood ratio statistic will be calculated (see chi).
If chisqr is set equal to Nag_FALSE, no such statistic will be calculated.
16: – Integer *Output
On exit: given a valid parameter set then niter contains the number of iterations performed by the maximum likelihood search function.
17: – doubleOutput
On exit: given a valid parameter set then contains the latest estimate of . (Because of possible recoding all elements of alpha will be positive.)
18: – doubleOutput
On exit: given a valid parameter set then contains the latest estimate of either if (logit model) or if (probit model).
19: – doubleOutput
Note: the dimension, dim, of the array
cm
must be at least
.
where appears in this document, it refers to the array element
when ;
when .
On exit: given a valid parameter set then the strict lower triangle of cm contains the correlation matrix of the parameter estimates held in alpha and pigam on exit. The diagonal elements of cm contain the standard errors. Thus:
=
standard error
=
standard error
=
correlation ,
for ;
=
correlation
=
correlation
=
correlation
=
correlation ,
for .
If the second derivative matrix cannot be computed then all the elements of cm are returned as zero.
20: – IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) of the matrix in the array
cm.
Constraint:
.
21: – doubleOutput
On exit: given a valid parameter set then g contains the estimated gradient vector corresponding to the final point held in the arrays alpha and pigam.
contains the derivative of the log-likelihood with respect to , for .
contains the derivative of the log-likelihood with respect to , for .
22: – doubleOutput
Note: the dimension, dim, of the array
expp
must be at least
.
where appears in this document, it refers to the array element
when ;
when .
On exit: given a valid parameter set then contains the expected percentage of individuals in the sample who respond positively to items and (), corresponding to the final point held in the arrays alpha and pigam.
23: – IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) of the matrix in the array
expp.
Constraint:
.
24: – doubleOutput
Note: the dimension, dim, of the array
obs
must be at least
.
where appears in this document, it refers to the array element
when ;
when .
On exit: given a valid parameter set then contains the observed percentage of individuals in the sample who responded positively to items and ().
25: – doubleOutput
On exit: given a valid parameter set then contains the expected frequency of the th score pattern (th row of x), corresponding to the final point held in the arrays alpha and pigam.
26: – doubleOutput
On exit: given a valid parameter set then contains the estimated theta score corresponding to the th row of x, for the final point held in the arrays alpha and pigam.
27: – IntegerOutput
On exit: given a valid parameter set then contains the number of items in the th row of x for which the response was positive (Nag_TRUE).
28: – double *Output
On exit: given a valid parameter set then rlogl contains the value of the log-likelihood kernel corresponding to the final point held in the arrays alpha and pigam, namely
29: – double *Output
On exit: if chisqr was set equal to Nag_TRUE on entry, then given a valid parameter set, chi will contain the value of the likelihood ratio statistic corresponding to the final parameter estimates held in the arrays alpha and pigam, namely
The summation is over those elements of irl which are positive. If is less than , then adjacent score patterns are pooled (the score patterns in x being first put in order of increasing theta score).
If chisqr has been set equal to Nag_FALSE, then chi is not used.
30: – Integer *Output
On exit: if chisqr was set equal to Nag_TRUE on entry, then given a valid parameter set, idf will contain the degrees of freedom associated with the likelihood ratio statistic, chi.
if ;
if ,
where denotes the number of terms summed to calculate chi ( only if there is no pooling).
If chisqr has been set equal to Nag_FALSE, idf is not used.
31: – double *Output
On exit: if chisqr was set equal to Nag_TRUE on entry, then given a valid parameter set, siglev will contain the significance level of chi based on idf degrees of freedom. If idf is zero or negative then siglev is set to zero.
If chisqr was set equal to Nag_FALSE, siglev is not used.
32: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument had an illegal value.
NE_INT
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, . Constraint: .
On entry, . Constraint: .
On entry, . Constraint: .
NE_INT_2
On entry, and .
Constraint: .
On entry, and .
Constraint: rows and of x should not be identical.
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint:
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
NE_INT_3
On entry, , and .
Constraint: .
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_MAT_INV
Failure to invert Hessian matrix and maxit iterations made: . This indicates a failure to invert the second derivative matrix for calculating the variance-covariance matrix of parameter estimates in the specified number of iterations. The elements of cm have been set to zero. Try restarting the calculations with a larger value for maxit.
Failure to invert Hessian matrix plus Heywood case encountered. This indicates a failure to invert the second derivative matrix for calculating the variance-covariance matrix of parameter estimates. In addition, an element of a has exceeded in absolute value. The elements of cm will have then been set to zero on exit. You are advised to restart the calculations from a different point to see whether the E-M algorithm moves off in the same direction.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_NOT_CLOSE_FILE
Cannot close file .
NE_NOT_WRITE_FILE
Cannot open file for writing.
NE_REAL_ARRAY_ELEM_CONS
One of the elements of a has exceeded in absolute. This is the Heywood case as described in Section 9.3. If steady increases in the log-likelihood kernel were monitored up to the point where this exit occurred then this exit may indicate that there is no maximum to the likelihood surface. You are advised to restart the calculations from a different point to see whether the E-M algorithm moves off in the same direction.
NE_RESPONSE_LEVEL
For at least one of the p items the responses are all at the same level.
NE_TOO_MANY_ITER
maxit iterations have been performed: . If steady increases in the log-likelihood kernel were monitored up to the point where this exit occurred, the exit probably occurred simply because maxit was set too small, so the calculations should be restarted from the final point held in a and c. This type of exit may also indicate that there is no maximum to the likelihood surface.
NE_ZERO_DF
statistic has less than one degree of freedom. The statistic is meaningless and siglev is set to zero. All other returned information should be correct.
7Accuracy
On exit from g11sac if NE_NOERROR or NE_ZERO_DF then the following condition will be satisfied:
If NE_MAT_INV or NE_TOO_MANY_ITER on exit (i.e., maxit iterations have been performed but the above condition does not hold), then the elements in a, c, alpha and pigam may still be good approximations to the maximum likelihood estimates. You are advised to inspect the elements of g to see whether this is confirmed.
8Parallelism and Performance
g11sac is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g11sac 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
9Further Comments
9.1Timing
The number of iterations required in the maximum likelihood search depends upon the number of observed variables, , and the distance of the starting point you supplied from the solution. The number of multiplications and divisions performed in an iteration is proportional to .
9.2Initial Estimates
You are strongly advised to use the recommended starting values for the elements of a and c. Divergence may result from values you supplied even if they are very close to the solution. Divergence may also occur when an item has nearly all its responses at one level.
9.3Heywood Cases
As in normal factor analysis, Heywood cases can often occur, particularly when is small and not very big. To overcome this difficulty the maximum likelihood search function is terminated when the absolute value of one of the exceeds .
You have the option of deciding whether to exit from g11sac (by setting on entry) or to permit g11sac to proceed onwards as if it had exited normally from the maximum likelihood search function (see or Nag_FALSE on entry).
The elements in a, c, alpha and pigam may still be good approximations to the maximum likelihood estimates. You are advised to inspect the elements g to see whether this is confirmed.
9.4Goodness of Fit Statistic
When is not very large compared to a goodness-of-fit statistic should not be calculated as many of the expected frequencies will then be less than .
9.5First and Second Order Margins
The observed and expected percentages of sample members responding to individual and pairs of items held in the arrays obs and expp on exit can be converted to observed and expected numbers by multiplying all elements of these two arrays by .
10Example
A program to fit the logit latent variable model to the following data: