hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_correg_glm_estfunc (g02gn)

Purpose

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

Syntax

[est, stat, sestat, z, ifail] = g02gn(irank, b, cov, v, f, tol, 'ip', ip)
[est, stat, sestat, z, ifail] = nag_correg_glm_estfunc(irank, b, cov, v, f, tol, 'ip', ip)

Description

nag_correg_glm_estfunc (g02gn) 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 nag_correg_glm_normal (g02ga), nag_correg_glm_binomial (g02gb), nag_correg_glm_poisson (g02gc) or nag_correg_glm_gamma (g02gd). 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 functions use a singular value decomposition (SVD) to find the parameter estimates, β̂β^, and their variance-covariance matrix. Given the upper triangular matrix RR obtained from the QRQR decomposition of the independent variables the SVD gives
R = Q*
(D0)
0 0
PT,
R=Q* D 0 0 0 PT,
where DD is a kk by kk diagonal matrix with nonzero diagonal elements, kk being the rank of RR, and Q*Q* and PP are pp by pp orthogonal matrices. This leads to a solution:
β̂ = P1D1Q*1Tc1,
β^=P1D-1Q*1Tc1,
P1P1 being the first kk columns of PP, i.e., P = (P1P0)P=(P1P0); Q*1Q*1 being the first kk columns of Q*Q*, and c1c1 being the first pp elements of cc.
Details of the SVD are made available in the form of the matrix P*P*:
P* =
(D1 P1T )
P0T
P*= D-1 P1T P0T
as described by nag_correg_glm_normal (g02ga), nag_correg_glm_binomial (g02gb), nag_correg_glm_poisson (g02gc) and nag_correg_glm_gamma (g02gd).
A linear function of the parameters, F = fTβF=fTβ, can be tested to see if it is estimable by computing ζ = P0T fζ= 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 FF is estimable it can be estimated by fTβ̂fTβ^ and its standard error calculated from the variance-covariance matrix of β̂β^, CβCβ, as
se(F) = sqrt(fTCβf).
se(F)=fTCβf.
Also a zz statistic
z = (fTβ̂)/(se(F)),
z=fTβ^ se(F) ,
can be computed. The distribution of zz will be approximately Normal.

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

Parameters

Compulsory Input Parameters

1:     irank – int64int32nag_int scalar
kk, the rank of the dependent variables.
Constraint: 1irankip1irankip.
2:     b(ip) – double array
ip, the dimension of the array, must satisfy the constraint ip1ip1.
The ip values of the estimates of the parameters of the model, β̂β^.
3:     cov(ip × (ip + 1) / 2ip×(ip+1)/2) – double array
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)bi and the parameter estimate given in b(j)bj, jiji, is stored in cov((j × (j1) / 2 + i))cov(j×(j-1)/2+i).
4:     v(ldv,ip + 7ip+7) – double array
ldv, the first dimension of the array, must satisfy the constraint ldvipldvip.
5:     f(ip) – double array
ip, the dimension of the array, must satisfy the constraint ip1ip1.
ff, the linear function to be estimated.
6:     tol – double scalar
The tolerance value used in the check for estimability, ηη.
If tol0.0tol0.0 then sqrt(ε)ε, where εε is the machine precision, is used instead.

Optional Input Parameters

1:     ip – int64int32nag_int scalar
Default: The dimension of the arrays b, f and the first dimension of the array v. (An error is raised if these dimensions are not equal.)
pp, the number of terms in the linear model.
Constraint: ip1ip1.

Input Parameters Omitted from the MATLAB Interface

ldv wk

Output Parameters

1:     est – logical scalar
Indicates if the function was estimable.
est = trueest=true
The function is estimable.
est = falseest=false
The function is not estimable and stat, sestat and z are not set.
2:     stat – double scalar
If est = trueest=true, stat contains the estimate of the function, fTβ̂fTβ^
3:     sestat – double scalar
If est = trueest=true, sestat contains the standard error of the estimate of the function, se(F)se(F).
4:     z – double scalar
If est = trueest=true, z contains the zz statistic for the test of the function being equal to zero.
5:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Note: nag_correg_glm_estfunc (g02gn) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

  ifail = 1ifail=1
