naginterfaces.library.correg.coeffs_​pearson_​subset_​miss_​pair

naginterfaces.library.correg.coeffs_pearson_subset_miss_pair(x, miss, xmiss, kvar)[source]

coeffs_pearson_subset_miss_pair computes means and standard deviations, sums of squares and cross-products of deviations from means, and Pearson product-moment correlation coefficients for selected variables omitting cases with missing values from only those calculations involving the variables for which the values are missing.

For full information please refer to the NAG Library document for g02bj

https://www.nag.com/numeric/nl/nagdoc_29.3/flhtml/g02/g02bjf.html

Parameters
xfloat, array-like, shape

must be set to , the value of the th observation on the th variable, for , for .

missint, array-like, shape

must be set equal to if a missing value, , is to be specified for the th variable in the array , or set equal to otherwise. Values of must be given for all variables in the array .

xmissfloat, array-like, shape

must be set to the missing value, , to be associated with the th variable in the array , for those variables for which missing values are specified by means of the array (see Accuracy).

kvarint, array-like, shape

must be set to the column number in of the th variable for which information is required, for .

Returns
xbarfloat, ndarray, shape

The mean value, , of the variable specified in , for .

stdfloat, ndarray, shape

The standard deviation, , of the variable specified in , for .

sspfloat, ndarray, shape

is the cross-product of deviations, , for the variables specified in and , for , for .

rfloat, ndarray, shape

is the product-moment correlation coefficient, , between the variables specified in and , for , for .

ncasesint

The minimum number of cases used in the calculation of any of the sums of squares and cross-products and correlation coefficients (when cases involving missing values have been eliminated).

cntfloat, ndarray, shape

is the number of cases, , actually used in the calculation of , and , the sum of cross-products and correlation coefficient for the variables specified in and , for , for .

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: and .

(errno )

On entry, , and .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )

After observations with missing values were omitted, fewer than two cases remained.

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

The input data consists of observations for each of variables, given as an array

where is the th observation on the th variable, together with the subset of these variables, , for which information is required.

In addition, each of the variables may optionally have associated with it a value which is to be considered as representing a missing observation for that variable; the missing value for the th variable is denoted by . Missing values need not be specified for all variables.

Let if the th observation for the th variable is a missing value, i.e., if a missing value, , has been declared for the th variable, and (see also Accuracy); and otherwise, for , for .

The quantities calculated are:

  1. Means:

  2. Standard deviations:

  3. Sums of squares and cross-products of deviations from means:

    where

    (i.e., the means used in the calculation of the sum of squares and cross-products of deviations are based on the same set of observations as are the cross-products).

  4. Pearson product-moment correlation coefficients:

    where

    (i.e., the sums of squares of deviations used in the denominator are based on the same set of observations as are used in the calculation of the numerator).

    If or is zero, is set to zero.

  5. The number of cases used in the calculation of each of the correlation coefficients:

    (The diagonal terms, , for , also give the number of cases used in the calculation of the means, , and the standard deviations, .)