NAG Library Function Document
nag_opt_lsq_covariance (e04ycc)
1 Purpose
nag_opt_lsq_covariance (e04ycc) returns estimates of elements of the variance-covariance matrix of the estimated regression coefficients for a nonlinear least squares problem. The estimates are derived from the Jacobian of the function at the solution.
nag_opt_lsq_covariance (e04ycc) may be used following either of the NAG C Library nonlinear least squares functions
nag_opt_lsq_no_deriv (e04fcc),
nag_opt_lsq_deriv (e04gbc).
2 Specification
#include <nag.h> |
#include <nage04.h> |
void |
nag_opt_lsq_covariance (Integer job,
Integer m,
Integer n,
double fsumsq,
double cj[],
Nag_E04_Opt *options,
NagError *fail) |
|
3 Description
nag_opt_lsq_covariance (e04ycc) is intended for use when the nonlinear least squares function,
, represents the goodness-of-fit of a nonlinear model to observed data. It assumes that the Hessian of
, at the solution, can be adequately approximated by
, where
is the Jacobian of
at the solution. The estimated variance-covariance matrix
is then given by
where
is the estimated variance of the residual at the solution,
, given by
being the number of observations and
the number of variables.
The diagonal elements of
are estimates of the variances of the estimated regression coefficients. See the
e04 Chapter Introduction,
Bard (1974) and
Wolberg (1967) for further information on the use of the matrix
.
When
is singular then
is taken to be
where
is the pseudo-inverse of
, and
but in this case the argument
fail is returned with
as a warning to you that
has linear dependencies in its columns. The assumed rank of
can be obtained from
.
The function can be used to find either the diagonal elements of , or the elements of the th column of , or the whole of .
nag_opt_lsq_covariance (e04ycc) must be preceded by one of the nonlinear least squares functions mentioned in
Section 1, and requires the arguments
fsumsq and
options to be supplied by those functions.
fsumsq is the residual sum of squares
while the structure
options contains the members
and
which give the singular values and right singular vectors respectively in the singular value decomposition of
.
4 References
Bard Y (1974) Nonlinear Parameter Estimation Academic Press
Wolberg J R (1967) Prediction Analysis Van Nostrand
5 Arguments
- 1:
– IntegerInput
-
On entry: indicates which elements of are returned as follows:
- The by symmetric matrix is returned.
- The diagonal elements of are returned.
- The elements of column job of are returned.
Constraint:
.
- 2:
– IntegerInput
-
On entry: the number of observations (residuals ).
Constraint:
.
- 3:
– IntegerInput
-
On entry: the number of variables .
Constraint:
.
- 4:
– doubleInput
-
On entry: the sum of squares of the residuals, , at the solution , as returned by the nonlinear least squares function.
Constraint:
.
- 5:
– doubleOutput
-
On exit: with
,
cj returns the
diagonal elements of
. With
,
cj returns the
elements of the
th column of
. When
,
cj is not referenced.
- 6:
– Nag_E04_Opt *Input/Output
-
On entry/exit: the structure used in the call to the nonlinear least squares function. The following members are relevant to nag_opt_lsq_covariance (e04ycc), their values should not be altered between the call to the least squares function and the call to nag_opt_lsq_covariance (e04ycc).
- s – doubleInput
-
On entry: the pointer to the singular values of the Jacobian as returned by the nonlinear least squares function.
- v – doubleInput/Output
-
On entry: the pointer to the by right-hand orthogonal matrix (the right singular vectors) of as returned by the nonlinear least squares function.
On exit: when
then
is unchanged.
When then the leading by part of is overwritten by the by matrix . Matrix element is held in for and .
- tdv – IntegerInput
-
On entry: the trailing dimension used by .
- 7:
– NagError *Input/Output
-
The NAG error argument (see
Section 2.7 in How to Use the NAG Library and its Documentation).
6 Error Indicators and Warnings
- NE_2_INT_ARG_GT
-
On entry, while . These arguments must satisfy .
- NE_2_INT_ARG_LT
-
On entry, while . These arguments must satisfy .
- NE_INT_ARG_LT
-
On entry,
job must not be less than
:
.
On entry,
n must not be less than
:
.
- NE_REAL_ARG_LT
-
On entry,
fsumsq must not be less than 0.0:
.
- NE_SINGULAR_VALUES
-
The singular values are all zero, so that at the solution the Jacobian matrix has rank 0.
- NW_LIN_DEPEND
-
At the solution the Jacobian matrix contains linear, or near linear, dependencies amongst its columns. assumed to have rank .
In this case the required elements of
have still been computed based upon
having an assumed rank given by
. The rank is computed by regarding singular values
that are not larger than
as zero, where
is the
machine precision (see
nag_machine_precision (X02AJC)). If you expect near linear dependencies at the solution and are happy with this tolerance in determining rank you should not call nag_opt_lsq_covariance (e04ycc) with the null pointer
NAGERR_DEFAULT as the argument
fail but should specifically declare and initialize a NagError structure for the argument
fail.
- Overflow
-
If overflow occurs then either an element of is very large, or the singular values or singular vectors have been incorrectly supplied.
7 Accuracy
The computed elements of will be the exact covariances corresponding to a closely neighbouring Jacobian matrix .
8 Parallelism and Performance
nag_opt_lsq_covariance (e04ycc) is not threaded in any implementation.
When the time taken by the function is approximately proportional to . When the time taken by the function is approximately proportional to .
10 Example
This example estimates the variance-covariance matrix
for the least squares estimates of
,
and
in the model
using the 15 sets of data given in the following table:
The program uses (0.5,1.0,1.5) as the initial guess at the position of the minimum and computes the least squares solution using
nag_opt_lsq_no_deriv (e04fcc). Note that the structure
options is initialized by
nag_opt_init (e04xxc) before calling
nag_opt_lsq_no_deriv (e04fcc). See the function documents for
nag_opt_lsq_no_deriv (e04fcc),
nag_opt_init (e04xxc) and
nag_opt_free (e04xzc) for further information.
10.1 Program Text
Program Text (e04ycce.c)
10.2 Program Data
Program Data (e04ycce.d)
10.3 Program Results
Program Results (e04ycce.r)