G02 Chapter Contents
G02 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG02JBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G02JBF fits a linear mixed effects regression model using maximum likelihood (ML).

## 2  Specification

 SUBROUTINE G02JBF ( N, NCOL, LDDAT, DAT, LEVELS, YVID, CWID, NFV, FVID, FINT, NRV, RVID, NVPR, VPR, RINT, SVID, GAMMA, NFF, NRF, DF, ML, LB, B, SE, MAXIT, TOL, WARN, IFAIL)
 INTEGER N, NCOL, LDDAT, LEVELS(NCOL), YVID, CWID, NFV, FVID(NFV), FINT, NRV, RVID(NRV), NVPR, VPR(NRV), RINT, SVID, NFF, NRF, DF, LB, MAXIT, WARN, IFAIL REAL (KIND=nag_wp) DAT(LDDAT,NCOL), GAMMA(NVPR+2), ML, B(LB), SE(LB), TOL

## 3  Description

G02JBF 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
 $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 expectations 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$, G02JBF 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. G02JBF 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).
G02JBF fits the model using a quasi-Newton algorithm to maximize the log-likelihood function:
 $-2 l R = log V + n log r ′ V-1 r + log 2 π / n$
where
 $V = ZG Z′ + R, r=y-Xb and b = X ′ V-1 X -1 X ′ V-1 y .$
Once the final estimates for ${\gamma }^{*}$ have been obtained, the value of ${\sigma }_{R}^{2}$ is given by:
 $σR2 = r′ V-1 r / n - p .$
Case weights, ${W}_{c}$, can be incorporated into the model by replacing ${X}^{\prime }X$ and ${Z}^{\prime }Z$ with ${X}^{\prime }{W}_{c}X$ and ${Z}^{\prime }{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).

## 4  References

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

## 5  Parameters

