# NAG CL Interfaceg02jdc (mixeff_​hier_​reml)

Note: this function is deprecated. Replaced by g02jhc.

## 1Purpose

g02jdc fits a multi-level linear mixed effects regression model using restricted maximum likelihood (REML). Prior to calling g02jdc the initialization function g02jcc must be called.

## 2Specification

 #include
 void g02jdc (Integer lvpr, const Integer vpr[], Integer nvpr, double gamma[], Integer *effn, Integer *rnkx, Integer *ncov, double *lnlike, Integer lb, Integer id[], Integer pdid, double b[], double se[], double czz[], Integer pdczz, double cxx[], Integer pdcxx, double cxz[], Integer pdcxz, double rcomm[], Integer icomm[], const Integer iopt[], Integer liopt, const double ropt[], Integer lropt, NagError *fail)
The function may be called by the names: g02jdc, nag_correg_mixeff_hier_reml or nag_reml_hier_mixed_regsn.

## 3Description

g02jdc fits a model of the form:
 $y=Xβ+Zν+ε$
 where $y$ is a vector of $n$ observations on the dependent variable, $X$ is a known $n$ by $p$ design matrix for the fixed independent variables, $\beta$ is a vector of length $p$ of unknown fixed effects, $Z$ is a known $n$ by $q$ design matrix for the random independent variables, $\nu$ is a vector of length $q$ of unknown random effects, and $\epsilon$ is a vector of length $n$ of unknown random errors.
Both $\nu$ and $\epsilon$ are assumed to have a Gaussian distribution with expectation zero and variance/covariance matrix defined by
 $Var ν ε = G 0 0 R$
where $R={\sigma }_{R}^{2}I$, $I$ is the $n×n$ identity matrix and $G$ is a diagonal matrix. It is assumed that the random variables, $Z$, can be subdivided into $g\le q$ groups with each group being identically distributed with expectation zero and variance ${\sigma }_{i}^{2}$. The diagonal elements of matrix $G$ therefore take one of the values $\left\{{\sigma }_{i}^{2}:i=1,2,\dots ,g\right\}$, depending on which group the associated random variable belongs to.
The model therefore contains three sets of unknowns: the fixed effects $\beta$, the random effects $\nu$ and a vector of $g+1$ variance components $\gamma$, where $\gamma =\left\{{\sigma }_{1}^{2},{\sigma }_{2}^{2},\dots ,{\sigma }_{g-1}^{2},{\sigma }_{g}^{2},{\sigma }_{R}^{2}\right\}$. Rather than working directly with $\gamma$, g02jdc uses an iterative process to estimate ${\gamma }^{*}=\left\{{\sigma }_{1}^{2}/{\sigma }_{R}^{2},{\sigma }_{2}^{2}/{\sigma }_{R}^{2},\dots ,{\sigma }_{g-1}^{2}/{\sigma }_{R}^{2},{\sigma }_{g}^{2}/{\sigma }_{R}^{2},1\right\}$. Due to the iterative nature of the estimation a set of initial values, ${\gamma }_{0}$, for ${\gamma }^{*}$ is required. g02jdc 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).
g02jdc fits the model by maximizing the restricted log-likelihood function:
 $-2 l R = log V + n-p log r T V-1 r + log X T V-1 X + n-p 1+ log 2 π / n-p$
where
 $V = ZG ZT + R, r=y-Xb and b = XT V-1 X -1 XT V-1 y .$
Once the final estimates for ${\gamma }^{*}$ have been obtained, the value of ${\sigma }_{R}^{2}$ is given by
 $σR2 = rT V-1 r / n - p .$
