g02jhf fits a multi-level linear mixed effects regression model using restricted maximum likelihood (REML) or maximum likelihood (ML). Prior to calling g02jhf the initialization routine g02jff must be called.
The routine may be called by the names g02jhf or nagf_correg_lmm_fit.
3Description
g02jhf fits a model of the form:
where
is a vector of observations on the dependent variable,
is a known design matrix for the fixed independent variables,
is a vector of length of unknown fixed effects,
is a known design matrix for the random independent variables,
is a vector of length of unknown random effects,
and
is a vector of length of unknown random errors.
Both and are assumed to have a Gaussian distribution with expectation zero and variance/covariance matrix defined by
where , is the identity matrix and is a diagonal matrix. It is assumed that the random variables, , can be subdivided into groups with each group being identically distributed with expectation zero and variance . The diagonal elements of matrix , therefore, take one of the values , depending on which group the associated random variable belongs to.
The model, therefore, contains three sets of unknowns: the fixed effects , the random effects and a vector of variance components , where . Rather than working directly with , g02jhf uses an iterative process to estimate . Due to the iterative nature of the estimation a set of initial values, , for is required. g02jhf allows these initial values either to be supplied by you or calculated from the data using the minimum variance quadratic unbiased estimators (MIVQUE0) suggested by Rao (1972).
g02jhf fits the model by maximizing the restricted log-likelihood function:
or the log-likelihood function:
where
By default the restricted log-likelihood function is used, the log-likelihood function can be chosen through the optional parameter Solver as detailed in the documentation for g02jff.
Once the final estimates for have been obtained, the value of is given by
Case weights, , can be incorporated into the model by replacing and with and respectively, for a diagonal weight matrix .
The log-likelihood, , is calculated using the sweep algorithm detailed in Wolfinger et al. (1994).
4References
Goodnight J H (1979) A tutorial on the SWEEP operator The American Statistician33(3) 149–158
Harville D A (1977) Maximum likelihood approaches to variance component estimation and to related problems JASA72 320–340
Rao C R (1972) Estimation of variance and covariance components in a linear model J. Am. Stat. Assoc.67 112–115
Stroup W W (1989) Predictable functions and prediction space in the mixed model procedure Applications of Mixed Models in Agriculture and Related DisciplinesSouthern Cooperative Series Bulletin No. 343 39–48
Wolfinger R, Tobias R and Sall J (1994) Computing Gaussian likelihoods and their derivatives for general linear mixed models SIAM Sci. Statist. Comput.15 1294–1310
5Arguments
Note: prior to calling g02jhf the initialization routine g02jff must be called, therefore, this documentation should be read in conjunction with the document for g02jff. In particular some argument names and conventions described in that document are also relevant here, but their definition has not been repeated. Specifically, hlmm should be interpreted identically in both routines.
1: – Type (c_ptr)Input
On entry: a G22 handle to the internal data structure containing a description of the required model as returned in hlmm by g02jff.
2: – IntegerInput
On entry: , the number of variance components being estimated (excluding the overall variance, ).
This should be set to the value of nvpr returned by g02jff.
3: – Real (Kind=nag_wp) arrayInput/Output
On entry: holds the initial values of the variance components, , with
the initial value for , for .
If , the remaining elements of gamma are ignored and the initial values for the variance components are estimated from the data using MIVQUE0.
On exit: , for , holds the final estimate of and holds the final estimate for .
Labels for the variance components can be obtained using g22ydf.
Constraint:
or , for .
4: – IntegerOutput
On exit: effective number of observations. If there are no weights (i.e., ), or all weights are nonzero, .
5: – IntegerOutput
On exit: the rank of the design matrix, , for the fixed effects.
6: – IntegerOutput
On exit: number of variance components not estimated to be zero. If none of the variance components are estimated to be zero, .
7: – Real (Kind=nag_wp)Output
On exit: where is the log of the restricted maximum likelihood calculated at , the estimated variance components returned in gamma.
8: – IntegerInput
On entry: the dimension of the arrays b and se as declared in the (sub)program from which g02jhf is called.
Constraint:
.
9: – Real (Kind=nag_wp) arrayOutput
On exit: the parameter estimates, with the first elements of containing the parameter estimates for the random effects, , and the remaining elements containing the parameter estimates for the fixed effects, .
Labels for the parameter estimates can be obtained using g22ydf.
10: – Real (Kind=nag_wp) arrayOutput
On exit: the standard errors of the parameter estimates given in b.
11: – Real (Kind=nag_wp) arrayOutput
On exit: if , czz holds the lower triangular portion of the matrix , where and are the estimates of and respectively.
If , then czz holds this matrix in compressed form, with the first nrf columns holding the part of the matrix corresponding to the first level of the overall random subject variable, the next nrf columns holding the part of the matrix corresponding to the second level of the overall random subject variable etc.
On entry: the first dimension of the array czz as declared in the (sub)program from which g02jhf is called.
Constraints:
or ;
if , .
13: – Real (Kind=nag_wp) arrayOutput
On exit: if , cxx holds the lower triangular portion of the matrix , where is the estimated value of .
If , then cxx holds this matrix in compressed form, with the first nff columns holding the part of the matrix corresponding to the first level of the overall fixed subject variable, the next nff columns holding the part of the matrix corresponding to the second level of the overall fixed subject variable, etc.
On entry: the first dimension of the array cxz as declared in the (sub)program from which g02jhf is called.
Constraint:
or .
17: – Real (Kind=nag_wp) arrayCommunication Array
On entry: communication array initialized by a call to g02jff.
18: – Integer arrayCommunication Array
On entry: communication array initialized by a call to g02jff.
19: – 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).
On entry, the communication arrays, icomm and rcomm, have not been initialized correctly.
Optimal solution found, but requested accuracy not achieved.
Too many major iterations.
Current point cannot be improved upon.
At least one negative estimate for gamma was obtained. All negative estimates have been set to zero.
An unexpected error has been triggered by this routine. Please
contact NAG.
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.
7Accuracy
Not applicable.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g02jhf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02jhf 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.
9Further Comments
If g02jgf has been called, then rather than use the values of fnlsv, nff, rnlsv, nrf and nvpr as returned by g02jff they should be obtained by calling g02zlf. See Section 9 in g02jgf for more details.
10Example
This example fits a random effects model with three random submodels and two fixed effects to a simulated dataset with observations and variables. The model is fit using restricted maximum likelihood (REML). Custom labels for the parameter estimates and variance components are then constructed from information returned by g22ydf. See g02jff for an example that uses the standard parameter labels directly.