1:     N – INTEGERInput
On entry: $n$, the number of observations.
Constraint: ${\mathbf{N}}\ge 1$.
2:     NCOL – INTEGERInput
On entry: the number of columns in the data matrix, DAT.
Constraint: ${\mathbf{NCOL}}\ge 1$.
3:     LDDAT – INTEGERInput
On entry: the first dimension of the array DAT as declared in the (sub)program from which G02JBF is called.
Constraint: ${\mathbf{LDDAT}}\ge {\mathbf{N}}$.
4:     DAT(LDDAT,NCOL) – REAL (KIND=nag_wp) arrayInput
On entry: array containing all of the data. For the $i$th observation:
• ${\mathbf{DAT}}\left(i,{\mathbf{YVID}}\right)$ holds the dependent variable, $y$;
• if ${\mathbf{CWID}}\ne 0$, ${\mathbf{DAT}}\left(i,{\mathbf{CWID}}\right)$ holds the case weights;
• if ${\mathbf{SVID}}\ne 0$, ${\mathbf{DAT}}\left(i,{\mathbf{SVID}}\right)$ holds the subject variable.
The remaining columns hold the values of the independent variables.
Constraints:
• if ${\mathbf{CWID}}\ne 0$, ${\mathbf{DAT}}\left(i,{\mathbf{CWID}}\right)\ge 0.0$;
• if ${\mathbf{LEVELS}}\left(j\right)\ne 1$, $1\le {\mathbf{DAT}}\left(i,j\right)\le {\mathbf{LEVELS}}\left(j\right)$.
5:     LEVELS(NCOL) – INTEGER arrayInput
On entry: ${\mathbf{LEVELS}}\left(i\right)$ contains the number of levels associated with the $i$th variable of the data matrix DAT. If this variable is continuous or binary (i.e., only takes the values zero or one) then ${\mathbf{LEVELS}}\left(i\right)$ should be $1$; if the variable is discrete then ${\mathbf{LEVELS}}\left(i\right)$ is the number of levels associated with it and ${\mathbf{DAT}}\left(\mathit{j},i\right)$ is assumed to take the values $1$ to ${\mathbf{LEVELS}}\left(i\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{N}}$.
Constraint: ${\mathbf{LEVELS}}\left(\mathit{i}\right)\ge 1$, for $\mathit{i}=1,2,\dots ,{\mathbf{NCOL}}$.
6:     YVID – INTEGERInput
On entry: the column of DAT holding the dependent, $y$, variable.
Constraint: $1\le {\mathbf{YVID}}\le {\mathbf{NCOL}}$.
7:     CWID – INTEGERInput
On entry: the column of DAT holding the case weights.
If ${\mathbf{CWID}}=0$, no weights are used.
Constraint: $0\le {\mathbf{CWID}}\le {\mathbf{NCOL}}$.
8:     NFV – INTEGERInput
On entry: the number of independent variables in the model which are to be treated as being fixed.
Constraint: $0\le {\mathbf{NFV}}<{\mathbf{NCOL}}$.
9:     FVID(NFV) – INTEGER arrayInput
On entry: the columns of the data matrix DAT holding the fixed independent variables with ${\mathbf{FVID}}\left(i\right)$ holding the column number corresponding to the $i$th fixed variable.
Constraint: $1\le {\mathbf{FVID}}\left(\mathit{i}\right)\le {\mathbf{NCOL}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NFV}}$.
10:   FINT – INTEGERInput
On entry: flag indicating whether a fixed intercept is included (${\mathbf{FINT}}=1$).
Constraint: ${\mathbf{FINT}}=0$ or $1$.
11:   NRV – INTEGERInput
On entry: the number of independent variables in the model which are to be treated as being random.
Constraints:
• $0\le {\mathbf{NRV}}<{\mathbf{NCOL}}$;
• ${\mathbf{NRV}}+{\mathbf{RINT}}>0$.
12:   RVID(NRV) – INTEGER arrayInput
On entry: the columns of the data matrix ${\mathbf{DAT}}$ holding the random independent variables with ${\mathbf{RVID}}\left(i\right)$ holding the column number corresponding to the $i$th random variable.
Constraint: $1\le {\mathbf{RVID}}\left(\mathit{i}\right)\le {\mathbf{NCOL}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NRV}}$.
13:   NVPR – INTEGERInput
On entry: if ${\mathbf{RINT}}=1$ and ${\mathbf{SVID}}\ne 0$, NVPR is the number of variance components being $\text{estimated}-2$, ($g-1$), else ${\mathbf{NVPR}}=g$.
If ${\mathbf{NRV}}=0$, ${\mathbf{NVPR}}$ is not referenced.
Constraint: if ${\mathbf{NRV}}\ne 0$, $1\le {\mathbf{NVPR}}\le {\mathbf{NRV}}$.
14:   VPR(NRV) – INTEGER arrayInput
On entry: ${\mathbf{VPR}}\left(i\right)$ holds a flag indicating the variance of the $i$th random variable. The variance of the $i$th random variable is ${\sigma }_{j}^{2}$, where $j={\mathbf{VPR}}\left(i\right)+1$ if ${\mathbf{RINT}}=1$ and ${\mathbf{SVID}}\ne 0$ and $j={\mathbf{VPR}}\left(i\right)$ otherwise. Random variables with the same value of $j$ are assumed to be taken from the same distribution.
Constraint: $1\le {\mathbf{VPR}}\left(\mathit{i}\right)\le {\mathbf{NVPR}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NRV}}$.
15:   RINT – INTEGERInput
On entry: flag indicating whether a random intercept is included (${\mathbf{RINT}}=1$).
If ${\mathbf{SVID}}=0$, RINT is not referenced.
Constraint: ${\mathbf{RINT}}=0$ or $1$.
16:   SVID – INTEGERInput
On entry: the column of DAT holding the subject variable.
If ${\mathbf{SVID}}=0$, no subject variable is used.
Specifying a subject variable is equivalent to specifying the interaction between that variable and all of the random-effects. Letting the notation ${Z}_{1}×{Z}_{S}$ denote the interaction between variables ${Z}_{1}$ and ${Z}_{S}$, fitting a model with ${\mathbf{RINT}}=0$, random-effects ${Z}_{1}+{Z}_{2}$ and subject variable ${Z}_{S}$ is equivalent to fitting a model with random-effects ${Z}_{1}×{Z}_{S}+{Z}_{2}×{Z}_{S}$ and no subject variable. If ${\mathbf{RINT}}=1$ the model is equivalent to fitting ${Z}_{S}+{Z}_{1}×{Z}_{S}+{Z}_{2}×{Z}_{S}$ and no subject variable.
Constraint: $0\le {\mathbf{SVID}}\le {\mathbf{NCOL}}$.
17:   GAMMA(${\mathbf{NVPR}}+2$) – REAL (KIND=nag_wp) arrayInput/Output
On entry: holds the initial values of the variance components, ${\gamma }_{0}$, with ${\mathbf{GAMMA}}\left(\mathit{i}\right)$ the initial value for ${\sigma }_{\mathit{i}}^{2}/{\sigma }_{R}^{2}$, for $\mathit{i}=1,2,\dots ,g$. If ${\mathbf{RINT}}=1$ and ${\mathbf{SVID}}\ne 0$, $g={\mathbf{NVPR}}+1$, else $g={\mathbf{NVPR}}$.
If ${\mathbf{GAMMA}}\left(1\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}\right)$, for $\mathit{i}=1,2,\dots ,g$, holds the final estimate of ${\sigma }_{\mathit{i}}^{2}$ and ${\mathbf{GAMMA}}\left(g+1\right)$ holds the final estimate for ${\sigma }_{R}^{2}$.
Constraint: ${\mathbf{GAMMA}}\left(1\right)=-1.0\text{​ or ​}{\mathbf{GAMMA}}\left(\mathit{i}\right)\ge 0.0$, for $\mathit{i}=1,2,\dots ,g$.
18:   NFF – INTEGEROutput
On exit: the number of fixed effects estimated (i.e., the number of columns, $p$, in the design matrix $X$).
19:   NRF – INTEGEROutput
On exit: the number of random effects estimated (i.e., the number of columns, $q$, in the design matrix $Z$).
20:   DF – INTEGEROutput
On exit: the degrees of freedom.
21:   ML – REAL (KIND=nag_wp)Output
On exit: $-2{l}_{R}\left(\stackrel{^}{\gamma }\right)$ where ${l}_{R}$ is the log of the maximum likelihood calculated at $\stackrel{^}{\gamma }$, the estimated variance components returned in GAMMA.
22:   LB – INTEGERInput
On entry: the size of the array B.
Constraint: ${\mathbf{LB}}\ge {\mathbf{FINT}}+\sum _{i=1}^{{\mathbf{NFV}}}\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{LEVELS}}\left({\mathbf{FVID}}\left(i\right)\right)-1,1\right)+{L}_{S}×\left({\mathbf{RINT}}+\sum _{i=1}^{{\mathbf{NRV}}}{\mathbf{LEVELS}}\left({\mathbf{RVID}}\left(i\right)\right)\right)$ where ${L}_{S}={\mathbf{LEVELS}}\left({\mathbf{SVID}}\right)$ if ${\mathbf{SVID}}\ne 0$ and $1$ otherwise.
23:   B(LB) – REAL (KIND=nag_wp) arrayOutput
On exit: the parameter estimates, $\left(\beta ,\nu \right)$, with the first NFF elements of B containing the fixed effect parameter estimates, $\beta$ and the next NRF elements of B containing the random effect parameter estimates, $\nu$.
Fixed effects
If ${\mathbf{FINT}}=1$, ${\mathbf{B}}\left(1\right)$ contains the estimate of the fixed intercept. Let ${L}_{i}$ denote the number of levels associated with the $i$th fixed variable, that is ${L}_{i}={\mathbf{LEVELS}}\left({\mathbf{FVID}}\left(i\right)\right)$. Define
• if ${\mathbf{FINT}}=1$, ${F}_{1}=2$ else if ${\mathbf{FINT}}=0$, ${F}_{1}=1$;
• ${F}_{i+1}={F}_{i}+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({L}_{i}-1,1\right)$, $i\ge 1$.
Then for $i=1,2,\dots ,{\mathbf{NFV}}$:
• if ${L}_{i}>1$, ${\mathbf{B}}\left({F}_{i}+\mathit{j}-2\right)$ contains the parameter estimate for the $\mathit{j}$th level of the $i$th fixed variable, for $\mathit{j}=2,3,\dots ,{L}_{i}$;
• if ${L}_{i}\le 1$, ${\mathbf{B}}\left({F}_{i}\right)$ contains the parameter estimate for the $i$th fixed variable.
Random effects
Redefining ${L}_{i}$ to denote the number of levels associated with the $i$th random variable, that is ${L}_{i}={\mathbf{LEVELS}}\left({\mathbf{RVID}}\left(i\right)\right)$. Define
• if ${\mathbf{RINT}}=1$, ${R}_{1}=2$ else if ${\mathbf{RINT}}=0$, ${R}_{1}=1$;
${R}_{i+1}={R}_{i}+{L}_{i}$, $i\ge 1$.
Then for $i=1,2,\dots ,{\mathbf{NRV}}$:
• if ${\mathbf{SVID}}=0$,
• if ${L}_{i}>1$, ${\mathbf{B}}\left({\mathbf{NFF}}+{R}_{i}+\mathit{j}-1\right)$ contains the parameter estimate for the $\mathit{j}$th level of the $i$th random variable, for $\mathit{j}=1,2,\dots ,{L}_{i}$;
• if ${L}_{i}\le 1$, ${\mathbf{B}}\left({\mathbf{NFF}}+{R}_{i}\right)$ contains the parameter estimate for the $i$th random variable;
• if ${\mathbf{SVID}}\ne 0$,
• let ${L}_{S}$ denote the number of levels associated with the subject variable, that is ${L}_{S}={\mathbf{LEVELS}}\left({\mathbf{SVID}}\right)$;
• if ${L}_{i}>1$, ${\mathbf{B}}\left({\mathbf{NFF}}+\left(\mathit{s}-1\right){L}_{S}+{R}_{i}+\mathit{j}-1\right)$ contains the parameter estimate for the interaction between the $\mathit{s}$th level of the subject variable and the $\mathit{j}$th level of the $i$th random variable, for $\mathit{s}=1,2,\dots ,{L}_{S}$ and $\mathit{j}=1,2,\dots ,{L}_{i}$;
• if ${L}_{i}\le 1$, ${\mathbf{B}}\left({\mathbf{NFF}}+\left(\mathit{s}-1\right){L}_{S}+{R}_{i}\right)$ contains the parameter estimate for the interaction between the $\mathit{s}$th level of the subject variable and the $i$th random variable, for $\mathit{s}=1,2,\dots ,{L}_{S}$;
• if ${\mathbf{RINT}}=1$, ${\mathbf{B}}\left({\mathbf{NFF}}+1\right)$ contains the estimate of the random intercept.
24:   SE(LB) – REAL (KIND=nag_wp) arrayOutput
On exit: the standard errors of the parameter estimates given in B.
25:   MAXIT – INTEGERInput
On entry: the maximum number of iterations.
If ${\mathbf{MAXIT}}<0$, the default value of $100$ is used.
If ${\mathbf{MAXIT}}=0$, the parameter estimates $\left(\beta ,\nu \right)$ and corresponding standard errors are calculated based on the value of ${\gamma }_{0}$ supplied in GAMMA.
26:   TOL – REAL (KIND=nag_wp)Input
On entry: the tolerance used to assess convergence.
If ${\mathbf{TOL}}\le 0.0$, the default value of ${\epsilon }^{0.7}$ is used, where $\epsilon$ is the machine precision.
27:   WARN – INTEGEROutput
On exit: is set to $1$ if a variance component was estimated to be a negative value during the fitting process. Otherwise WARN is set to $0$.
If ${\mathbf{WARN}}=1$, the negative estimate is set to zero and the estimation process allowed to continue.
28:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{N}}<2$, or ${\mathbf{NCOL}}<1$, or ${\mathbf{LDDAT}}<{\mathbf{N}}$, or ${\mathbf{YVID}}<1$ or ${\mathbf{YVID}}>{\mathbf{NCOL}}$, or ${\mathbf{CWID}}<0$ or ${\mathbf{CWID}}>{\mathbf{NCOL}}$, or ${\mathbf{NFV}}<0$ or ${\mathbf{NFV}}\ge {\mathbf{NCOL}}$, or ${\mathbf{FINT}}\ne 0$ and ${\mathbf{FINT}}\ne 1$, or ${\mathbf{NRV}}<0$ or ${\mathbf{NRV}}>{\mathbf{NCOL}}$ or ${\mathbf{NRV}}+{\mathbf{RINT}}<1$, or ${\mathbf{NVPR}}<0$ or ${\mathbf{NVPR}}>{\mathbf{NRV}}$, or ${\mathbf{RINT}}\ne 0$ and ${\mathbf{RINT}}\ne 1$, or ${\mathbf{SVID}}<0$ or ${\mathbf{SVID}}>{\mathbf{NCOL}}$, or LB is too small.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{LEVELS}}\left(i\right)<1$, for at least one $i$, or ${\mathbf{FVID}}\left(i\right)<1$, or ${\mathbf{FVID}}\left(i\right)>{\mathbf{NCOL}}$, for at least one $i$, or ${\mathbf{RVID}}\left(i\right)<1$, or ${\mathbf{RVID}}\left(i\right)>{\mathbf{NCOL}}$, for at least one $i$, or ${\mathbf{VPR}}\left(i\right)<1$ or ${\mathbf{VPR}}\left(i\right)>{\mathbf{NVPR}}$, for at least one $i$, or at least one discrete variable in array DAT has a value greater than that specified in LEVELS, or ${\mathbf{GAMMA}}\left(i\right)<0$, for at least one $i$, and ${\mathbf{GAMMA}}\left(1\right)\ne -1$.
${\mathbf{IFAIL}}=3$
Degrees of freedom $<1$. The number of parameters exceed the effective number of observations.
${\mathbf{IFAIL}}=4$
The routine failed to converge to the specified tolerance in MAXIT iterations. See Section 8 for advice.

