nag_glm_tran_model (g02gkc) (PDF version)
g02 Chapter Contents
g02 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_glm_tran_model (g02gkc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_glm_tran_model (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>
#include <nagg02.h>
void  nag_glm_tran_model (Integer ip, Integer nclin, const double v[], Integer tdv, const double c[], Integer tdc, double b[], double scale, double se[], double cov[], NagError *fail)

3  Description

nag_glm_tran_model (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 nag_glm_normal (g02gac), nag_glm_binomial (g02gbc), nag_glm_poisson (g02gcc) or nag_glm_gamma (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 nag_glm_normal (g02gac), nag_glm_binomial (g02gbc), nag_glm_poisson (g02gcc) and nag_glm_gamma (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  by 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:     ipIntegerInput
On entry: the number of terms in the linear model, p .
Constraint: ip1 .
2:     nclinIntegerInput
On entry: the number of constraints to be imposed on the arguments, n c .
Constraint: 0 < nclin < ip .
3:     v[ip×tdv]const doubleInput
Note: the i,jth element of the matrix V is stored in v[i-1×tdv+j-1].
4:     tdvIntegerInput
On entry: the stride separating matrix column elements in the array v.
5:     c[ip×tdc]const doubleInput
Note: the i,jth 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:     tdcIntegerInput
On entry: the stride separating matrix column elements in the array c.
Constraint: tdcnclin .
7:     b[ip]doubleInput/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:     scaledoubleInput
On entry: the estimate of the scale argument.
For results from nag_glm_normal (g02gac) and nag_glm_gamma (g02gdc) then scale is the scale argument, for the model σ 2  and ν ^ -1  respectively.
For results from nag_glm_binomial (g02gbc) and nag_glm_poisson (g02gcc) then scale should be set to 1.0.
Constraint: scale>0.0 .
9:     se[ip]doubleOutput
On exit: the standard error of the parameter estimates in b.
10:   cov[ip×ip+1/2]doubleOutput
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:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

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  Further Comments

nag_glm_tran_model (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.

9  Example

A loglinear model is fitted to a 3 by 5 contingency table by nag_glm_poisson (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 nag_glm_tran_model (g02gkc) and printed.

9.1  Program Text

Program Text (g02gkce.c)

9.2  Program Data

Program Data (g02gkce.d)

9.3  Program Results

Program Results (g02gkce.r)


nag_glm_tran_model (g02gkc) (PDF version)
g02 Chapter Contents
g02 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012