NAG FL Interface
g02gnf (glm_​estfunc)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g02gnf gives the estimate of an estimable function along with its standard error from the results from fitting a generalized linear model.

2 Specification

Fortran Interface
Subroutine g02gnf ( ip, irank, b, cov, v, ldv, f, est, stat, sestat, z, tol, wk, ifail)
Integer, Intent (In) :: ip, irank, ldv
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: b(ip), cov(ip*(ip+1)/2), v(ldv,ip+7), f(ip), tol
Real (Kind=nag_wp), Intent (Out) :: stat, sestat, z, wk(ip)
Logical, Intent (Out) :: est
C Header Interface
#include <nag.h>
void  g02gnf_ (const Integer *ip, const Integer *irank, const double b[], const double cov[], const double v[], const Integer *ldv, const double f[], logical *est, double *stat, double *sestat, double *z, const double *tol, double wk[], Integer *ifail)
The routine may be called by the names g02gnf or nagf_correg_glm_estfunc.

3 Description

g02gnf computes the estimates of an estimable function 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. An estimable function is a linear combination of the parameters such that it has a unique estimate. For a full rank model all linear combinations of parameters are estimable.
In the case of a model not of full rank the routines use a singular value decomposition (SVD) to find the parameter estimates, β^, and their variance-covariance matrix. Given the upper triangular matrix R obtained from the QR decomposition of the independent variables the SVD gives
R=Q* ( D 0 0 0 ) PT,  
where D is a k×k diagonal matrix with nonzero diagonal elements, k being the rank of R, and Q* and P are p×p orthogonal matrices. This leads to a solution:
β^=P1D-1Q*1Tc1,  
P1 being the first k columns of P, i.e., P=(P1P0); Q*1 being the first k columns of Q*, and c1 being the first p elements of c.
Details of the SVD are made available in the form of the matrix P*:
P*=( D-1 P1T P0T )  
as described by g02gaf, g02gbf, g02gcf and g02gdf.
A linear function of the parameters, F=fTβ, can be tested to see if it is estimable by computing ζ= P0T f. If ζ is zero, then the function is estimable, if not; the function is not estimable. In practice |ζ| is tested against some small quantity η.
Given that F is estimable it can be estimated by fTβ^ and its standard error calculated from the variance-covariance matrix of β^, Cβ, as
se(F)=fTCβf.  
Also a z statistic
z=fTβ^ se(F) ,  
can be computed. The distribution of z will be approximately Normal.

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: ip Integer Input
On entry: p, the number of terms in the linear model.
Constraint: ip1.
2: irank Integer Input
On entry: k, the rank of the dependent variables.
Constraint: 1irankip.
3: b(ip) Real (Kind=nag_wp) array Input
On entry: the ip values of the estimates of the parameters of the model, β^.
4: cov(ip×(ip+1)/2) Real (Kind=nag_wp) array Input
On entry: the upper triangular part of the variance-covariance 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 b(i) and the parameter estimate given in b(j), ji, is stored in cov((j×(j-1)/2+i)).
5: v(ldv,ip+7) Real (Kind=nag_wp) array Input
On entry: as returned by g02gaf, g02gbf, g02gcf and g02gdf.
6: ldv Integer Input
On entry: the first dimension of the array v as declared in the (sub)program from which g02gnf is called.
Constraint: ldvip.
7: f(ip) Real (Kind=nag_wp) array Input
On entry: f, the linear function to be estimated.
8: est Logical Output
On exit: indicates if the function was estimable.
est=.TRUE.
The function is estimable.
est=.FALSE.
The function is not estimable and stat, sestat and z are not set.
9: stat Real (Kind=nag_wp) Output
On exit: if est=.TRUE., stat contains the estimate of the function, fTβ^
10: sestat Real (Kind=nag_wp) Output
On exit: if est=.TRUE., sestat contains the standard error of the estimate of the function, se(F).
11: z Real (Kind=nag_wp) Output
On exit: if est=.TRUE., z contains the z statistic for the test of the function being equal to zero.
12: tol Real (Kind=nag_wp) Input
On entry: the tolerance value used in the check for estimability, η.
If tol0.0 then ε, where ε is the machine precision, is used instead.
13: wk(ip) Real (Kind=nag_wp) array Workspace
14: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of -1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value -1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value -1 is recommended since useful values can be provided in some output arguments even when ifail0 on exit. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry 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:
Note: in some cases g02gnf may return useful information.
ifail=1
On entry, ip=value.
Constraint: ip1.
On entry, irank=value.
Constraint: irank1.
On entry, irank=value and ip=value.
Constraint: irankip.
On entry, ldv=value and ip=value.
Constraint: ldvip.
ifail=2
irank=ip. In this case est is returned as true and all statistics are calculated.
ifail=3
Standard error of statistic =0.0; this may be due to rounding errors if the standard error is very small or due to mis-specified inputs cov and f.
ifail=-99
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.
ifail=-399
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

The computations are believed to be stable.

8 Parallelism and Performance

g02gnf 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.

9 Further Comments

The value of estimable functions is independent of the solution chosen from the many possible solutions. While g02gnf may be used to estimate functions of the parameters of the model as computed by g02gkf, βc, these must be expressed in terms of the original parameters, β. The relation between the two sets of parameters may not be straightforward.

10 Example

A loglinear model is fitted to a 3×5 contingency table by g02gcf. The model consists of terms for rows and columns. The table is:
141 67 114 79 39 131 66 143 72 35 36 14 38 28 16  
The number of functions to be tested is read in, then the linear functions themselves are read in and tested with g02gnf. The results of g02gnf are printed.

10.1 Program Text

Program Text (g02gnfe.f90)

10.2 Program Data

Program Data (g02gnfe.d)

10.3 Program Results

Program Results (g02gnfe.r)