NAG Library Routine Document
G02GNF
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
SUBROUTINE G02GNF ( |
IP, IRANK, B, COV, V, LDV, F, EST, STAT, SESTAT, Z, TOL, WK, IFAIL) |
INTEGER |
IP, IRANK, LDV, IFAIL |
REAL (KIND=nag_wp) |
B(IP), COV(IP*(IP+1)/2), V(LDV,IP+7), F(IP), STAT, SESTAT, Z, TOL, WK(IP) |
LOGICAL |
EST |
|
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
obtained from the
decomposition of the independent variables the SVD gives
where
is a
by
diagonal matrix with nonzero diagonal elements,
being the rank of
, and
and
are
by
orthogonal matrices. This leads to a solution:
being the first
columns of
, i.e.,
;
being the first
columns of
, and
being the first
elements of
.
Details of the SVD are made available in the form of the matrix
:
as described by
G02GAF,
G02GBF,
G02GCF and
G02GDF.
A linear function of the parameters, , can be tested to see if it is estimable by computing . 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
is estimable it can be estimated by
and its standard error calculated from the variance-covariance matrix of
,
, as
Also a
statistic
can be computed. The distribution of
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 Parameters
- 1: – INTEGERInput
-
On entry: , the number of terms in the linear model.
Constraint:
.
- 2: – INTEGERInput
-
On entry: , the rank of the dependent variables.
Constraint:
.
- 3: – REAL (KIND=nag_wp) arrayInput
-
On entry: the
IP values of the estimates of the parameters of the model,
.
- 4: – REAL (KIND=nag_wp) arrayInput
-
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
and the parameter estimate given in
,
, is stored in
.
- 5: – REAL (KIND=nag_wp) arrayInput
-
On entry: as returned by
G02GAF,
G02GBF,
G02GCF and
G02GDF.
- 6: – INTEGERInput
-
On entry: the first dimension of the array
V as declared in the (sub)program from which G02GNF is called.
Constraint:
.
- 7: – REAL (KIND=nag_wp) arrayInput
-
On entry: , the linear function to be estimated.
- 8: – LOGICALOutput
-
On exit: indicates if the function was estimable.
- The function is estimable.
- The function is not estimable and STAT, SESTAT and Z are not set.
- 9: – REAL (KIND=nag_wp)Output
-
On exit: if
,
STAT contains the estimate of the function,
- 10: – REAL (KIND=nag_wp)Output
-
On exit: if
,
SESTAT contains the standard error of the estimate of the function,
.
- 11: – REAL (KIND=nag_wp)Output
-
On exit: if
,
Z contains the
statistic for the test of the function being equal to zero.
- 12: – REAL (KIND=nag_wp)Input
-
On entry: the tolerance value used in the check for estimability,
.
If then , where is the machine precision, is used instead.
- 13: – REAL (KIND=nag_wp) arrayWorkspace
-
- 14: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if
on exit, the recommended value is
.
When the value 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).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Note: G02GNF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
-
On entry, | , |
or | , |
or | , |
or | . |
-
On entry, | . In this case EST is returned as true and all statistics are calculated. |
-
Standard error of statistic
; this may be due to rounding errors if the standard error is very small or due to mis-specified inputs
COV and
F.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
The computations are believed to be stable.
8 Parallelism and Performance
G02GNF is not threaded by NAG in any implementation.
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.
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,
, 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
by
contingency table by
G02GCF. The model consists of terms for rows and columns. The table is:
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)