Case weights, ${W}_{c}$, can be incorporated into the model by replacing ${X}^{\mathrm{T}}X$ and ${Z}^{\mathrm{T}}Z$ with ${X}^{\mathrm{T}}{W}_{c}X$ and ${Z}^{\mathrm{T}}{W}_{c}Z$ respectively, for a diagonal weight matrix ${W}_{c}$.
The log-likelihood, ${l}_{R}$, 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 Statistician 33(3) 149–158
Harville D A (1977) Maximum likelihood approaches to variance component estimation and to related problems JASA 72 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 Disciplines Southern 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 g02jdc the initialization function g02jcc must be called, therefore this documention should be read in conjunction with the document for g02jcc. In particular some argument names and conventions described in that document are also relevant here, but their definition has not been repeated. Specifically, RNDM, wt, n, nff, nrf, nlsv, levels, fixed, DAT, licomm and lrcomm should be interpreted identically in both functions.
1: $\mathbf{lvpr}$Integer Input
On entry: the sum of the number of random parameters and the random intercept flags specified in the call to g02jcc.
Constraint: ${\mathbf{lvpr}}={\sum }_{i}{\mathbf{rndm}}\left(1,i\right)+{\mathbf{rndm}}\left(2,i\right)$.
2: $\mathbf{vpr}\left[{\mathbf{lvpr}}\right]$const Integer Input
On entry: a vector of flags indicating the mapping between the random variables specified in rndm and the variance components, ${\sigma }_{i}^{2}$. See Section 9 for more details.
Constraint: $1\le {\mathbf{vpr}}\left[\mathit{i}-1\right]\le {\mathbf{nvpr}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{lvpr}}$.
3: $\mathbf{nvpr}$Integer Input
On entry: $g$, the number of variance components being estimated (excluding the overall variance, ${\sigma }_{R}^{2}$).
Constraint: $1\le {\mathbf{nvpr}}\le {\mathbf{lvpr}}$.
4: $\mathbf{gamma}\left[{\mathbf{nvpr}}+1\right]$double Input/Output
On entry: holds the initial values of the variance components, ${\gamma }_{0}$, with ${\mathbf{gamma}}\left[\mathit{i}-1\right]$ the initial value for ${\sigma }_{\mathit{i}}^{2}/{\sigma }_{R}^{2}$, for $\mathit{i}=1,2,\dots ,{\mathbf{nvpr}}$.
If ${\mathbf{gamma}}\left[0\right]=-1.0$, the remaining elements of gamma are ignored and the initial values for the variance components are estimated from the data using MIVQUE0.
On exit: ${\mathbf{gamma}}\left[\mathit{i}-1\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{nvpr}}$, holds the final estimate of ${\sigma }_{\mathit{i}}^{2}$ and ${\mathbf{gamma}}\left[{\mathbf{nvpr}}\right]$ holds the final estimate for ${\sigma }_{R}^{2}$.
Constraint: ${\mathbf{gamma}}\left[0\right]=-1.0$ or ${\mathbf{gamma}}\left[\mathit{i}-1\right]\ge 0.0$, for $\mathit{i}=1,2,\dots ,g$.
5: $\mathbf{effn}$Integer * Output
On exit: effective number of observations. If no weights were supplied to g02jcc or all supplied weights were nonzero, ${\mathbf{effn}}={\mathbf{n}}$.
6: $\mathbf{rnkx}$Integer * Output
On exit: the rank of the design matrix, $X$, for the fixed effects.
7: $\mathbf{ncov}$Integer * Output
On exit: number of variance components not estimated to be zero. If none of the variance components are estimated to be zero, then ${\mathbf{ncov}}={\mathbf{nvpr}}$.
8: $\mathbf{lnlike}$double * Output
On exit: $-2{l}_{R}\left(\stackrel{^}{\gamma }\right)$ where ${l}_{R}$ is the log of the restricted maximum likelihood calculated at $\stackrel{^}{\gamma }$, the estimated variance components returned in gamma.
9: $\mathbf{lb}$Integer Input
On entry: the dimension of the arrays b and se.
Constraint: ${\mathbf{lb}}\ge {\mathbf{nff}}+{\mathbf{nrf}}×{\mathbf{nlsv}}$.
10: $\mathbf{id}\left[{\mathbf{pdid}}×{\mathbf{lb}}\right]$Integer Output
Note: where ${\mathbf{ID}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{id}}\left[\left(j-1\right)×{\mathbf{pdid}}+i-1\right]$.
On exit: an array describing the parameter estimates returned in b. The first ${\mathbf{nlsv}}×{\mathbf{nrf}}$ columns of ID describe the parameter estimates for the random effects and the last nff columns the parameter estimates for the fixed effects.
The example program for this function includes a demonstration of decoding the parameter estimates given in b using information from id.
For fixed effects:
• for $l={\mathbf{nrf}}×{\mathbf{nlsv}}+1,\dots ,{\mathbf{nrf}}×{\mathbf{nlsv}}+{\mathbf{nff}}$
• if ${\mathbf{b}}\left[l-1\right]$ contains the parameter estimate for the intercept, then
 $ID1,l = ID2,l = ID3,l = 0 ;$
