G02 Chapter Contents
G02 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG02DNF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G02DNF gives the estimate of an estimable function along with its standard error.

## 2  Specification

 SUBROUTINE G02DNF ( IP, IRANK, B, COV, P, F, EST, STAT, SESTAT, T, TOL, WK, IFAIL)
 INTEGER IP, IRANK, IFAIL REAL (KIND=nag_wp) B(IP), COV(IP*(IP+1)/2), P(IP*IP+2*IP), F(IP), STAT, SESTAT, T, TOL, WK(IP) LOGICAL EST

## 3  Description

G02DNF 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 G02DAF or G02DDF. 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 routines use a singular value decomposition (SVD) to find the parameter estimates, $\stackrel{^}{\beta }$, and their variance-covariance matrix. Given the upper triangular matrix $R$ obtained from the $QR$ decomposition of the independent variables the SVD gives
 $R=Q* D 0 0 0 PT,$
where $D$ is a $k$ by $k$ diagonal matrix with nonzero diagonal elements, $k$ being the rank of $R$, and ${Q}_{*}$ and $P$ are $p$ by $p$ orthogonal matrices. This gives the solution
 $β^=P1D-1Q*1Tc1,$
${P}_{1}$ being the first $k$ columns of $P$, i.e., $P=\left({P}_{1}{P}_{0}\right)$, ${Q}_{{*}_{1}}$ being the first $k$ columns of ${Q}_{*}$, and ${c}_{1}$ being the first $p$ elements of $c$.
Details of the SVD are made available in the form of the matrix ${P}^{*}$:
 $P*= D-1 P1T P0T ,$
as given by G02DAF and G02DDF.
A linear function of the parameters, $F={f}^{\mathrm{T}}\beta$, can be tested to see if it is estimable by computing $\zeta ={P}_{0}^{\mathrm{T}}f$. If $\zeta$ is zero, then the function is estimable; if not, the function is not estimable. In practice $\left|\zeta \right|$ is tested against some small quantity $\eta$.
Given that $F$ is estimable it can be estimated by ${f}^{\mathrm{T}}\stackrel{^}{\beta }$ and its standard error calculated from the variance-covariance matrix of $\stackrel{^}{\beta }$, ${C}_{\beta }$, as
 $seF=fTCβf.$
Also a $t$-statistic,
 $t=fTβ^ seF ,$
can be computed. The $t$-statistic will have a Student's $t$-distribution with degrees of freedom as given by the degrees of freedom for the residual sum of squares for the model.

## 4  References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl. 20(3) 2–25
Searle S R (1971) Linear Models Wiley

## 5  Parameters

1:     IP – INTEGERInput
On entry: $p$, the number of terms in the linear model.
Constraint: ${\mathbf{IP}}\ge 1$.
2:     IRANK – INTEGERInput
On entry: $k$, the rank of the independent variables.
Constraint: $1\le {\mathbf{IRANK}}\le {\mathbf{IP}}$.
3:     B(IP) – REAL (KIND=nag_wp) arrayInput
On entry: the IP values of the estimates of the parameters of the model, $\stackrel{^}{\beta }$.
4:     COV(${\mathbf{IP}}×\left({\mathbf{IP}}+1\right)/2$) – REAL (KIND=nag_wp) arrayInput
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 ${\mathbf{B}}\left(i\right)$ and the parameter estimate given in ${\mathbf{B}}\left(j\right)$, $j\ge i$, is stored in ${\mathbf{COV}}\left(\left(j×\left(j-1\right)/2+i\right)\right)$.
5:     P(${\mathbf{IP}}×{\mathbf{IP}}+2×{\mathbf{IP}}$) – REAL (KIND=nag_wp) arrayInput
On entry: as returned by G02DAF and G02DDF.
6:     F(IP) – REAL (KIND=nag_wp) arrayInput
On entry: $f$, the linear function to be estimated.
7:     EST – LOGICALOutput
On exit: indicates if the function was estimable.
${\mathbf{EST}}=\mathrm{.TRUE.}$
The function is estimable.
${\mathbf{EST}}=\mathrm{.FALSE.}$
The function is not estimable and STAT, SESTAT and T are not set.
8:     STAT – REAL (KIND=nag_wp)Output
On exit: if ${\mathbf{EST}}=\mathrm{.TRUE.}$, STAT contains the estimate of the function, ${f}^{\mathrm{T}}\stackrel{^}{\beta }$.
9:     SESTAT – REAL (KIND=nag_wp)Output
On exit: if ${\mathbf{EST}}=\mathrm{.TRUE.}$, SESTAT contains the standard error of the estimate of the function, $\mathrm{se}\left(F\right)$.
10:   T – REAL (KIND=nag_wp)Output
On exit: if ${\mathbf{EST}}=\mathrm{.TRUE.}$, T contains the $t$-statistic for the test of the function being equal to zero.
11:   TOL – REAL (KIND=nag_wp)Input
On entry: $\eta$, the tolerance value used in the check for estimability.
${\mathbf{TOL}}\le 0.0$
$\sqrt{\epsilon }$, where $\epsilon$ is the machine precision, is used instead.
12:   WK(IP) – REAL (KIND=nag_wp) arrayWorkspace
13:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if ${\mathbf{IFAIL}}\ne {\mathbf{0}}$ on exit, the recommended value is $-1$. When the value $-\mathbf{1}\text{​ or ​}1$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: G02DNF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{IP}}<1$, or ${\mathbf{IRANK}}<1$, or ${\mathbf{IRANK}}>{\mathbf{IP}}$.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{IRANK}}={\mathbf{IP}}$. In this case EST is returned as true and all statistics are calculated.
${\mathbf{IFAIL}}=3$
Standard error of statistic $\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.

## 7  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 G02DNF may be used to estimate functions of the parameters of the model as computed by G02DKF, ${\beta }_{c}$, these must be expressed in terms of the original parameters, $\beta$. The relation between the two sets of parameters may not be straightforward.

## 9  Example

Data from an experiment with four treatments and three observations per treatment are read in. A model, with a mean term, is fitted by G02DAF. The number of functions to be tested is read in, then the linear functions themselves are read in and tested with G02DNF. The results of G02DNF are printed.

### 9.1  Program Text

Program Text (g02dnfe.f90)

### 9.2  Program Data

Program Data (g02dnfe.d)

### 9.3  Program Results

Program Results (g02dnfe.r)