g02ce takes selected elements from two vectors (typically vectors of means and standard deviations) to form two smaller vectors, and selected rows and columns from two matrices (typically either matrices of sums of squares and cross-products of deviations from means and Pearson product-moment correlation coefficients, or matrices of sums of squares and cross-products about zero and correlation-like coefficients) to form two smaller matrices, allowing reordering of elements in the process.

# Syntax

C#
```public static void g02ce(
int n,
double[] xbar,
double[] std,
double[,] ssp,
double[,] r,
int m,
int[] korder,
double[] xbar2,
double[] std2,
double[,] ssp2,
double[,] r2,
out int ifail
)```
Visual Basic
```Public Shared Sub g02ce ( _
n As Integer, _
xbar As Double(), _
std As Double(), _
ssp As Double(,), _
r As Double(,), _
m As Integer, _
korder As Integer(), _
xbar2 As Double(), _
std2 As Double(), _
ssp2 As Double(,), _
r2 As Double(,), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g02ce(
int n,
array<double>^ xbar,
array<double>^ std,
array<double,2>^ ssp,
array<double,2>^ r,
int m,
array<int>^ korder,
array<double>^ xbar2,
array<double>^ std2,
array<double,2>^ ssp2,
array<double,2>^ r2,
[OutAttribute] int% ifail
)```
F#
```static member g02ce :
n : int *
xbar : float[] *
std : float[] *
ssp : float[,] *
r : float[,] *
m : int *
korder : int[] *
xbar2 : float[] *
std2 : float[] *
ssp2 : float[,] *
r2 : float[,] *
ifail : int byref -> unit
```

#### Parameters

n
Type: System..::..Int32
On entry: $n$, the number of variables in the input data.
Constraint: ${\mathbf{n}}\ge 2$.
xbar
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: ${\mathbf{xbar}}\left[\mathit{i}-1\right]$ must be set to ${\stackrel{-}{x}}_{\mathit{i}}$, the mean of variable $\mathit{i}$, for $\mathit{i}=1,2,\dots ,n$.
std
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: ${\mathbf{std}}\left[\mathit{i}-1\right]$ must be set to ${s}_{\mathit{i}}$, the standard deviation of variable $\mathit{i}$, for $\mathit{i}=1,2,\dots ,n$.
ssp
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, n]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{n}}$
On entry: ${\mathbf{ssp}}\left[\mathit{i}-1,\mathit{j}-1\right]$ must be set to the sum of cross-products of deviations from means ${S}_{\mathit{i}\mathit{j}}$ (or about zero, ${\stackrel{~}{S}}_{\mathit{i}\mathit{j}}$) for variables $\mathit{i}$ and $\mathit{j}$, for $\mathit{i}=1,2,\dots ,n$ and $\mathit{j}=1,2,\dots ,n$.
r
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, n]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{n}}$
On entry: ${\mathbf{r}}\left[\mathit{i}-1,\mathit{j}-1\right]$ must be set to the Pearson product-moment correlation coefficient ${R}_{\mathit{i}\mathit{j}}$ (or the correlation-like coefficient, ${\stackrel{~}{R}}_{\mathit{i}\mathit{j}}$) for variables $\mathit{i}$ and $\mathit{j}$, for $\mathit{i}=1,2,\dots ,n$ and $\mathit{j}=1,2,\dots ,n$.
m
Type: System..::..Int32
On entry: the number of variables $m$, required in the reduced vectors and matrices.
Constraint: $1\le {\mathbf{m}}\le {\mathbf{n}}$.
korder
Type: array<System..::..Int32>[]()[][]
An array of size [m]
On entry: ${\mathbf{korder}}\left[\mathit{i}-1\right]$ must be set to the number of the original variable which is to be the $\mathit{i}$th variable in the output vectors and matrices, for $\mathit{i}=1,2,\dots ,m$.
Constraint: $1\le {\mathbf{korder}}\left[\mathit{i}\right]\le {\mathbf{n}}$, for $\mathit{i}=0,1,\dots ,m-1$.
xbar2
Type: array<System..::..Double>[]()[][]
An array of size [m]
On exit: the mean of variable $i$, ${\mathbf{xbar}}\left[i-1\right]$, where $i={\mathbf{korder}}\left[\mathit{k}-1\right]$, for $\mathit{k}=1,2,\dots ,m$. (The array xbar2 must differ from xbar and std.)
std2
Type: array<System..::..Double>[]()[][]
An array of size [m]
On exit: the standard deviation of variable $i$, ${\mathbf{std}}\left[i-1\right]$, where $i={\mathbf{korder}}\left[\mathit{k}-1\right]$, for $\mathit{k}=1,2,\dots ,m$. (The array std2 must differ from both xbar and std.)
ssp2
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, m]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{m}}$
On exit: ${\mathbf{ssp2}}\left[\mathit{k}-1,\mathit{l}-1\right]$ contains the value of ${\mathbf{ssp}}\left[i-1,j-1\right]$, where $i={\mathbf{korder}}\left[\mathit{k}-1\right]$ and $j={\mathbf{korder}}\left[\mathit{l}-1\right]$, for $\mathit{k}=1,2,\dots ,m$ and $\mathit{l}=1,2,\dots ,m$. (The array ssp2 must differ from both ssp and r.)
That is to say: on exit, ${\mathbf{ssp2}}\left[k-1,l-1\right]$ contains the sum of cross-products of deviations from means ${S}_{ij}$ (or about zero, ${\stackrel{~}{S}}_{ij}$).
r2
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, m]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{m}}$
On exit: ${\mathbf{r2}}\left[\mathit{k}-1,\mathit{l}-1\right]$ contains the value of ${\mathbf{r}}\left[i-1,j-1\right]$, where $i={\mathbf{korder}}\left[\mathit{k}-1\right]$ and $j={\mathbf{korder}}\left[\mathit{l}-1\right]$, for $\mathit{k}=1,2,\dots ,m$ and $\mathit{l}=1,2,\dots ,m$. (The array r2 must differ from both ssp and r.)
That is to say: on exit, ${\mathbf{r2}}\left[k-1,l-1\right]$ contains the Pearson product-moment coefficient ${R}_{ij}$ (or the correlation-like coefficient, ${\stackrel{~}{R}}_{ij}$).
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

