PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_correg_linregm_estfunc (g02dn)
Purpose
nag_correg_linregm_estfunc (g02dn) gives the estimate of an estimable function along with its standard error.
Syntax
[
est,
stat,
sestat,
t,
ifail] = g02dn(
irank,
b,
covar,
p,
f,
tol, 'ip',
ip)
[
est,
stat,
sestat,
t,
ifail] = nag_correg_linregm_estfunc(
irank,
b,
covar,
p,
f,
tol, 'ip',
ip)
Description
nag_correg_linregm_estfunc (g02dn) 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
nag_correg_linregm_fit (g02da) or
nag_correg_linregm_update (g02dd). An estimable function is a linear combination of the arguments such that it has a unique estimate. For a full rank model all linear combinations of arguments 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
obtained from the
decomposition of the independent variables the SVD gives
where
is a
by
diagonal matrix with nonzero diagonal elements,
being the rank of
, and
and
are
by
orthogonal matrices. This gives the solution
being the first
columns of
, i.e.,
,
being the first
columns of
, and
being the first
elements of
.
Details of the SVD are made available in the form of the matrix
:
as given by
nag_correg_linregm_fit (g02da) and
nag_correg_linregm_update (g02dd).
A linear function of the arguments, , can be tested to see if it is estimable by computing . 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
is estimable it can be estimated by
and its standard error calculated from the variance-covariance matrix of
,
, as
Also a
-statistic,
can be computed. The
-statistic will have a Student's
-distribution with degrees of freedom as given by the degrees of freedom for the residual sum of squares for the model.
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
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the rank of the independent variables.
Constraint:
.
- 2:
– double array
-
The
ip values of the estimates of the arguments of the model,
.
- 3:
– 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
and the parameter estimate given in
,
, is stored in
.
- 4:
– double array
-
- 5:
– double array
-
, the linear function to be estimated.
- 6:
– double scalar
-
, the tolerance value used in the check for estimability.
- , where is the machine precision, is used instead.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
b,
f. (An error is raised if these dimensions are not equal.)
, the number of terms in the linear model.
Constraint:
.
Output Parameters
- 1:
– logical scalar
-
Indicates if the function was estimable.
- The function is estimable.
- The function is not estimable and stat, sestat and t are not set.
- 2:
– double scalar
-
If
,
stat contains the estimate of the function,
.
- 3:
– double scalar
-
If
,
sestat contains the standard error of the estimate of the function,
.
- 4:
– double scalar
-
If
,
t contains the
-statistic for the test of the function being equal to zero.
- 5:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Note: nag_correg_linregm_estfunc (g02dn) 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.
-
-
On entry, | , |
or | , |
or | . |
- W
-
On entry, | . In this case est is returned as true and all statistics are calculated. |
-
-
Standard error of statistic
; this may be due to rounding errors if the standard error is very small or due to mis-specified inputs
covar and
f.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
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_linregm_estfunc (g02dn) may be used to estimate functions of the arguments of the model as computed by
nag_correg_linregm_constrain (g02dk),
, these must be expressed in terms of the original arguments,
. The relation between the two sets of arguments may not be straightforward.
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
nag_correg_linregm_fit (g02da). The number of functions to be tested is read in, then the linear functions themselves are read in and tested with
nag_correg_linregm_estfunc (g02dn). The results of
nag_correg_linregm_estfunc (g02dn) are printed.
Open in the MATLAB editor:
g02dn_example
function g02dn_example
fprintf('g02dn example results\n\n');
x = [1, 0, 0, 0;
0, 0, 0, 1;
0, 1, 0, 0;
0, 0, 1, 0;
0, 0, 0, 1;
0, 1, 0, 0;
0, 0, 0, 1;
1, 0, 0, 0;
0, 0, 1, 0;
1, 0, 0, 0;
0, 0, 1, 0;
0, 1, 0, 0];
y = [33.63; 39.62; 38.18; 41.46; 38.02; 35.83;
35.99; 36.58; 42.92; 37.80; 40.43; 37.89];
[n,m] = size(x);
isx = ones(m,1,'int64');
mean_p = 'M';
ip = int64(m+1);
[rss, idf, b, se, covar, res, h, q, svd, irank, p, wk, ifail] = ...
g02da(mean_p, x, isx, ip, y);
fprintf('Estimates from g02da\n\n');
fprintf('Residual sum of squares = %12.4e\n', rss);
fprintf('Degrees of freedom = %4d\n', idf);
fprintf('\nVariable Parameter estimate Standard error\n\n');
ivar = double([1:ip]');
fprintf('%6d%20.4e%20.4e\n',[ivar b se]');
f = [1 1 0 0 0;
0 1 -1 0 0;
0 1 0 0 0];
nf = size(f,1);
tol = 1e-05;
for j = 1:nf
[est, stat, sestat, t, ifail] = ...
g02dn(irank, b, covar, p, f(j,:), tol);
fprintf('\nFunction %2d\n\n', j);
fprintf('%8.2f', f(j,:));
if est
fprintf('\n\nstat = %10.4f, se = %10.4f, t = %10.4f\n', stat, sestat, t);
else
fprintf('\n\nFunction not estimable\n');
end
end
g02dn example results
Estimates from g02da
Residual sum of squares = 2.2227e+01
Degrees of freedom = 8
Variable Parameter estimate Standard error
1 3.0557e+01 3.8494e-01
2 5.4467e+00 8.3896e-01
3 6.7433e+00 8.3896e-01
4 1.1047e+01 8.3896e-01
5 7.3200e+00 8.3896e-01
Function 1
1.00 1.00 0.00 0.00 0.00
stat = 36.0033, se = 0.9623, t = 37.4119
Function 2
0.00 1.00 -1.00 0.00 0.00
stat = -1.2967, se = 1.3610, t = -0.9528
Function 3
0.00 1.00 0.00 0.00 0.00
Function not estimable
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015