The routine may be called by the names g03gaf or nagf_mv_gaussian_mixture.
A Normal (Gaussian) mixture model is a weighted sum of group Normal densities given by,
is a -dimensional object of interest;
is the mixture weight for the th group and ;
is a -dimensional vector of means for the th group;
is the covariance structure for the th group;
is the -variate Normal density:
Optionally, the (co)variance structure may be pooled (common to all groups) or calculated for each group, and may be full or diagonal.
Hartigan J A (1975) Clustering Algorithms Wiley
1: – IntegerInput
On entry: , the number of objects. There must be more objects than parameters in the model.
if , ;
if , ;
if , ;
if , ;
if , .
2: – IntegerInput
On entry: the total number of variables in array x.
3: – Real (Kind=nag_wp) arrayInput
On entry: must contain the value of the th variable for the th object, for and .
4: – IntegerInput
On entry: the first dimension of the array x as declared in the (sub)program from which g03gaf is called.
5: – Integer arrayInput
On entry: if all available variables are included in the model and isx is not referenced; otherwise the th variable will be included in the analysis if
and excluded if , for .
if , for nvar values of and for the remaining values of , for .
6: – IntegerInput
On entry: , the number of variables included in the calculations.
7: – IntegerInput
On entry: , the number of groups in the mixture model.
8: – IntegerInput
On entry: if , the initial membership probabilities in prob are set internally; otherwise these probabilities must be supplied.
9: – Real (Kind=nag_wp) arrayInput/Output
On entry: if , is the probability that the th object belongs to the th group. (These probabilities are normalised internally.)
On exit: is the probability of membership of the th object to the th group for the fitted model.
10: – IntegerInput
On entry: the first dimension of the array prob as declared in the (sub)program from which g03gaf is called.
11: – IntegerInput/Output
On entry: the maximum number of iterations.
On exit: the number of completed iterations.
12: – IntegerInput
On entry: if , membership probabilities are rounded to or after the completion of the first riter iterations.
13: – Real (Kind=nag_wp) arrayOutput
On exit: , the mixing probability for the th group.
14: – Real (Kind=nag_wp) arrayOutput
On exit: gives the estimated mean of the th variable in the th group.
15: – IntegerInput
On entry: determines the (co)variance structure:
Groupwise covariance matrices.
Pooled covariance matrix.
, , , or .
16: – Real (Kind=nag_wp) arrayOutput
Note: the last dimension of the array s
must be at least
if , and at least otherwise.
On exit: if , gives the th element of the th group.
If , gives the th element of the pooled covariance.
If , gives the th variance in the th group.
If , gives the th pooled variance.
If , gives the overall variance.
17: – IntegerInput
On entry: the first dimension of the (co)variance structure s.
if , ;
18: – IntegerInput
On entry: the second dimension of the (co)variance structure s.
if or , ;
if , ;
if or , .
19: – Real (Kind=nag_wp) arrayOutput
On exit: gives the -variate Normal (Gaussian) density of the th object in the th group.
20: – Real (Kind=nag_wp)Input
On entry: iterations cease the first time an improvement in log-likelihood is less than tol. If a value of is used.
21: – Real (Kind=nag_wp)Output
On exit: the log-likelihood for the fitted mixture model.
22: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or 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).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, and . Constraint: , the number of parameters, i.e., too few objects have been supplied for the model.
A covariance matrix is not positive definite, try a different initial allocation.
An iteration cannot continue due to an empty group, try a different initial allocation.
An unexpected error has been triggered by this routine. Please
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g03gaf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g03gaf 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.
This example fits a Gaussian mixture model with pooled covariance structure to New Haven schools test data, see Table 5.1 (p. 118) in Hartigan (1975).