• if ${\mathbf{b}}\left[l-1\right]$ contains the parameter estimate for the $i$th level of the $j$th fixed variable, that is the vector of values held in the $k$th column of DAT when ${\mathbf{fixed}}\left[j+1\right]=k$ then
 $ID1,l=0, ID2,l=j, ID3,l=i;$
• if the $j$th variable is continuous or binary, that is ${\mathbf{levels}}\left[{\mathbf{fixed}}\left[j+1\right]-1\right]=1$, ${\mathbf{ID}}\left(3,l\right)=0$;
• any remaining rows of the $l$th column of ID are set to $0$.
For random effects:
• let
• ${N}_{{R}_{b}}$ denote the number of random variables in the $b$th random statement, that is ${N}_{{R}_{b}}={\mathbf{rndm}}\left(1,b\right)$;
• ${R}_{jb}$ denote the $j$th random variable from the $b$th random statement, that is the vector of values held in the $k$th column of DAT when ${\mathbf{rndm}}\left(2+j,b\right)=k$;
• ${N}_{{S}_{b}}$ denote the number of subject variables in the $b$th random statement, that is ${N}_{{S}_{b}}={\mathbf{rndm}}\left(3+{N}_{{R}_{b}},b\right)$;
• ${S}_{jb}$ denote the $j$th subject variable from the $b$th random statement, that is the vector of values held in the $k$th column of DAT when ${\mathbf{rndm}}\left(3+{N}_{{R}_{b}}+j,b\right)=k$;
• $L\left({S}_{jb}\right)$ denote the number of levels for ${S}_{jb}$, that is $L\left({S}_{jb}\right)={\mathbf{levels}}\left[{\mathbf{rndm}}\left(3+{N}_{{R}_{b}}+j,b\right)-1\right]$;
• then
• for $l=1,2,\dots {\mathbf{nrf}}×{\mathbf{nlsv}}$, if ${\mathbf{b}}\left[l-1\right]$ contains the parameter estimate for the $i$th level of ${R}_{jb}$ when ${S}_{\mathit{k}b}={s}_{\mathit{k}}$, for $\mathit{k}=1,2,\dots ,{N}_{{S}_{b}}$ and $1\le {s}_{\mathit{k}}\le L\left({S}_{jb}\right)$, i.e., ${s}_{k}$ is a valid value for the $k$th subject variable, then
 $ID1,l=b, ID2,l=j, ID3,l=i, ID3+k,l=sk, ​k=1,2,…,NSb;$
