PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_correg_linregm_service_reorder (g02cf)
Purpose
nag_correg_linregm_service_reorder (g02cf) reorders the elements in two vectors (typically vectors of means and standard deviations), and the rows and columns in 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).
Syntax
[
xbar,
std,
ssp,
r,
ifail] = g02cf(
korder,
xbar,
std,
ssp,
r, 'n',
n)
[
xbar,
std,
ssp,
r,
ifail] = nag_correg_linregm_service_reorder(
korder,
xbar,
std,
ssp,
r, 'n',
n)
Description
Input to the function consists of:
(a) |
A list of the order in which the variables are to be arranged on exit:
|
(b) |
A vector of means:
|
(c) |
A vector of standard deviations:
|
(d) |
A matrix of sums of squares and cross-products of deviations from means:
|
(e) |
A matrix of correlation coefficients:
|
On exit from the function, these same vectors and matrices are reordered, in the manner specified, and contain the following information:
(i) |
The vector of means:
|
(ii) |
The vector of standard deviations:
|
(iii) |
The matrix of sums of squares and cross-products of deviations from means:
|
(iv) |
The matrix of correlation coefficients:
|
Note: for sums of squares of cross-products of deviations about zero and correlation-like coefficients
and
should be replaced by
and
in the description of the input and output above.
References
None.
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int array
-
must be set to the number of the original variable which is to be the th variable in the re-arranged data, for .
Constraint:
, for .
- 2:
– double array
-
must be set to the mean of variable , for .
- 3:
– double array
-
must be set to the standard deviation of variable , for .
- 4:
– double array
-
ldssp, the first dimension of the array, must satisfy the constraint
.
must be set to the sum of cross-products of deviations from means (or about zero ) for variables and , for and .
- 5:
– double array
-
ldr, the first dimension of the array, must satisfy the constraint
.
must be set to the Pearson product-moment correlation coefficient (or the correlation-like coefficient ) for variables and , for and .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
korder,
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.)
, the number of variables in the input data.
Constraint:
.
Output Parameters
- 1:
– double array
-
contains the mean of variable where , for .
- 2:
– double array
-
contains the standard deviation of variable where , for .
- 3:
– double array
-
contains the sum of cross-products of deviations from means (or about zero ) for variables and , where , and , .
- 4:
– double array
-
contains the Pearson product-moment correlation coefficient (or the correlation-like coefficient ) for variables and , where and , for and .
- 5:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
-
-
On entry, | , |
or | . |
-
-
On entry, | , |
or | for some . |
-
-
On entry, there is not a one-to-one correspondence between the old variables and the new variables; at least one of the original variables is not included in the new set, and consequently at least one other variable has been included more than once.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Not applicable.
Further Comments
The time taken by nag_correg_linregm_service_reorder (g02cf) depends on and the amount of re-arrangement involved.
The function is intended primarily for use when a set of variables is to be reordered for use in a regression, and is described accordingly. There is however no reason why the function should not also be used to reorder vectors and matrices 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
This example reads in the means, standard deviations, sums of squares and cross-products, and correlation coefficients for three variables. The vectors and matrices are reordered so that they contain the means, standard deviations, sums of squares and cross-products, and correlation coefficients for the first, third and second variables (in that order). Finally the reordered vectors and matrices are printed.
Open in the MATLAB editor:
g02cf_example
function g02cf_example
fprintf('g02cf example results\n\n');
xbar = [ 5.4; 5.8; 2.8];
std = [ 4.98; 5.0695; 1.924 ];
ssp = [ 99.2, -57.6, 6.4;
-57.6, 102.8, -29.2;
6.4, -29.2, 14.8 ];
r = [ 1, -0.5704, 0.167;
-0.5704, 1, -0.7486;
0.167, -0.7486, 1 ];
korder = [int64(1); 3; 2];
fprintf('Original vector xbar : ');
fprintf(' %10.4f', xbar);
fprintf('\n\nOriginal vector std : ');
fprintf(' %10.4f', std);
fprintf('\n\n');
disp('Original matrix SSP :');
disp(ssp);
disp('Original matrix R :');
disp(r);
[xbar, std, ssp, r, ifail] = g02cf( ...
korder, xbar, std, ssp, r);
fprintf('New vector xbar : ');
fprintf(' %10.4f', xbar);
fprintf('\n\nNew vector std : ');
fprintf(' %10.4f', std);
fprintf('\n\n');
disp('New matrix ssp :');
disp(ssp);
disp('New matrix r :');
disp(r);
g02cf example results
Original vector xbar : 5.4000 5.8000 2.8000
Original vector std : 4.9800 5.0695 1.9240
Original matrix SSP :
99.2000 -57.6000 6.4000
-57.6000 102.8000 -29.2000
6.4000 -29.2000 14.8000
Original matrix R :
1.0000 -0.5704 0.1670
-0.5704 1.0000 -0.7486
0.1670 -0.7486 1.0000
New vector xbar : 5.4000 2.8000 5.8000
New vector std : 4.9800 1.9240 5.0695
New matrix ssp :
99.2000 6.4000 -57.6000
6.4000 14.8000 -29.2000
-57.6000 -29.2000 102.8000
New matrix r :
1.0000 0.1670 -0.5704
0.1670 1.0000 -0.7486
-0.5704 -0.7486 1.0000
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015