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://support.nag.com/numeric/nl/nagdoc_30.2/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 formto 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:
The number of cases, , on which the regression is based.
The total number of variables, dependent and independent, in the regression, .
The number of independent variables in the regression, .
The means of all variables in the regression, both the independent variables and the dependent variable , which is the th variable: i.e., .
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.
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:
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.
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.
The regression coefficients:
where is the sum of cross-products of deviations from means for the independent variable and the dependent variable .
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, ;
The degrees of freedom attributable to the regression, , the degrees of freedom of deviations about the regression, , and the total degrees of freedom, :
The mean square attributable to the regression, , and the mean square of deviations about the regression, :
The values for the analysis of variance:
The standard error estimate:
The coefficient of multiple correlation, , the coefficient of multiple determination, and the coefficient of multiple determination corrected for the degrees of freedom, ;
The standard error of the regression coefficients:
The values for the regression coefficients:
The regression constant, , its standard error, , and its value, :
- References
Draper, N R and Smith, H, 1985, Applied Regression Analysis, (2nd Edition), Wiley