|
NAG[g02btc] NAG[nag_sum_sqs_update] - Update a weighted sum of squares matrix with a new observation
|
|
Calling Sequence
g02btc(mean, wt, x, incx, sw, xbar, c, 'm'=m, 'fail'=fail)
nag_sum_sqs_update(. . .)
Parameters
|
mean - String;
|
|
|
On entry: indicates whether nag_sum_sqs_update (g02btc) 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: "Nag_AboutMean" or "Nag_AboutZero". .
|
|
|
wt - float;
|
|
|
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.
|
|
|
x - Vector(1.., datatype=float[8]);
|
|
|
|
incx - integer;
|
|
|
On entry: the increment of x.
|
|
Constraint: . .
|
|
|
sw - assignable;
|
|
|
Note: On exit the variable sw will have a value of type float.
|
|
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, .
|
|
|
xbar - Vector(1..m, datatype=float[8]);
|
|
|
|
c - Vector(1.., datatype=float[8]);
|
|
|
Note: the dimension, dim, of the array c must be at least .
|
|
On exit: the update sums of squares and cross-products stored as on input.
|
|
|
'm'=m - integer; (optional)
|
|
|
On entry: , the number of variables.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_sum_sqs_update (g02btc) 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.
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_INT"
On entry, . Constraint: .
On entry, . Constraint: .
"NE_INTERNAL_ERROR"
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please consult NAG for assistance.
"NE_REAL"
On entry, . Constraint: .
"NE_SUM_WEIGHT"
On entry, : .
|
|
Accuracy
|
|
For a detailed discussion of the accuracy of this method see Chan et al. (1982) and West (1979).
|
|
Further Comments
|
|
nag_sum_sqs_update (g02btc) may be used to update the results returned by g02buc (nag_sum_sqs).
g02bwc (nag_cov_to_corr) may be used to calculate the correlation matrix from the matrix of sums of squares and cross-products of deviations about the mean .
|
|
|
Examples
|
|
>
|
mean := "Nag_AboutMean":
m := 3:
wt := 0.13:
incx := 1:
sw := 0:
x := Vector([9.123100000000001, 3.7011, 4.523], datatype=float[8]):
xbar := Vector([0, 0, 0], datatype=float[8]):
c := Vector([0, 0, 0, 0, 0, 0], datatype=float[8]):
NAG:-g02btc(mean, wt, x, incx, sw, xbar, c, 'm' = m):
|
|
|
See Also
|
|
Chan T F, Golub G H and Leveque R J (1982) Updating Formulae and a Pairwise Algorithm for Computing Sample Variances Compstat, Physica-Verlag
West D H D (1979) Updating mean and variance estimates: An improved method Comm. ACM 22 532–555
g02 Chapter Introduction.
NAG Toolbox Overview.
NAG Web Site.
|
|