naginterfaces.library.correg.linregm_​coeffs_​const

naginterfaces.library.correg.linregm_coeffs_const(n, xbar, ssp, r)[source]

linregm_coeffs_const performs a multiple linear regression on a set of variables whose means, sums of squares and cross-products of deviations from means, and Pearson product-moment correlation coefficients are given.

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

https://www.nag.com/numeric/nl/nagdoc_27.1/flhtml/g02/g02cgf.html

Parameters
nint

The number of cases , used in calculating the sums of squares and cross-products and correlation coefficients.

xbarfloat, array-like, shape

must be set to , the mean value of the th variable, for ; the mean of the dependent variable must be contained in .

sspfloat, array-like, shape

must be set to , the sum of cross-products of deviations from means for the th and th variables, for , for ; terms involving the dependent variable appear in row and column .

rfloat, array-like, shape

must be set to , the Pearson product-moment correlation coefficient for the th and th variables, for , for ; terms involving the dependent variable appear in row and column .

Returns
resultfloat, ndarray, shape

The following information:

, the sum of squares attributable to the regression;

, the degrees of freedom attributable to the regression;

, the mean square attributable to the regression;

, the value for the analysis of variance;

, the sum of squares of deviations about the regression;

, the degrees of freedom of deviations about the regression;

, the mean square of deviations about the regression;

, the total sum of squares;

, the total degrees of freedom;

, the standard error estimate;

, the coefficient of multiple correlation;

, the coefficient of multiple determination;

, the coefficient of multiple determination corrected for the degrees of freedom.

coeffloat, ndarray, shape

For , the following information:

, the regression coefficient for the th variable.

, the standard error of the regression coefficient for the th variable.

, the value of the regression coefficient for the th variable.

confloat, ndarray, shape

The following information:

, the regression constant;

, the standard error of the regression constant;

, the value for the regression constant.

rinvfloat, ndarray, shape

The inverse of the matrix of correlation coefficients for the independent variables; that is, the inverse of the matrix consisting of the first rows and columns of .

cfloat, ndarray, shape

The modified inverse matrix, where

, for , for .

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

The by partition of which requires inversion is not positive definite.

(errno )

The refinement following inversion has failed.

Notes

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

linregm_coeffs_const fits a curve of the form

to the data points

such that

The function calculates the regression coefficients, , the regression constant, , and various other statistical quantities by minimizing

The actual data values are not provided as input to the function. Instead, input consists of:

  1. The number of cases, , on which the regression is based.

  2. The total number of variables, dependent and independent, in the regression, .

  3. The number of independent variables in the regression, .

  4. The means of all variables in the regression, both the independent variables and the dependent variable , which is the th variable: i.e., .

  5. The matrix [] of sums of squares and cross-products of deviations from means of all the variables in the regression; the terms involving the dependent variable, , appear in the th row and column.

  6. The matrix [] of the Pearson product-moment correlation coefficients for all the variables in the regression; the correlations involving the dependent variable, , appear in the th row and column.

The quantities calculated are:

  1. The inverse of the partition of the matrix of correlation coefficients, [], involving only the independent variables. The inverse is obtained using an accurate method which assumes that this sub-matrix is positive definite.

  2. The modified inverse matrix, , where

    where is the th element of the inverse matrix of [] as described in (a) above. Each element of is thus the corresponding element of the matrix of correlation coefficients multiplied by the corresponding element of the inverse of this matrix, divided by the corresponding element of the matrix of sums of squares and cross-products of deviations from means.

  3. The regression coefficients:

    where is the sum of cross-products of deviations from means for the independent variable and the dependent variable .

  4. The sum of squares attributable to the regression, , the sum of squares of deviations about the regression, , and the total sum of squares, :

    , the sum of squares of deviations from the mean for the dependent variable, ;

  5. The degrees of freedom attributable to the regression, , the degrees of freedom of deviations about the regression, , and the total degrees of freedom, :

  6. The mean square attributable to the regression, , and the mean square of deviations about the regression, :

  7. The values for the analysis of variance:

  8. The standard error estimate:

  9. The coefficient of multiple correlation, , the coefficient of multiple determination, and the coefficient of multiple determination corrected for the degrees of freedom, ;

  10. The standard error of the regression coefficients:

  11. The values for the regression coefficients:

  12. The regression constant, , its standard error, , and its value, :

References

Draper, N R and Smith, H, 1985, Applied Regression Analysis, (2nd Edition), Wiley