On entry,ip < 1ip<1,
orirank < 1irank<1,
orirank > ipirank>ip,
orldv < ipldv<ip.
W ifail = 2ifail=2
On entry,irank = ipirank=ip. In this case est is returned as true and all statistics are calculated.
W ifail = 3ifail=3
Standard error of statistic = 0.0=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.

Accuracy

The computations are believed to be stable.

Further Comments

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

Example

function nag_correg_glm_estfunc_example
irank = int64(7);
b = [2.597657842414576;
     1.261948923584132;
     1.277732791293482;
     0.05797612753696259;
     1.030690710494773;
     0.2910235146611871;
     0.9875662840229057;
     0.4879767334503795;
     -0.1995994002146691];
covar = [0.0006664818407102356;
     -0.0001595378960155927;
     0.001920010427807241;
     -0.0001672750280627377;
     -0.0003434322862006344;
     0.001902988737303523;
     0.0009932947647885656;
     -0.001736116037622199;
     -0.001726831479165626;
     0.00445624228157639;
     -0.0002293968978281512;
     -0.0001528053345265174;
     -0.0001543527609359471;
     7.776119763431389e-05;
     0.003035114236776554;
     0.0002344249938242676;
     1.801962690954937e-06;
     2.545362815264299e-07;
     0.0002323684948517858;
     -0.0008300681959040716;
     0.005354223695038647;
     -0.0002107346463877743;
     -0.0001465845840463917;
     -0.0001481320104558212;
     8.398194811443918e-05;
     -0.0002365220089546794;
     -0.0008549511978245716;
     0.003128425493978436;
     7.579948426790887e-05;
     -5.107320716116392e-05;
     -5.262063357059387e-05;
     0.0001794933249996664;
     -0.0006185675164955941;
     -0.001236996705365483;
     -0.0006434505184160947;
     0.004561096147256851;
     0.0007963889068339843;
     0.0001891232670275259;
     0.0001875758406180984;
     0.0004196897991883592;
     -0.001579353413250359;
     -0.00219778260212025;
     -0.001604236415170865;
     -0.00198628192271177;
     0.008164043260087225];
