nag_sum_sqs_combine (g02bzc) combines two sets of sample means and sums of squares and crossproducts matrices. It is designed to be used in conjunction with
nag_sum_sqs (g02buc) to allow large datasets to be summarised.
Let
$X$ and
$Y$ denote two sets of data, each with
$m$ variables and
${n}_{x}$ and
${n}_{y}$ observations respectively. Let
${\mu}_{x}$ denote the (optionally weighted) vector of
$m$ means for the first dataset and
${C}_{x}$ denote either the sums of squares and crossproducts of deviations from
${\mu}_{x}$
or the sums of squares and crossproducts, in which case
where
$e$ is a vector of
${n}_{x}$ ones and
${D}_{x}$ is a diagonal matrix of (optional) weights and
${W}_{x}$ is defined as the sum of the diagonal elements of
$D$. Similarly, let
${\mu}_{y}$,
${C}_{y}$ and
${W}_{y}$ denote the same quantities for the second dataset.
Given
${\mu}_{x},{\mu}_{y},{C}_{x},{C}_{y},{W}_{x}$ and
${W}_{y}$ nag_sum_sqs_combine (g02bzc) calculates
${\mu}_{z}$,
${C}_{z}$ and
${W}_{z}$ as if a dataset
$Z$, with
$m$ variables and
${n}_{x}+{n}_{y}$ observations were supplied to
nag_sum_sqs (g02buc), with
$Z$ constructed as
nag_sum_sqs_combine (g02bzc) has been designed to combine the results from two calls to
nag_sum_sqs (g02buc) allowing large datasets, or cases where all the data is not available at the same time, to be summarised.
Bennett J, Pebay P, Roe D and Thompson D (2009) Numerically stable, singlepass, parallel statistics algorithms Proceedings of IEEE International Conference on Cluster Computing
 1:
$\mathbf{mean}$ – Nag_SumSquareInput

On entry: indicates whether the matrices supplied in
xc and
yc are sums of squares and crossproducts, or sums of squares and crossproducts of deviations about the mean.
 ${\mathbf{mean}}=\mathrm{Nag\_AboutMean}$
 Sums of squares and crossproducts of deviations about the mean have been supplied.
 ${\mathbf{mean}}=\mathrm{Nag\_AboutZero}$
 Sums of squares and crossproducts have been supplied.
Constraint:
${\mathbf{mean}}=\mathrm{Nag\_AboutMean}$ or $\mathrm{Nag\_AboutZero}$.
 2:
$\mathbf{m}$ – IntegerInput

On entry: $m$, the number of variables.
Constraint:
${\mathbf{m}}\ge 1$.
 3:
$\mathbf{xsw}$ – double *Input/Output

On entry: ${W}_{x}$, the sum of weights, from the first set of data, $X$. If the data is unweighted then this will be the number of observations in the first dataset.
On exit: ${W}_{z}$, the sum of weights, from the combined dataset, $Z$. If both datasets are unweighted then this will be the number of observations in the combined dataset.
Constraint:
${\mathbf{xsw}}\ge 0$.
 4:
$\mathbf{xmean}\left[{\mathbf{m}}\right]$ – doubleInput/Output

On entry: ${\mu}_{x}$, the sample means for the first set of data, $X$.
On exit: ${\mu}_{z}$, the sample means for the combined data, $Z$.
 5:
$\mathbf{xc}\left[\left({\mathbf{m}}\times {\mathbf{m}}+{\mathbf{m}}\right)/2\right]$ – doubleInput/Output

On entry:
${C}_{x}$, the sums of squares and crossproducts matrix for the first set of data,
$X$, as returned by
nag_sum_sqs (g02buc).
nag_sum_sqs (g02buc), returns this matrix packed by columns, i.e., the crossproduct between the
$j$th and
$k$th variable,
$k\ge j$, is stored in
${\mathbf{xc}}\left[k\times \left(k1\right)/2+j1\right]$.
No check is made that ${C}_{x}$ is a valid crossproducts matrix.
On exit:
${C}_{z}$, the sums of squares and crossproducts matrix for the combined dataset,
$Z$.
This matrix is again stored packed by columns.
 6:
$\mathbf{ysw}$ – doubleInput

On entry: ${W}_{y}$, the sum of weights, from the second set of data, $Y$. If the data is unweighted then this will be the number of observations in the second dataset.
Constraint:
${\mathbf{ysw}}\ge 0$.
 7:
$\mathbf{ymean}\left[{\mathbf{m}}\right]$ – const doubleInput

On entry: ${\mu}_{y}$, the sample means for the second set of data, $Y$.
 8:
$\mathbf{yc}\left[\left({\mathbf{m}}\times {\mathbf{m}}+{\mathbf{m}}\right)/2\right]$ – const doubleInput

On entry:
${C}_{y}$, the sums of squares and crossproducts matrix for the second set of data,
$Y$, as returned by
nag_sum_sqs (g02buc).
nag_sum_sqs (g02buc), returns this matrix packed by columns, i.e., the crossproduct between the
$j$th and
$k$th variable,
$k\ge j$, is stored in
${\mathbf{yc}}\left[k\times \left(k1\right)/2+j1\right]$.
No check is made that ${C}_{y}$ is a valid crossproducts matrix.
 9:
$\mathbf{fail}$ – NagError *Input/Output

The NAG error argument (see
Section 2.7 in How to Use the NAG Library and its Documentation).
Not applicable.
nag_sum_sqs_combine (g02bzc) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
x06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
None.
This example illustrates the use of nag_sum_sqs_combine (g02bzc) by dividing a dataset into three blocks of
$4$,
$5$ and
$3$ observations respectively. Each block of data is summarised using
nag_sum_sqs (g02buc) and then the three summaries combined using nag_sum_sqs_combine (g02bzc).
The resulting sums of squares and crossproducts matrix is then scaled to obtain the covariance matrix for the whole dataset.