• if the parameter being estimated is for the intercept, then ${\mathbf{ID}}\left(2,l\right)={\mathbf{ID}}\left(3,l\right)=0$;
• if the $j$th variable is continuous, or binary, that is $L\left({S}_{jb}\right)=1$, then ${\mathbf{ID}}\left(3,l\right)=0$;
• the remaining rows of the $l$th column of ID are set to $0$.
In some situations, certain combinations of variables are never observed. In such circumstances all elements of the $l$th row of ID are set to $-999$.
11: $\mathbf{pdid}$Integer Input
On entry: the first dimension of the array ID.
Constraint: ${\mathbf{pdid}}\ge 3+\underset{j}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left({\mathbf{rndm}}\left(3+{\mathbf{rndm}}\left(1,j\right),j\right)\right)$, i.e.,$3+\text{}$ maximum number of subject variables (see g02jcc).
12: $\mathbf{b}\left[{\mathbf{lb}}\right]$double Output
On exit: the parameter estimates, with the first ${\mathbf{nrf}}×{\mathbf{nlsv}}$ elements of ${\mathbf{b}}$ containing the parameter estimates for the random effects, $\nu$, and the remaining nff elements containing the parameter estimates for the fixed effects, $\beta$. The order of these estimates are described by the id argument.
13: $\mathbf{se}\left[{\mathbf{lb}}\right]$double Output
On exit: the standard errors of the parameter estimates given in b.
14: $\mathbf{czz}\left[{\mathbf{pdczz}}×{\mathbf{nlsv}}×{\mathbf{nrf}}\right]$double Output
Note: where ${\mathbf{CZZ}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{czz}}\left[\left(j-1\right)×{\mathbf{pdczz}}+i-1\right]$.
On exit: if ${\mathbf{nlsv}}=1$, then CZZ holds the lower triangular portion of the matrix $\left(1/{\sigma }^{2}\right)\left({Z}^{\mathrm{T}}{\stackrel{^}{R}}^{-1}Z+{\stackrel{^}{G}}^{-1}\right)$, where $\stackrel{^}{R}$ and $\stackrel{^}{G}$ are the estimates of $R$ and $G$ respectively. If ${\mathbf{nlsv}}>1$, 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 subject variable, the next nrf columns the part corresponding to the second level of the overall subject variable etc.
15: $\mathbf{pdczz}$Integer Input
On entry: the stride separating matrix row elements in the array czz.
Constraint: ${\mathbf{pdczz}}\ge {\mathbf{nrf}}$.  (see g02jcc)
16: $\mathbf{cxx}\left[{\mathbf{pdcxx}}×{\mathbf{nff}}\right]$double Output
Note: where ${\mathbf{CXX}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{cxx}}\left[\left(j-1\right)×{\mathbf{pdcxx}}+i-1\right]$.
On exit: CXX holds the lower triangular portion of the matrix $\left(1/{\sigma }^{2}\right){X}^{\mathrm{T}}{\stackrel{^}{V}}^{-1}X$, where $\stackrel{^}{V}$ is the estimated value of $V$.
17: $\mathbf{pdcxx}$Integer Input
On entry: the stride separating matrix row elements in the array cxx.
Constraint: ${\mathbf{pdcxx}}\ge {\mathbf{nff}}$.  (see g02jcc)
18: $\mathbf{cxz}\left[{\mathbf{pdcxz}}×{\mathbf{nlsv}}×{\mathbf{nrf}}\right]$double Output
Note: where ${\mathbf{CXZ}}\left(i,j\right)$ appears in this document, it refers to the array element ${\mathbf{cxz}}\left[\left(j-1\right)×{\mathbf{pdcxz}}+i-1\right]$.
On exit: if ${\mathbf{nlsv}}=1$, then CXZ holds the matrix $\left(1/{\sigma }^{2}\right)\left({X}^{\mathrm{T}}{\stackrel{^}{V}}^{-1}Z\right)\stackrel{^}{G}$, where $\stackrel{^}{V}$ and $\stackrel{^}{G}$ are the estimates of $V$ and $G$ respectively. If ${\mathbf{nlsv}}>1$, then CXZ 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 subject variable, the next nrf columns the part corresponding to the second level of the overall subject variable etc.
19: $\mathbf{pdcxz}$Integer Input
On entry: the stride separating matrix row elements in the array cxz.
Constraint: ${\mathbf{pdcxz}}\ge {\mathbf{nff}}$.  (see g02jcc)
20: $\mathbf{rcomm}\left[\mathit{dim}\right]$double Communication Array
On entry: communication array initialized by a call to g02jcc.
21: $\mathbf{icomm}\left[\mathit{dim}\right]$Integer Communication Array
On entry: communication array initialized by a call to g02jcc.
22: $\mathbf{iopt}\left[{\mathbf{liopt}}\right]$const Integer Input
On entry: optional parameters passed to the optimization function.
By default g02jdc fits the specified model using a modified Newton optimization algorithm as implemented in the NAG Fortran Library routine e04lbf. In some cases, where the calculation of the derivatives is computationally expensive it may be more efficient to use a sequential QP algorithm. The sequential QP algorithm as implemented in the NAG Fortran Library routine e04ucf can be chosen by setting ${\mathbf{iopt}}\left[4\right]=1$. If ${\mathbf{liopt}}<5$ or ${\mathbf{iopt}}\left[4\right]\ne 1$, then the modified Newton algorithm will be used.
Different optional parameters are available depending on the optimization function used. In all cases, using a value of $-1$ will cause the default value to be used. In addition only the first liopt values of iopt are used, so for example, if only the first element of iopt needs changing and default values for all other optional parameters are sufficient liopt can be set to $1$.
The following table lists the association between elements of iopt and arguments in the optimizer when the modified Newton algorithm is being used.
 $i$ Description Equivalent argument Default Value $0$ Number of iterations maxcal $1000$ $1$ Unit number for monitoring information. See x04acc for details on how to assign a file to a unit number. n/a Output sent to stdout $2$ Print optional parameters ($1=$ print) n/a $-1$ (no printing performed) $3$ Frequency that monitoring information is printed iprint $-1$ $4$ Optimizer used n/a n/a