Input to the method consists of:
(a) A vector of means:
 $x-1,x-2,x-3,…,x-n,$
where $n$ is the number of input variables.
(b) A vector of standard deviations:
 $s1,s2,s3,…,sn.$
(c) A matrix of sums of squares and cross-products of deviations from means:
 $S11S12S13...S1nS21S22S2nS31.......Sn1Sn2....Snn.$
(d) A matrix of correlation coefficients:
 $R11R12R13...R1nR21R22R2nR31.......Rn1Rn2....Rnn.$
(e) The number of variables, $m$, in the required subset, and their row/column numbers in the input data, ${i}_{1},{i}_{2},{i}_{3},\dots ,{i}_{m}$,
New vectors and matrices are output containing the following information:
(i) A vector of means:
 $x-i1,x-i2,x-i3,…,x-im.$
(ii) A vector of standard deviations:
 $si1,si2,si3,…,sim.$
(iii) A matrix of sums of squares and cross-products of deviations from means:
 $Si1i1Si1i2Si1i3...Si1imSi2i1Si2i2.Si3i1.......Simi1Simi2....Simim.$
(iv) A matrix of correlation coefficients:
 $Ri1i1Ri1i2Ri1i3...Ri1imRi2i1Ri2i2.Ri3i1.......Rimi1Rimi2....Rimim.$
Note:  for sums of squares of cross-products of deviations about zero and correlation-like coefficients ${S}_{ij}$ and ${R}_{ij}$ should be replaced by ${\stackrel{~}{S}}_{ij}$ and ${\stackrel{~}{R}}_{ij}$ in the description of the input and output above.

None.

# Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDSSP, LDR, LDSSP2, LDR2) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{n}}<2$, or ${\mathbf{m}}<1$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{n}}<{\mathbf{m}}$.
${\mathbf{ifail}}=4$
 On entry, ${\mathbf{korder}}\left[i-1\right]<1$, or ${\mathbf{korder}}\left[i-1\right]>{\mathbf{n}}$ for some $i=1,2,\dots ,m$.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-4000$
Invalid dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

Not applicable.

# Parallelism and Performance

None.

The time taken by g02ce depends on $n$ and $m$.
The method is intended primarily for use when a subset of variables from a larger set of variables is to be used in a regression, and is described accordingly. There is however no reason why the method should not also be used to select specific rows and columns from vectors and arrays which contain any other non-statistical information; the matrices need not be symmetric.
The method may be used either with sums of squares and cross-products of deviations from means and Pearson product-moment correlation coefficients in connection with a regression involving a constant, or with sums of squares and cross-products about zero and correlation-like coefficients in connection with a regression with no constant.

# Example

This example reads in the means, standard deviations, sums of squares and cross-products, and correlation coefficients for four variables. New vectors and matrices are created containing the means, standard deviations, sums of squares and cross-products, and correlation coefficients for the fourth, first and second variables (in that order). Finally these new vectors and matrices are printed.

Example program (C#): g02cee.cs

Example program data: g02cee.d

Example program results: g02cee.r