Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

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, β̂$\stackrel{^}{\beta }$, and their variance-covariance matrix. Given the upper triangular matrix R$R$ obtained from the QR$QR$ decomposition of the independent variables the SVD gives
R = Q*
 ( D 0 ) 0 0
PT,
$R=Q* D 0 0 0 PT,$
where D$D$ is a k$k$ by k$k$ diagonal matrix with nonzero diagonal elements, k$k$ being the rank of R$R$, and Q*${Q}_{*}$ and P$P$ are p$p$ by p$p$ orthogonal matrices. This leads to a solution:
 β̂ = P1D − 1Q*1Tc1, $β^=P1D-1Q*1Tc1,$
P1${P}_{1}$ being the first k$k$ columns of P$P$, i.e., P = (P1P0)$P=\left({P}_{1}{P}_{0}\right)$; Q*1${Q}_{{*}_{1}}$ being the first k$k$ columns of Q*${Q}_{*}$, and c1${c}_{1}$ being the first p$p$ elements of c$c$.
Details of the SVD are made available in the form of the matrix P*${P}^{*}$:
P* =
 ( D − 1 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={f}^{\mathrm{T}}\beta$, can be tested to see if it is estimable by computing ζ = P0T f$\zeta ={P}_{0}^{\mathrm{T}}f$. If ζ$\zeta$ is zero, then the function is estimable, if not; the function is not estimable. In practice |ζ|$|\zeta |$ is tested against some small quantity η$\eta$.
Given that F$F$ is estimable it can be estimated by fTβ̂${f}^{\mathrm{T}}\stackrel{^}{\beta }$ and its standard error calculated from the variance-covariance matrix of β̂$\stackrel{^}{\beta }$, Cβ${C}_{\beta }$, as
 se(F) = sqrt(fTCβf). $se(F)=fTCβf.$
Also a z$z$ statistic
 z = (fTβ̂)/(se(F)), $z=fTβ^ se(F) ,$
can be computed. The distribution of z$z$ 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
k$k$, the rank of the dependent variables.
Constraint: 1irankip$1\le {\mathbf{irank}}\le {\mathbf{ip}}$.
2:     b(ip) – double array
ip, the dimension of the array, must satisfy the constraint ip1${\mathbf{ip}}\ge 1$.
The ip values of the estimates of the parameters of the model, β̂$\stackrel{^}{\beta }$.
3:     cov(ip × (ip + 1) / 2${\mathbf{ip}}×\left({\mathbf{ip}}+1\right)/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)${\mathbf{b}}\left(i\right)$ and the parameter estimate given in b(j)${\mathbf{b}}\left(j\right)$, ji$j\ge i$, is stored in cov((j × (j1) / 2 + i))${\mathbf{cov}}\left(\left(j×\left(j-1\right)/2+i\right)\right)$.
4:     v(ldv,ip + 7${\mathbf{ip}}+7$) – double array
ldv, the first dimension of the array, must satisfy the constraint ldvip$\mathit{ldv}\ge {\mathbf{ip}}$.
5:     f(ip) – double array
ip, the dimension of the array, must satisfy the constraint ip1${\mathbf{ip}}\ge 1$.
f$f$, the linear function to be estimated.
6:     tol – double scalar
The tolerance value used in the check for estimability, η$\eta$.
If tol0.0${\mathbf{tol}}\le 0.0$ then sqrt(ε)$\sqrt{\epsilon }$, where ε$\epsilon$ 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.)
p$p$, the number of terms in the linear model.
Constraint: ip1${\mathbf{ip}}\ge 1$.

ldv wk

Output Parameters

1:     est – logical scalar
Indicates if the function was estimable.
est = true${\mathbf{est}}=\mathbf{true}$
The function is estimable.
est = false${\mathbf{est}}=\mathbf{false}$
The function is not estimable and stat, sestat and z are not set.
2:     stat – double scalar
If est = true${\mathbf{est}}=\mathbf{true}$, stat contains the estimate of the function, fTβ̂${f}^{\mathrm{T}}\stackrel{^}{\beta }$
3:     sestat – double scalar
If est = true${\mathbf{est}}=\mathbf{true}$, sestat contains the standard error of the estimate of the function, se(F)$\mathrm{se}\left(F\right)$.
4:     z – double scalar
If est = true${\mathbf{est}}=\mathbf{true}$, z contains the z$z$ statistic for the test of the function being equal to zero.
5:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{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 = 1${\mathbf{ifail}}=1$
 On entry, ip < 1${\mathbf{ip}}<1$, or irank < 1${\mathbf{irank}}<1$, or ${\mathbf{irank}}>{\mathbf{ip}}$, or ldv < ip$\mathit{ldv}<{\mathbf{ip}}$.
W ifail = 2${\mathbf{ifail}}=2$
 On entry, ${\mathbf{irank}}={\mathbf{ip}}$. In this case est is returned as true and all statistics are calculated.
W ifail = 3${\mathbf{ifail}}=3$
Standard error of statistic = 0.0$\text{}=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.

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${\beta }_{\mathrm{c}}$, these must be expressed in terms of the original parameters, β$\beta$. 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

```