If requested, monitoring information is displayed in a similar format to that given by the modified Newton optimizer.
The following table lists the association between elements of iopt and optional parameters in the optimizer when the sequential QP algorithm is being used.
 $i$ Description Equivalent optional parameter Default Value $0$ Number of iterations ${\mathbf{Major Iteration Limit}}$ $\mathrm{max}\left(50,3×{\mathbf{nvpr}}\right)$ $1$ Unit number for monitoring information. See x04acc for details on how to assign a file to a unit number. n/a Output sent to stdout $2$ Print optional parameters ($1=\text{}$ print, otherwise no print) ${\mathbf{List}}$/${\mathbf{Nolist}}$ $-1$ (no printing performed) $3$ Frequency that monitoring information is printed ${\mathbf{Major Print Level}}$ $0$ $4$ Optimizer used n/a n/a $5$ Number of minor iterations ${\mathbf{Minor Iteration Limit}}$ $\mathrm{max}\left(50,3×{\mathbf{nvpr}}\right)$ $6$ Frequency that additional monitoring information is printed ${\mathbf{Minor Print Level}}$ $0$
If ${\mathbf{liopt}}\le 0$, default values are used for all optional parameters and iopt may be set to NULL.
23: $\mathbf{liopt}$Integer Input
On entry: length of the options array iopt.
24: $\mathbf{ropt}\left[{\mathbf{lropt}}\right]$const double Input
On entry: optional parameters passed to the optimization function.
Different optional parameters are available depending on the optimization function used. In all cases, using a value of $-1.0$ will cause the default value to be used. In addition only the first lropt values of ropt are used, so for example, if only the first element of ropt needs changing and default values for all other optional parameters are sufficient lropt can be set to $1$.
The following table lists the association between elements of ropt and arguments in the optimizer when the modified Newton algorithm is being used.
 $i$ Description Equivalent argument Default Value $0$ Sweep tolerance n/a $\mathrm{max}\left(\sqrt{\mathrm{eps}},\sqrt{\mathrm{eps}}×\underset{i}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left({\mathrm{zz}}_{ii}\right)\right)$ $1$ Lower bound for ${\gamma }^{*}$ n/a $\mathrm{eps}/100$ $2$ Upper bound for ${\gamma }^{*}$ n/a ${10}^{20}$ $3$ Accuracy of linear minimizations eta $0.9$ $4$ Accuracy to which solution is required xtol $0.0$ $5$ Initial distance from solution stepmx $100000.0$
The following table lists the association between elements of ropt and optional parameters in the optimizer when the sequential QP algorithm is being used.
 $i$ Description Equivalent optional parameter Default Value $0$ Sweep tolerance n/a $\mathrm{max}\left(\sqrt{\mathrm{eps}},\sqrt{\mathrm{eps}}×\underset{i}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left({\mathrm{zz}}_{ii}\right)\right)$ $1$ Lower bound for ${\gamma }^{*}$ n/a $\mathrm{eps}/100$ $2$ Upper bound for ${\gamma }^{*}$ n/a ${10}^{20}$ $3$ Line search tolerance ${\mathbf{Line Search Tolerance}}$ $0.9$ $4$ Optimality tolerance ${\mathbf{Optimality Tolerance}}$ ${\mathrm{eps}}^{0.72}$
