NAG Library Routine Document
G02GKF
1 Purpose
G02GKF calculates the estimates of the arguments of a generalized linear model for given constraints from the singular value decomposition results.
2 Specification
SUBROUTINE G02GKF ( 
IP, ICONST, V, LDV, C, LDC, B, S, SE, COV, WK, IFAIL) 
INTEGER 
IP, ICONST, LDV, LDC, IFAIL 
REAL (KIND=nag_wp) 
V(LDV,IP+7), C(LDC,ICONST), B(IP), S, SE(IP), COV(IP*(IP+1)/2), WK(2*IP*IP+IP*ICONST+2*ICONST*ICONST+4*ICONST) 

3 Description
G02GKF computes the estimates given a set of linear constraints for a generalized linear model which is not of full rank. It is intended for use after a call to
G02GAF,
G02GBF,
G02GCF or
G02GDF.
In the case of a model not of full rank the routines use a singular value decomposition to find the parameter estimates,
${\hat{\beta}}_{\text{svd}}$, and their variancecovariance matrix. Details of the SVD are made available in the form of the matrix
${P}^{*}$:
as described by
G02GAF,
G02GBF,
G02GCF and
G02GDF. Alternative solutions can be formed by imposing constraints on the arguments. If there are
$p$ arguments and the rank of the model is
$k$ then
${n}_{\mathrm{c}}=pk$ constraints will have to be imposed to obtain a unique solution.
Let
$C$ be a
$p$ by
${n}_{\mathrm{c}}$ matrix of constraints, such that
then the new parameter estimates
${\hat{\beta}}_{\mathrm{c}}$ are given by:
and the variancecovariance matrix is given by
provided
${\left({C}^{\mathrm{T}}{P}_{0}\right)}^{1}$ exists.
4 References
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
McCullagh P and Nelder J A (1983) Generalized Linear Models Chapman and Hall
Searle S R (1971) Linear Models Wiley
5 Arguments
 1: $\mathrm{IP}$ – INTEGERInput

On entry: $p$, the number of terms in the linear model.
Constraint:
${\mathbf{IP}}\ge 1$.
 2: $\mathrm{ICONST}$ – INTEGERInput

On entry: the number of constraints to be imposed on the arguments, ${n}_{\mathrm{c}}$.
Constraint:
$0<{\mathbf{ICONST}}<{\mathbf{IP}}$.
 3: $\mathrm{V}\left({\mathbf{LDV}},{\mathbf{IP}}+7\right)$ – REAL (KIND=nag_wp) arrayInput

On entry: the array
V as returned by
G02GAF,
G02GBF,
G02GCF or
G02GDF.
 4: $\mathrm{LDV}$ – INTEGERInput

On entry: the first dimension of the array
V as declared in the (sub)program from which G02GKF is called.
Constraint:
${\mathbf{LDV}}\ge {\mathbf{IP}}$.
LDV should be as supplied to
G02GAF,
G02GBF,
G02GCF or
G02GDF
 5: $\mathrm{C}\left({\mathbf{LDC}},{\mathbf{ICONST}}\right)$ – REAL (KIND=nag_wp) arrayInput

On entry: contains the
ICONST constraints stored by column, i.e., the
$i$th constraint is stored in the
$i$th column of
C.
 6: $\mathrm{LDC}$ – INTEGERInput

On entry: the first dimension of the array
C as declared in the (sub)program from which G02GKF is called.
Constraint:
${\mathbf{LDC}}\ge {\mathbf{IP}}$.
 7: $\mathrm{B}\left({\mathbf{IP}}\right)$ – REAL (KIND=nag_wp) arrayInput/Output

On entry: the parameter estimates computed by using the singular value decomposition, ${\hat{\beta}}_{\text{svd}}$.
On exit: the parameter estimates of the arguments with the constraints imposed, ${\hat{\beta}}_{\mathrm{c}}$.
 8: $\mathrm{S}$ – REAL (KIND=nag_wp)Input

On entry: the estimate of the scale argument.
For results from
G02GAF and
G02GDF then
S is the scale argument for the model.
For results from
G02GBF and
G02GCF then
S should be set to
$1.0$.
Constraint:
${\mathbf{S}}>0.0$.
 9: $\mathrm{SE}\left({\mathbf{IP}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: the standard error of the parameter estimates in
B.
 10: $\mathrm{COV}\left({\mathbf{IP}}\times \left({\mathbf{IP}}+1\right)/2\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: the upper triangular part of the variancecovariance matrix of the
IP parameter estimates given in
B. They are stored packed by column, i.e., the covariance between the parameter estimate given in
${\mathbf{B}}\left(i\right)$ and the parameter estimate given in
${\mathbf{B}}\left(j\right)$,
$j\ge i$, is stored in
${\mathbf{COV}}\left(\left(j\times \left(j1\right)/2+i\right)\right)$.
 11: $\mathrm{WK}\left(2\times {\mathbf{IP}}\times {\mathbf{IP}}+{\mathbf{IP}}\times {\mathbf{ICONST}}+2\times {\mathbf{ICONST}}\times {\mathbf{ICONST}}+4\times {\mathbf{ICONST}}\right)$ – REAL (KIND=nag_wp) arrayWorkspace

Note: a simple upper bound for the size of the workspace is $5\times {\mathbf{IP}}\times {\mathbf{IP}}+4\times {\mathbf{IP}}$.
 12: $\mathrm{IFAIL}$ – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ or}1$. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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}}=0$ or
$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{IP}}<1$. 
or  ${\mathbf{ICONST}}\ge {\mathbf{IP}}$, 
or  ${\mathbf{ICONST}}\le 0$, 
or  ${\mathbf{LDV}}<{\mathbf{IP}}$, 
or  ${\mathbf{LDC}}<{\mathbf{IP}}$, 
or  ${\mathbf{S}}\le 0.0$. 
 ${\mathbf{IFAIL}}=2$

C does not give a model of full rank.
 ${\mathbf{IFAIL}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{IFAIL}}=399$
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{IFAIL}}=999$
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7 Accuracy
It should be noted that due to rounding errors an argument that should be zero when the constraints have been imposed may be returned as a value of order machine precision.
8 Parallelism and Performance
G02GKF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
G02GKF 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 implementationspecific information.
G02GKF is intended for use in situations in which dummy ($0\u20131$) variables have been used such as in the analysis of designed experiments when you do not wish to change the arguments of the model to give a full rank model. The routine is not intended for situations in which the relationships between the independent variables are only approximate.
10 Example
A loglinear model is fitted to a
$3$ by
$5$ contingency table by
G02GCF. The model consists of terms for rows and columns. The table is
The constraints that the sum of row effects and the sum of column effects are zero are then read in and the parameter estimates with these constraints imposed are computed by G02GKF and printed.
10.1 Program Text
Program Text (g02gkfe.f90)
10.2 Program Data
Program Data (g02gkfe.d)
10.3 Program Results
Program Results (g02gkfe.r)