g02 Chapter Contents
g02 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_regsn_mult_linear_tran_model (g02dkc)

## 1  Purpose

nag_regsn_mult_linear_tran_model (g02dkc) calculates the estimates of the arguments of a general linear regression model for given constraints from the singular value decomposition results.

## 2  Specification

 #include #include
 void nag_regsn_mult_linear_tran_model (Integer ip, Integer iconst, const double p[], const double c[], Integer tdc, double b[], double rss, double df, double se[], double cov[], NagError *fail)

## 3  Description

nag_regsn_mult_linear_tran_model (g02dkc) computes the estimates given a set of linear constraints for a general linear regression model which is not of full rank. It is intended for use after a call to nag_regsn_mult_linear (g02dac) or nag_regsn_mult_linear_upd_model (g02ddc).
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 }}_{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_regsn_mult_linear (g02dac) and nag_regsn_mult_linear_upd_model (g02ddc).
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 ${\stackrel{^}{\beta }}_{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 ${\left({C}^{\mathrm{T}}{P}_{0}\right)}^{-1}$ exists.

## 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  Arguments

1:     ipIntegerInput
On entry: the number of terms in the linear model, $p$.
Constraint: ${\mathbf{ip}}\ge 1$.
2:     iconstIntegerInput
On entry: the number of constraints to be imposed on the arguments, ${n}_{c}$.
Constraint: $0<{\mathbf{iconst}}<{\mathbf{ip}}$.
3:     p[${\mathbf{ip}}×{\mathbf{ip}}+2×{\mathbf{ip}}$]const doubleInput
4:     c[${\mathbf{ip}}×{\mathbf{tdc}}$]const doubleInput
Note: the $\left(i,j\right)$th element of the matrix $C$ is stored in ${\mathbf{c}}\left[\left(i-1\right)×{\mathbf{tdc}}+j-1\right]$.
On entry: the iconst constraints stored by column, i.e., the $i$th constraint is stored in the $i$th column of c.
5:     tdcIntegerInput
On entry: the stride separating matrix column elements in the array c.
Constraint: ${\mathbf{tdc}}\ge {\mathbf{iconst}}$.
6:     b[ip]doubleInput/Output
On entry: the parameter estimates computed by using the singular value decomposition, ${\stackrel{^}{\beta }}_{svd}$.
On exit: the parameter estimates of the arguments with the constraints imposed, ${\stackrel{^}{\beta }}_{c}$.
On entry: the residual sum of squares as returned by nag_regsn_mult_linear (g02dac) or nag_regsn_mult_linear_upd_model (g02ddc).
Constraint: ${\mathbf{rss}}>0.0$.
8:     dfdoubleInput
On entry: the degrees of freedom associated with the residual sum of squares as returned by nag_regsn_mult_linear (g02dac) or nag_regsn_mult_linear_upd_model (g02ddc).
Constraint: ${\mathbf{df}}>0.0$.
9:     se[ip]doubleOutput
On exit: the standard error of the parameter estimates in b.
10:   cov[${\mathbf{ip}}×\left({\mathbf{ip}}+1\right)/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 ${\mathbf{b}}\left[\mathit{i}\right]$ and the parameter estimate given in ${\mathbf{b}}\left[\mathit{j}\right]$, $\mathit{j}\ge \mathit{i}$, is stored in ${\mathbf{cov}}\left[\mathit{j}\left(\mathit{j}+1\right)/2+\mathit{i}\right]$, for $\mathit{i}=0,1,\dots ,{\mathbf{ip}}-1$ and $\mathit{j}=\mathit{i},\dots ,{\mathbf{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, ${\mathbf{iconst}}=〈\mathit{\text{value}}〉$ while ${\mathbf{ip}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{iconst}}<{\mathbf{ip}}$.
NE_2_INT_ARG_LT
On entry, ${\mathbf{tdc}}=〈\mathit{\text{value}}〉$ while ${\mathbf{iconst}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdc}}\ge {\mathbf{iconst}}$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_INT_ARG_LE
On entry, ${\mathbf{iconst}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{iconst}}>0$.
NE_INT_ARG_LT
On entry, ${\mathbf{ip}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ip}}\ge 1$.
NE_MAT_NOT_FULL_RANK
Matrix c does not give a model of full rank.
NE_REAL_ARG_LE
On entry, df must not be less than or equal to 0.0: ${\mathbf{df}}=〈\mathit{\text{value}}〉$.
On entry, rss must not be less than or equal to 0.0: ${\mathbf{rss}}=〈\mathit{\text{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.

nag_regsn_mult_linear_tran_model (g02dkc) 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

Data from an experiment with four treatments and three observations per treatment are read in. A model, including the mean term, is fitted by nag_regsn_mult_linear (g02dac) and the results printed. The constraint that the sum of treatment effects is zero is then read in and the parameter estimates with this constraint imposed are computed by nag_regsn_mult_linear_tran_model (g02dkc) and printed.

### 9.1  Program Text

Program Text (g02dkce.c)

### 9.2  Program Data

Program Data (g02dkce.d)

### 9.3  Program Results

Program Results (g02dkce.r)