NAG FL Interface
g02cef (linregm_service_select)
1
Purpose
g02cef 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.
2
Specification
Fortran Interface
Subroutine g02cef ( |
n, xbar, std, ssp, ldssp, r, ldr, m, korder, xbar2, std2, ssp2, ldssp2, r2, ldr2, ifail) |
Integer, Intent (In) |
:: |
n, ldssp, ldr, m, korder(m), ldssp2, ldr2 |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
xbar(n), std(n), ssp(ldssp,n), r(ldr,n) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
ssp2(ldssp2,m), r2(ldr2,m) |
Real (Kind=nag_wp), Intent (Out) |
:: |
xbar2(m), std2(m) |
|
C Header Interface
#include <nag.h>
void |
g02cef_ (const Integer *n, const double xbar[], const double std[], const double ssp[], const Integer *ldssp, const double r[], const Integer *ldr, const Integer *m, const Integer korder[], double xbar2[], double std2[], double ssp2[], const Integer *ldssp2, double r2[], const Integer *ldr2, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g02cef_ (const Integer &n, const double xbar[], const double std[], const double ssp[], const Integer &ldssp, const double r[], const Integer &ldr, const Integer &m, const Integer korder[], double xbar2[], double std2[], double ssp2[], const Integer &ldssp2, double r2[], const Integer &ldr2, Integer &ifail) |
}
|
The routine may be called by the names g02cef or nagf_correg_linregm_service_select.
3
Description
Input to the routine consists of:
-
(a)A vector of means:
where is the number of input variables.
-
(b)A vector of standard deviations:
-
(c)A matrix of sums of squares and cross-products of deviations from means:
-
(d)A matrix of correlation coefficients:
-
(e)The number of variables, , in the required subset, and their row/column numbers in the input data, ,
New vectors and matrices are output containing the following information:
-
(i)A vector of means:
-
(ii)A vector of standard deviations:
-
(iii)A matrix of sums of squares and cross-products of deviations from means:
-
(iv)A 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.
4
References
None.
5
Arguments
-
1:
– Integer
Input
-
On entry: , the number of variables in the input data.
Constraint:
.
-
2:
– Real (Kind=nag_wp) array
Input
-
On entry: must be set to , the mean of variable , for .
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: must be set to , the standard deviation of variable , for .
-
4:
– Real (Kind=nag_wp) array
Input
-
On entry: must be set to the sum of cross-products of deviations from means (or about zero, ) for variables and , for and .
-
5:
– Integer
Input
-
On entry: the first dimension of the array
ssp as declared in the (sub)program from which
g02cef is called.
Constraint:
.
-
6:
– Real (Kind=nag_wp) array
Input
-
On entry: must be set to the Pearson product-moment correlation coefficient (or the correlation-like coefficient, ) for variables and , for and .
-
7:
– Integer
Input
-
On entry: the first dimension of the array
r as declared in the (sub)program from which
g02cef is called.
Constraint:
.
-
8:
– Integer
Input
-
On entry: the number of variables , required in the reduced vectors and matrices.
Constraint:
.
-
9:
– Integer array
Input
-
On entry: must be set to the number of the original variable which is to be the th variable in the output vectors and matrices, for .
Constraint:
, for .
-
10:
– Real (Kind=nag_wp) array
Output
-
On exit: the mean of variable
,
, where
, for
. (The array
xbar2 must differ from
xbar and
std.)
-
11:
– Real (Kind=nag_wp) array
Output
-
On exit: the standard deviation of variable
,
, where
, for
. (The array
std2 must differ from both
xbar and
std.)
-
12:
– Real (Kind=nag_wp) array
Output
-
On exit:
contains the value of
, where
and
, for
and
. (The array
ssp2 must differ from both
ssp and
r.)
That is to say: on exit, contains the sum of cross-products of deviations from means (or about zero, ).
-
13:
– Integer
Input
-
On entry: the first dimension of the array
ssp2 as declared in the (sub)program from which
g02cef is called.
Constraint:
.
-
14:
– Real (Kind=nag_wp) array
Output
-
On exit:
contains the value of
, where
and
, for
and
. (The array
r2 must differ from both
ssp and
r.)
That is to say: on exit, contains the Pearson product-moment coefficient (or the correlation-like coefficient, ).
-
15:
– Integer
Input
-
On entry: the first dimension of the array
r2 as declared in the (sub)program from which
g02cef is called.
Constraint:
.
-
16:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
On entry, .
Constraint: .
-
On entry, and .
Constratint: .
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
-
On entry, and .
Constraint: , for .
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
Not applicable.
8
Parallelism and Performance
g02cef is not threaded in any implementation.
The time taken by g02cef depends on and .
The routine 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 routine 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 routine 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.
10
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.
10.1
Program Text
10.2
Program Data
10.3
Program Results