v = [4.890297476493481, 132.9931304975522, 0.08671323636775569, 11.53226476012202, ...
    0.6875039713237874, 0.6035396163882434, 0, 0.0190106784478845, 0.008405335397184037, ...
     0.008587821997748737, 0.002017521052951722, 0.006018698150011753, ...
    0.002569439508216107, 0.005710268118949224, 0.003195800397035001, 0.001516472273672414;
     4.150630280659896, 63.47399412403458, 0.1255168658332746, 7.96705680436851, ...
    0.4385677120269487, 0.5137644803624514, 0, -0.0002104052850739208, -0.03362644601906961, ...
    0.03352834001769896, -0.0001122992837032618, -8.410523978672018e-05, ...
    -1.834202533241677e-05, -7.350180559025446e-05, -2.50373181392074e-05, -9.418896225321663e-06;
     4.847173050021614, 127.3797841010689, 0.08860326907783028, 11.28626528578293, ...
    -1.207211262022778, 0.5962906923855547, 0, -0.000593266263451917, -0.0003445349204235381, ...
     -0.000333175581116977, 8.444423808860036e-05, 0.04164067761137802, ...
    -0.000834602710139113, -0.03974432490123243, -0.001281738894244829, -0.0003732773692135418;
     4.347583499449088, 77.29146221158076, 0.1137455037136346, 8.791556302019613, ...
    0.193629026736895, 0.5316079856446033, 0, -0.005604448606553034, -0.00473076223435367, ...
     -0.004660408745794929, 0.003786722373595579, 0.03079195529372083, ...
    -0.01961182893501804, 0.03434336417204345, -0.04455401443460466, -0.006573924702694605;
     3.660007365784039, 38.86162911664574, 0.160412976990412, 6.23390961729842, ...
    0.02218333268101244, 0.4819807366090336, 0, -0.01246501079735563, 0.02562719062269757, ...
     0.02538801446619446, -0.06348021588624767, -0.003268009116713865, ...
    0.01218311975746848, -0.003443738617825787, -0.01974708083814387, 0.001810698017859427;
     4.906081344202832, 135.1089303020151, 0.08603159451608589, 11.62363670724507, ...
    -0.3553126814370362, 0.6083327470988832, 0, -0.007494797532342946, 0.006087596749368498, ...
     0.006034528387724169, -0.01961692266943561, 0.009789429893167587, ...
    -0.06230084141169696, 0.01026746382279108, 0.04102802603588968, -0.006278875872494353;
     4.166414148369245, 64.48380766743846, 0.1245301935277972, 8.030181048235367, ...
    0.1880789664600944, 0.5196429754104227, 0, -0.007856295692343652, -0.001520639263699578, ...
     -0.001513684000176248, -0.004821972428467818, 0.01450100243772308, ...
    0.03053649776467425, 0.01481400539841174, 0.02215701246445583, -0.08986481375760852;
     4.862956917730965, 129.4062806673598, 0.08790676991659417, 11.37568814038781, ...
    1.174924303092439, 0.6011714612100958, 0, 0.4644148349507297, -0.508180337140321, ...
     -0.508180337140321, -0.508180337140321, 0.04376550218959127, ...
    0.04376550218959111, 0.04376550218959127, 0.04376550218959124, 0.04376550218959125;
     4.363367367158438, 78.52109911103648, 0.1128513646061788, 8.861213185057478, ...
    -0.7464706890225739, 0.5372707561039687, 0, -0.3635174659273034, -0.05120849696428324, ...
     -0.05120849696428324, -0.05120849696428316, 0.4147259628915867, ...
    0.4147259628915865, 0.4147259628915868, 0.4147259628915868, 0.4147259628915868];
f = [1;
     1;
     0;
     0;
     1;
     0;
     0;
     0;
     0];
tol = 5e-05;
[est, stat, sestat, z, ifail] = nag_correg_glm_estfunc(irank, b, covar, v, f, tol)
 

est =

     1


stat =

    4.8903


sestat =

    0.0674


z =

   72.5934


ifail =

                    0


function g02gn_example
irank = int64(7);
b = [2.597657842414576;
     1.261948923584132;
     1.277732791293482;
     0.05797612753696259;
     1.030690710494773;
     0.2910235146611871;
     0.9875662840229057;
     0.4879767334503795;
     -0.1995994002146691];
covar = [0.0006664818407102356;
     -0.0001595378960155927;
     0.001920010427807241;
     -0.0001672750280627377;
     -0.0003434322862006344;
     0.001902988737303523;
     0.0009932947647885656;
     -0.001736116037622199;
     -0.001726831479165626;
     0.00445624228157639;
     -0.0002293968978281512;
     -0.0001528053345265174;
     -0.0001543527609359471;
     7.776119763431389e-05;
     0.003035114236776554;
     0.0002344249938242676;
     1.801962690954937e-06;
     2.545362815264299e-07;
     0.0002323684948517858;
     -0.0008300681959040716;
     0.005354223695038647;
     -0.0002107346463877743;
     -0.0001465845840463917;
     -0.0001481320104558212;
     8.398194811443918e-05;
     -0.0002365220089546794;
     -0.0008549511978245716;
     0.003128425493978436;
     7.579948426790887e-05;
     -5.107320716116392e-05;
     -5.262063357059387e-05;
     0.0001794933249996664;
     -0.0006185675164955941;
     -0.001236996705365483;
     -0.0006434505184160947;
     0.004561096147256851;
     0.0007963889068339843;
     0.0001891232670275259;
     0.0001875758406180984;
     0.0004196897991883592;
     -0.001579353413250359;
     -0.00219778260212025;
     -0.001604236415170865;
     -0.00198628192271177;
     0.008164043260087225];