where $\mathrm{eps}$ is the machine precision returned by X02AJC and ${\mathrm{zz}}_{ii}$ denotes the $i$ diagonal element of ${Z}^{\mathrm{T}}Z$.
If ${\mathbf{lropt}}\le 0$, then default values are used for all optional parameters and ropt may be set to NULL.
25: $\mathbf{lropt}$Integer Input
On entry: length of the options array ropt.
26: $\mathbf{fail}$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.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{lb}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{lb}}\ge 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{lvpr}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{lvpr}}\ge 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{nvpr}}=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{nvpr}}\le 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{pdcxx}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdcxx}}\ge 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{pdcxz}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdcxz}}\ge 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{pdczz}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdczz}}\ge 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{pdid}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdid}}\ge 〈\mathit{\text{value}}〉$.
NE_INT_ARRAY
On entry, at least one value of i, for $\mathit{i}=1,2,\dots ,{\mathbf{nvpr}}$, does not appear in vpr.
On entry, icomm has not been initialized correctly.
On entry, ${\mathbf{vpr}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$ and ${\mathbf{nvpr}}=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{vpr}}\left[i\right]\le {\mathbf{nvpr}}$.
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_NEG_ELEMENT
At least one negative estimate for gamma was obtained. All negative estimates have been set to zero.
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_REAL_ARRAY
On entry, ${\mathbf{gamma}}\left[〈\mathit{\text{value}}〉\right]=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{gamma}}\left[0\right]=-1.0$ or ${\mathbf{gamma}}\left[i-1\right]\ge 0.0$.
NW_KT_CONDITIONS
Current point cannot be improved upon.
NW_NOT_CONVERGED
Optimal solution found, but requested accuracy not achieved.
NW_TOO_MANY_ITER
Too many major iterations.

Not applicable.

## 8Parallelism and Performance

g02jdc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02jdc 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.

The argument vpr gives the mapping between the random variables and the variance components. In most cases ${\mathbf{vpr}}\left[\mathit{i}-1\right]=\mathit{i}$, for $\mathit{i}=1,2,\dots ,{\sum }_{\mathit{i}}{\mathbf{rndm}}\left(1,\mathit{i}\right)+{\mathbf{rndm}}\left(2,\mathit{i}\right)$. However, in some cases it might be necessary to associate more than one random variable with a single variance component, for example, when the columns of DAT hold dummy variables.
Consider a dataset with three variables:
 $dat= 113.6 214.5 311.1 128.3 227.2 326.1$
where the first column corresponds to a categorical variable with three levels, the next to a categorical variable with two levels and the last column to a continuous variable. So in a call to g02jcc
 $levels=321$
also assume a model with no fixed effects, no random intercept, no nesting and all three variables being included as random effects, then
 $fixed=00; rndm=30123T.$
Each of the three columns in DAT therefore correspond to a single variable and hence there are three variance components, one for each random variable included in the model, so
 $vpr=123.$
This is the recommended way of supplying the data to g02jdc, however it is possible to reformat the above dataset by replacing each of the categorical variables with a series of dummy variables, one for each level. The dataset then becomes
 $dat= 100103.6 010104.5 001101.1 100018.3 010017.2 001016.1$
where each column only has one level
 $levels= 111111 .$
Again a model with no fixed effects, no random intercept, no nesting and all variables being included as random effects is required, so
 $fixed=00 ; rndm= 60123456T .$
With the data entered in this manner, the first three columns of DAT correspond to a single variable (the first column of the original dataset) as do the next two columns (the second column of the original dataset). Therefore vpr must reflect this
 $vpr= 111223 .$
In most situations it is more efficient to supply the data to g02jcc in terms of categorical variables rather than transform them into dummy variables.

### 9.1Internal Changes

Internal changes have been made to this function as follows:
• At Mark 27: The algorithm underlying this function has been altered to improve efficiency. The design matrices are now reordered internally before performing the analysis. It is therefore no longer necessary to construct rndm in the previously recommended manner.
For details of all known issues which have been reported for the NAG Library please refer to the Known Issues.

## 10Example

This example fits a random effects model with three levels of nesting to a simulated dataset with $90$ observations and $12$ variables.

### 10.1Program Text

Program Text (g02jdce.c)

### 10.2Program Data

Program Data (g02jdce.d)

### 10.3Program Results

Program Results (g02jdce.r)