## 7  Accuracy

The accuracy of the results can be adjusted through the use of the TOL parameter.

Wherever possible any block structure present in the design matrix $Z$ should be modelled through a subject variable, specified via SVID, rather than being explicitly entered into DAT.
G02JBF uses an iterative process to fit the specified model and for some problems this process may fail to converge (see ${\mathbf{IFAIL}}={\mathbf{4}}$). If the routine fails to converge then the maximum number of iterations (see MAXIT) or tolerance (see TOL) may require increasing; try a different starting estimate in GAMMA. Alternatively, the model can be fit using restricted maximum likelihood (see G02JAF) or using the noniterative MIVQUE0.
To fit the model just using MIVQUE0, the first element of GAMMA should be set to $-1$ and MAXIT should be set to zero.
Although the quasi-Newton algorithm used in G02JBF tends to require more iterations before converging compared to the Newton–Raphson algorithm recommended by Wolfinger et al. (1994), it does not require the second derivatives of the likelihood function to be calculated and consequentially takes significantly less time per iteration.

## 9  Example

The following dataset is taken from Stroup (1989) and arises from a balanced split-plot design with the whole plots arranged in a randomized complete block-design.
In this example the full design matrix for the random independent variable, $Z$, is given by:
 $Z = 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1$
 $= A 0 0 0 0 A 0 0 0 0 A 0 0 0 0 A A 0 0 0 0 A 0 0 0 0 A 0 0 0 0 A ,$ (1)
where
 $A = 1 1 0 0 1 0 1 0 1 0 0 1 .$
The block structure evident in (1) is modelled by specifying a four-level subject variable, taking the values $\left\{1,1,1,2,2,2,3,3,3,4,4,4,1,1,1,2,2,2,3,3,3,4,4,4\right\}$. The first column of $1\mathrm{s}$ is added to $A$ by setting ${\mathbf{RINT}}=1$. The remaining columns of $A$ are specified by a three level factor, taking the values, $\left\{1,2,3,1,2,3,1,\dots \right\}$.

### 9.1  Program Text

Program Text (g02jbfe.f90)

### 9.2  Program Data

Program Data (g02jbfe.d)

### 9.3  Program Results

Program Results (g02jbfe.r)