NAG CL Interface
g02gkc (glm_​constrain)

Settings help

CL Name Style:


1 Purpose

g02gkc calculates the estimates of the arguments of a generalized linear model for given constraints from the singular value decomposition results.

2 Specification

#include <nag.h>
void  g02gkc (Integer ip, Integer nclin, const double v[], Integer tdv, const double c[], Integer tdc, double b[], double scale, double se[], double cov[], NagError *fail)
The function may be called by the names: g02gkc, nag_correg_glm_constrain or nag_glm_tran_model.

3 Description

g02gkc 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 g02gac, g02gbc, g02gcc or g02gdc.
In the case of a model not of full rank the functions use a singular value decomposition (SVD) to find the parameter estimates, β ^ svd , and their variance-covariance matrix. Details of the SVD are made available, in the form of the matrix P * :
P * = ( D −1 P1T P0T )  
as described by g02gac, g02gbc, g02gcc and g02gdc.
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 c = p - k constraints will have to be imposed to obtain a unique solution.
Let C be a p × n c matrix of constraints, such that
CT β = 0 ,  
then the new parameter estimates β ^ c are given by:
β ^ c = A β ^ svd = ( I-P 0 (CT P 0 ) −1 ) β ^ svd ,  
where I is the identity matrix, and the variance-covariance matrix is given by:
A P 1 D −2 P1T AT  
provided (CT P 0 ) −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: ip Integer Input
On entry: the number of terms in the linear model, p .
Constraint: ip1 .
2: nclin Integer Input
On entry: the number of constraints to be imposed on the arguments, n c .
Constraint: 0 < nclin < ip .
3: v[ip×tdv] const double Input
Note: the (i,j)th element of the matrix V is stored in v[(i-1)×tdv+j-1].
On entry: v as returned by g02gac, g02gbc, g02gcc or g02gdc.
4: tdv Integer Input
On entry: the stride separating matrix column elements in the array v.
Constraint: tdv ip + 6 .
tdv should be as supplied to g02gac, g02gbc, g02gcc or g02gdc.
5: c[ip×tdc] const double Input
Note: the (i,j)th element of the matrix C is stored in c[(i-1)×tdc+j-1].
On entry: the nclin constraints stored by column, i.e., the i th constraint is stored in the i th column of c.
6: tdc Integer Input
On entry: the stride separating matrix column elements in the array c.
Constraint: tdcnclin .
7: b[ip] double Input/Output
On entry: the parameter estimates computed by using the singular value decomposition, β ^ svd .
On exit: the parameter estimates of the arguments with the constraints imposed, β ^ c .
8: scale double Input
On entry: the estimate of the scale argument.
For results from g02gac and g02gdc then scale is the scale argument, for the model σ 2 and ν ^ −1 respectively.
For results from g02gbc and g02gcc then scale should be set to 1.0.
Constraint: scale>0.0 .
9: se[ip] double Output
On exit: the standard error of the parameter estimates in b.
10: cov[(ip)×(ip+1)/2] double Output
On exit: 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 ] , for i=0,1,,ip - 1 and j=i,,ip - 1.
11: fail 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_GE
On entry, nclin=value while ip=value . These arguments must satisfy nclin<ip .
NE_2_INT_ARG_LT
On entry, tdc=value while nclin=value . These arguments must satisfy tdcnclin .
On entry, tdv=value while ip=value . These arguments must satisfy tdv ip + 6 .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_INT_ARG_LE
On entry, nclin=value.
Constraint: nclin>0.
NE_INT_ARG_LT
On entry, ip=value.
Constraint: ip1.
NE_MAT_NOT_FULL_RANK
Matrix c does not give a model of full rank.
NE_REAL_ARG_LE
On entry, scale must not be less than or equal to 0.0: scale=value .

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

g02gkc is not threaded in any implementation.

9 Further Comments

g02gkc is intended for use in situations in which dummy (0-1) 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 function 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 g02gcc. 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 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 g02gkc and printed.

10.1 Program Text

Program Text (g02gkce.c)

10.2 Program Data

Program Data (g02gkce.d)

10.3 Program Results

Program Results (g02gkce.r)