NAG CL Interface
g02gnc (glm_estfunc)
1
Purpose
g02gnc gives the estimate of an estimable function along with its standard error from the results from fitting a generalized linear model.
2
Specification
void |
g02gnc (Integer ip,
Integer rank,
const double b[],
const double cov[],
const double v[],
Integer tdv,
const double f[],
Nag_Boolean *est,
double *stat,
double *sestat,
double *z,
double tol,
NagError *fail) |
|
The function may be called by the names: g02gnc, nag_correg_glm_estfunc or nag_glm_est_func.
3
Description
g02gnc computes the estimates of an estimable function for a general linear regression model which is not of full rank. It is intended for use after a call to
g02gac,
g02gbc,
g02gcc or
g02gdc. An estimable function is a linear combination of the arguments such that it has a unique estimate. For a full rank model all linear combinations of arguments are estimable.
In the case of a model not of full rank the functions 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 given by
g02gac,
g02gbc,
g02gcc and
g02gdc.
A linear function of the arguments, , 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
Arguments
-
1:
– Integer
Input
-
On entry: the number of terms in the linear model, .
Constraint:
.
-
2:
– Integer
Input
-
On entry: the rank of the independent variables, .
Constraint:
.
-
3:
– const double
Input
-
On entry: the
ip values of the estimates of the arguments of the model,
.
-
4:
– const double
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
and the parameter estimate given in
,
, is stored in
, for
and
.
-
5:
– const double
Input
-
Note: the th element of the matrix is stored in .
On entry:
v as returned by
g02gac,
g02gbc,
g02gcc and
g02gdc.
-
6:
– Integer
Input
-
On entry: the stride separating matrix column elements in the array
v.
Constraint:
.
tdv should be as supplied to
g02gac,
g02gbc,
g02gcc or
g02gdc.
-
7:
– const double
Input
-
On entry: the linear function to be estimated, .
-
8:
– Nag_Boolean *
Output
-
On exit:
est indicates if the function was estimable.
- The function is estimable.
- The function is not estimable and stat, sestat and z are not set.
-
9:
– double *
Output
-
On exit: if
,
stat contains the estimate of the function,
.
-
10:
– double *
Output
-
On exit: if
,
sestat contains the standard error of the estimate of the function,
.
-
11:
– double *
Output
-
On exit: if
,
z contains the
statistic for the test of the function being equal to zero.
-
12:
– double
Input
-
On entry:
tol is the tolerance value used in the check for estimability,
.
If , then is used instead.
-
13:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
- NE_2_INT_ARG_GT
-
On entry, while . These arguments must satisfy .
- NE_2_INT_ARG_LT
-
On entry, while . These arguments must satisfy .
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
- NE_INT_ARG_LT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_RANK_EQ_IP
-
On entry,
. In this case, the boolean variable
est is returned as Nag_TRUE and all statistics are calculated.
- NE_STDES_ZERO
-
sestat, the standard error of the estimate of the function, se
; probably due to rounding error or due to incorrectly specified input values of
cov and
f.
7
Accuracy
The computations are believed to be stable.
8
Parallelism and Performance
g02gnc is not threaded in any implementation.
The value of estimable functions is independent of the solution chosen from the many possible solutions. While
g02gnc may be used to estimate functions of the arguments of the model as computed by
g02gkc,
, these must be expressed in terms of the original arguments,
. The relation between the two sets of arguments may not be straightforward.
10
Example
A loglinear model is fitted to a 3 by 5 contingency table by
g02gcc. The model consists of terms for 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
g02gnc. The results of
g02gnc are printed.
10.1
Program Text
10.2
Program Data
10.3
Program Results