v = [4.890297476493481, 132.9931304975522, 0.08671323636775569, 11.53226476012202, ...
    0.6875039713237874, 0.6035396163882434, 0, 0.0190106784478845, 0.008405335397184037, ...
     0.008587821997748737, 0.002017521052951722, 0.006018698150011753, ...
    0.002569439508216107, 0.005710268118949224, 0.003195800397035001, 0.001516472273672414;
     4.150630280659896, 63.47399412403458, 0.1255168658332746, 7.96705680436851, ...
    0.4385677120269487, 0.5137644803624514, 0, -0.0002104052850739208, -0.03362644601906961, ...
    0.03352834001769896, -0.0001122992837032618, -8.410523978672018e-05, ...
    -1.834202533241677e-05, -7.350180559025446e-05, -2.50373181392074e-05, -9.418896225321663e-06;
     4.847173050021614, 127.3797841010689, 0.08860326907783028, 11.28626528578293, ...
    -1.207211262022778, 0.5962906923855547, 0, -0.000593266263451917, -0.0003445349204235381, ...
     -0.000333175581116977, 8.444423808860036e-05, 0.04164067761137802, ...
    -0.000834602710139113, -0.03974432490123243, -0.001281738894244829, -0.0003732773692135418;
     4.347583499449088, 77.29146221158076, 0.1137455037136346, 8.791556302019613, ...
    0.193629026736895, 0.5316079856446033, 0, -0.005604448606553034, -0.00473076223435367, ...
     -0.004660408745794929, 0.003786722373595579, 0.03079195529372083, ...
    -0.01961182893501804, 0.03434336417204345, -0.04455401443460466, -0.006573924702694605;
     3.660007365784039, 38.86162911664574, 0.160412976990412, 6.23390961729842, ...
    0.02218333268101244, 0.4819807366090336, 0, -0.01246501079735563, 0.02562719062269757, ...
     0.02538801446619446, -0.06348021588624767, -0.003268009116713865, ...
    0.01218311975746848, -0.003443738617825787, -0.01974708083814387, 0.001810698017859427;
     4.906081344202832, 135.1089303020151, 0.08603159451608589, 11.62363670724507, ...
    -0.3553126814370362, 0.6083327470988832, 0, -0.007494797532342946, 0.006087596749368498, ...
     0.006034528387724169, -0.01961692266943561, 0.009789429893167587, ...
    -0.06230084141169696, 0.01026746382279108, 0.04102802603588968, -0.006278875872494353;
     4.166414148369245, 64.48380766743846, 0.1245301935277972, 8.030181048235367, ...
    0.1880789664600944, 0.5196429754104227, 0, -0.007856295692343652, -0.001520639263699578, ...
     -0.001513684000176248, -0.004821972428467818, 0.01450100243772308, ...
    0.03053649776467425, 0.01481400539841174, 0.02215701246445583, -0.08986481375760852;
     4.862956917730965, 129.4062806673598, 0.08790676991659417, 11.37568814038781, ...
    1.174924303092439, 0.6011714612100958, 0, 0.4644148349507297, -0.508180337140321, ...
     -0.508180337140321, -0.508180337140321, 0.04376550218959127, ...
    0.04376550218959111, 0.04376550218959127, 0.04376550218959124, 0.04376550218959125;
     4.363367367158438, 78.52109911103648, 0.1128513646061788, 8.861213185057478, ...
    -0.7464706890225739, 0.5372707561039687, 0, -0.3635174659273034, -0.05120849696428324, ...
     -0.05120849696428324, -0.05120849696428316, 0.4147259628915867, ...
    0.4147259628915865, 0.4147259628915868, 0.4147259628915868, 0.4147259628915868];
f = [1;
     1;
     0;
     0;
     1;
     0;
     0;
     0;
     0];
tol = 5e-05;
[est, stat, sestat, z, ifail] = g02gn(irank, b, covar, v, f, tol)
 

est =

     1


stat =

    4.8903


sestat =

    0.0674


z =

   72.5934


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013