naginterfaces.library.correg.linregm_stat_resinf¶
- naginterfaces.library.correg.linregm_stat_resinf(n, ip, res, h, rms)[source]¶
linregm_stat_resinf
calculates two types of standardized residuals and two measures of influence for a linear regression.For full information please refer to the NAG Library document for g02fa
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g02/g02faf.html
- Parameters
- nint
, the number of observations included in the regression.
- ipint
, the number of linear parameters estimated in the regression model.
- resfloat, array-like, shape
The residuals, .
- hfloat, array-like, shape
The diagonal elements of , , corresponding to the residuals in .
- rmsfloat
The estimate of based on all observations, , i.e., the residual mean square.
- Returns
- sresfloat, ndarray, shape
The standardized residuals and influence statistics.
For the observation with residual, , given in .
Is the internally standardized residual, .
Is the externally standardized residual, .
Is Cook’s statistic, .
Is Atkinson’s statistic, .
- Raises
- NagValueError
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: , for all .
- (errno )
On entry, a value in is too large for given . and .
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
For the general linear regression model
where
is a vector of length of the dependent variable,
is an matrix of the independent variables,
is a vector of length of unknown parameters,
and
is a vector of length of unknown random errors such that .
The residuals are given by
and the fitted values, , can be written as for an matrix . The th diagonal elements of , , give a measure of the influence of the th values of the independent variables on the fitted regression model. The values of and the are returned by
linregm_fit()
.linregm_stat_resinf
calculates statistics which help to indicate if an observation is extreme and having an undue influence on the fit of the regression model. Two types of standardized residual are calculated:The th residual is standardized by its variance when the estimate of , , is calculated from all the data; this is known as internal Studentization.
The th residual is standardized by its variance when the estimate of , is calculated from the data excluding the th observation; this is known as external Studentization.
The two measures of influence are:
Cook’s
Atkinson’s
- References
Atkinson, A C, 1981, Two graphical displays for outlying and influential observations in regression, Biometrika (68), 13–20
Cook, R D and Weisberg, S, 1982, Residuals and Influence in Regression, Chapman and Hall