G02BTF updates the sample means and sums of squares and cross-products, or sums of squares and cross-products of deviations about the mean, for a new observation. The data may be weighted.
G02BTF is an adaptation of West's WV2 algorithm; see
West (1979). This routine updates the weighted means of variables and weighted sums of squares and cross-products or weighted sums of squares and cross-products of deviations about the mean for observations on
variables
, for
. For the first
observations let the mean of the
th variable be
, the cross-product about the mean for the
th and
th variables be
and the sum of weights be
. These are updated by the
th observation,
, for
, with weight
as follows:
and
The algorithm is initialized by taking
, the first observation and
.
- 1: – CHARACTER(1)Input
-
On entry: indicates whether G02BTF is to calculate sums of squares and cross-products, or sums of squares and cross-products of deviations about the mean.
- The sums of squares and cross-products of deviations about the mean are calculated.
- The sums of squares and cross-products are calculated.
Constraint:
or .
- 2: – INTEGERInput
-
On entry: , the number of variables.
Constraint:
.
- 3: – REAL (KIND=nag_wp)Input
-
On entry: the weight to use for the current observation,
.
For unweighted means and cross-products set
. The use of a suitable negative value of
WT, e.g.,
will have the effect of deleting the observation.
- 4: – REAL (KIND=nag_wp) arrayInput
-
On entry: must contain the value of the th variable for the current observation, .
- 5: – INTEGERInput
-
On entry: the increment of
X. Two situations are common.
If
, the data values are to be found in consecutive locations in
X, i.e., in a column.
If , for some positive integer , the data values are to be found as a row of an array with first dimension .
Constraint:
.
- 6: – REAL (KIND=nag_wp)Input/Output
-
On entry: the sum of weights for the previous observations,
.
- The update procedure is initialized.
- All elements of XBAR and C are set to zero.
Constraint:
and .
On exit: contains the updated sum of weights, .
- 7: – REAL (KIND=nag_wp) arrayInput/Output
-
On entry: if
,
XBAR is initialized, otherwise
must contain the weighted mean of the
th variable for the previous
observations,
, for
.
On exit: contains the weighted mean of the th variable, , for .
- 8: – REAL (KIND=nag_wp) arrayInput/Output
-
On entry: if
,
C must contain the upper triangular part of the matrix of weighted sums of squares and cross-products or weighted sums of squares and cross-products of deviations about the mean. It is stored packed form by column, i.e., the cross-product between the
th and
th variable,
, is stored in
.
On exit: the update sums of squares and cross-products stored as on input.
- 9: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
For a detailed discussion of the accuracy of this method see
Chan et al. (1982) and
West (1979).
Not applicable.
G02BTF may be used to update the results returned by
G02BUF.
G02BWF may be used to calculate the correlation matrix from the matrix of sums of squares and cross-products of deviations about the mean
and the matrix may be scaled
using
F06EDF (DSCAL) or
F06FDF
to produce a variance-covariance matrix.
A program to calculate the means, the required sums of squares and cross-products matrix, and the variance matrix for a set of observations of variables.