hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_correg_linregm_service_select (g02ce)

Purpose

nag_correg_linregm_service_select (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

[xbar2, std2, ssp2, r2, ifail] = g02ce(xbar, std, ssp, r, korder, 'n', n, 'm', m)
[xbar2, std2, ssp2, r2, ifail] = nag_correg_linregm_service_select(xbar, std, ssp, r, korder, 'n', n, 'm', m)

Description

Input to the function consists of:
(a) A vector of means:
(x1,x2,x3,,xn),
(x-1,x-2,x-3,,x-n),
where nn is the number of input variables.
(b) A vector of standard deviations:
(s1,s2,s3,,sn).
(s1,s2,s3,,sn).
(c) A matrix of sums of squares and cross-products of deviations from means:
  S11 S12 S13 . . . S1n S21 S22 S2n S31 . . . . . . . Sn1 Sn2 . . . . Snn  
.
S11 S12 S13 . . . S1n S21 S22 S2n S31 . . . . . . . Sn1 Sn2 . . . . Snn .
(d) A matrix of correlation coefficients:
  R11 R12 R13 . . . R1n R21 R22 R2n R31 . . . . . . . Rn1 Rn2 . . . . Rnn  
.
R11 R12 R13 . . . R1n R21 R22 R2n R31 . . . . . . . Rn1 Rn2 . . . . Rnn .
(e) The number of variables, mm, in the required subset, and their row/column numbers in the input data, i1,i2,i3,,imi1,i2,i3,,im,
iikn  for k = 1,2,,m(n2,m1  and  mn).
iikn  for k=1,2,,m(n2,m1  and  mn).
New vectors and matrices are output containing the following information:
(i) A vector of means:
(xi1,xi2,xi3,,xim).
(x-i1,x-i2,x-i3,,x-im).
(ii) A vector of standard deviations:
(si1,si2,si3,,sim).
(si1,si2,si3,,sim).
(iii) A matrix of sums of squares and cross-products of deviations from means:
  Si_1i_1 Si_1i_2 Si_1i_3 . . . Si_1i_m Si_2i_1 Si_2i_2 . Si_3i_1 . . . . . . . Si_mi_1 Si_mi_2 . . . . Si_mi_m  
.
Si1i1 Si1i2 Si1i3 . . . Si1im Si2i1 Si2i2 . Si3i1 . . . . . . . Simi1 Simi2 . . . . Simim .
(iv) A matrix of correlation coefficients:
  Ri_1i_1 Ri_1i_2 Ri_1i_3 . . . Ri_1i_m Ri_2i_1 Ri_2i_2 . Ri_3i_1 . . . . . . . Ri_mi_1 Ri_mi_2 . . . . Ri_mi_m  
.
Ri1i1 Ri1i2 Ri1i3 . . . Ri1im Ri2i1 Ri2i2 . Ri3i1 . . . . . . . Rimi1 Rimi2 . . . . Rimim .
Note:  for sums of squares of cross-products of deviations about zero and correlation-like coefficients SijSij and RijRij should be replaced by ijS~ij and ijR~ij in the description of the input and output above.

References

None.

Parameters

Compulsory Input Parameters

1:     xbar(n) – double array
n, the dimension of the array, must satisfy the constraint n2n2.
xbar(i)xbari must be set to xix-i, the mean of variable ii, for i = 1,2,,ni=1,2,,n.
2:     std(n) – double array
n, the dimension of the array, must satisfy the constraint n2n2.
std(i)stdi must be set to sisi, the standard deviation of variable ii, for i = 1,2,,ni=1,2,,n.
3:     ssp(ldssp,n) – double array
ldssp, the first dimension of the array, must satisfy the constraint ldsspnldsspn.
ssp(i,j)sspij must be set to the sum of cross-products of deviations from means SijSij (or about zero, ijS~ij) for variables ii and jj, for i = 1,2,,ni=1,2,,n and j = 1,2,,nj=1,2,,n.
4:     r(ldr,n) – double array
ldr, the first dimension of the array, must satisfy the constraint ldrnldrn.
r(i,j)rij must be set to the Pearson product-moment correlation coefficient RijRij (or the correlation-like coefficient, ijR~ij) for variables ii and jj, for i = 1,2,,ni=1,2,,n and j = 1,2,,nj=1,2,,n.
5:     korder(m) – int64int32nag_int array
m, the dimension of the array, must satisfy the constraint 1mn1mn.
korder(i)korderi must be set to the number of the original variable which is to be the iith variable in the output vectors and matrices, for i = 1,2,,mi=1,2,,m.
Constraint: 1korder(i)n1korderin, for i = 1,2,,mi=1,2,,m.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the arrays xbar, std and the first dimension of the arrays ssp, r and the second dimension of the arrays ssp, r. (An error is raised if these dimensions are not equal.)
nn, the number of variables in the input data.
Constraint: n2n2.
2:     m – int64int32nag_int scalar
Default: The dimension of the array korder.
The number of variables mm, required in the reduced vectors and matrices.
Constraint: 1mn1mn.

Input Parameters Omitted from the MATLAB Interface

ldssp ldr ldssp2 ldr2

Output Parameters

1:     xbar2(m) – double array
The mean of variable ii, xbar(i)xbari, where i = korder(k)i=korderk, for k = 1,2,,mk=1,2,,m. (The array xbar2 must differ from xbar and std.)
2:     std2(m) – double array
The standard deviation of variable ii, std(i)stdi, where i = korder(k)i=korderk, for k = 1,2,,mk=1,2,,m. (The array std2 must differ from both xbar and std.)
3:     ssp2(ldssp2,m) – double array
ldssp2mldssp2m.
ssp2(k,l)ssp2kl contains the value of ssp(i,j)sspij, where i = korder(k)i=korderk and j = korder(l)j=korderl, for k = 1,2,,mk=1,2,,m and l = 1,2,,ml=1,2,,m. (The array ssp2 must differ from both ssp and r.)
That is to say: on exit, ssp2(k,l)ssp2kl contains the sum of cross-products of deviations from means SijSij (or about zero, ijS~ij).
4:     r2(ldr2,m) – double array
ldr2mldr2m.
r2(k,l)r2kl contains the value of r(i,j)rij, where i = korder(k)i=korderk and j = korder(l)j=korderl, for k = 1,2,,mk=1,2,,m and l = 1,2,,ml=1,2,,m. (The array r2 must differ from both ssp and r.)
That is to say: on exit, r2(k,l)r2kl contains the Pearson product-moment coefficient RijRij (or the correlation-like coefficient, ijR~ij).
5:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n < 2n<2,
orm < 1m<1.
  ifail = 2ifail=2
On entry,n < mn<m.
  ifail = 3ifail=3
On entry,ldssp < nldssp<n,
orldr < nldr<n,
orldssp < mldssp<m,
orldr2 < mldr2<m.
  ifail = 4ifail=4
On entry,korder(i) < 1korderi<1,
orkorder(i) > nkorderi>n for some i = 1,2,,mi=1,2,,m.

Accuracy

Not applicable.

Further Comments

The time taken by nag_correg_linregm_service_select (g02ce) depends on nn and mm.
The function 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 function 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 function 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

function nag_correg_linregm_service_select_example
xbar = [5.8;
     2.8;
     1.8;
     5.4];
std = [5.0695;
     1.924;
     2.5884;
     4.98];
ssp = [102.8, -29.2, -14.2, -57.6;
     -29.2, 14.8, -6.2, 6.4;
     -14.2, -6.2, 28.6, 42.4;
     -57.6, 6.4, 42.4, 99.2];
r = [1, -0.7486, -0.2619, -0.5704;
     -0.7486, 1, -0.3014, 0.167;
     -0.2619, -0.3014, 1, 0.796;
     -0.5704, 0.167, 0.796, 1];
korder = [int64(4);1;2];
[xbar2, std2, ssp2, r2, ifail] = nag_correg_linregm_service_select(xbar, std, ssp, r, korder)
 

xbar2 =

    5.4000
    5.8000
    2.8000


std2 =

    4.9800
    5.0695
    1.9240


ssp2 =

   99.2000  -57.6000    6.4000
  -57.6000  102.8000  -29.2000
    6.4000  -29.2000   14.8000


r2 =

    1.0000   -0.5704    0.1670
   -0.5704    1.0000   -0.7486
    0.1670   -0.7486    1.0000


ifail =

                    0


function g02ce_example
xbar = [5.8;
     2.8;
     1.8;
     5.4];
std = [5.0695;
     1.924;
     2.5884;
     4.98];
ssp = [102.8, -29.2, -14.2, -57.6;
     -29.2, 14.8, -6.2, 6.4;
     -14.2, -6.2, 28.6, 42.4;
     -57.6, 6.4, 42.4, 99.2];
r = [1, -0.7486, -0.2619, -0.5704;
     -0.7486, 1, -0.3014, 0.167;
     -0.2619, -0.3014, 1, 0.796;
     -0.5704, 0.167, 0.796, 1];
korder = [int64(4);1;2];
[xbar2, std2, ssp2, r2, ifail] = g02ce(xbar, std, ssp, r, korder)
 

xbar2 =

    5.4000
    5.8000
    2.8000


std2 =

    4.9800
    5.0695
    1.9240


ssp2 =

   99.2000  -57.6000    6.4000
  -57.6000  102.8000  -29.2000
    6.4000  -29.2000   14.8000


r2 =

    1.0000   -0.5704    0.1670
   -0.5704    1.0000   -0.7486
    0.1670   -0.7486    1.0000


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013