naginterfaces.library.correg.glm_constrain¶
- naginterfaces.library.correg.glm_constrain(v, c, b, s)[source]¶
glm_constrain
calculates the estimates of the parameters of a generalized linear model for given constraints from the singular value decomposition results.For full information please refer to the NAG Library document for g02gk
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g02/g02gkf.html
- Parameters
- vfloat, array-like, shape
The array as returned by
glm_normal()
,glm_binomial()
,glm_poisson()
orglm_gamma()
.- cfloat, array-like, shape
Contains the constraints stored by column, i.e., the th constraint is stored in the th column of .
- bfloat, array-like, shape
The parameter estimates computed by using the singular value decomposition, .
- sfloat
The estimate of the scale parameter.
For results from
glm_normal()
andglm_gamma()
then is the scale parameter for the model.For results from
glm_binomial()
andglm_poisson()
then should be set to .
- Returns
- bfloat, ndarray, shape
The parameter estimates of the parameters with the constraints imposed, .
- sefloat, ndarray, shape
The standard error of the parameter estimates in .
- covfloat, ndarray, shape
The upper triangular part of the variance-covariance matrix of the parameter estimates given in . They are stored packed by column, i.e., the covariance between the parameter estimate given in and the parameter estimate given in , , is stored in .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
does not give a model of full rank.
- 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.
glm_constrain
computes the estimates given a set of linear constraints for a generalized linear model which is not of full rank. It is intended for use after a call toglm_normal()
,glm_binomial()
,glm_poisson()
orglm_gamma()
.In the case of a model not of full rank the functions use a singular value decomposition to find the parameter estimates, , and their variance-covariance matrix. Details of the SVD are made available in the form of the matrix :
as described by
glm_normal()
,glm_binomial()
,glm_poisson()
andglm_gamma()
. Alternative solutions can be formed by imposing constraints on the parameters. If there are parameters and the rank of the model is then constraints will have to be imposed to obtain a unique solution.Let be a matrix of constraints, such that
then the new parameter estimates are given by:
and the variance-covariance matrix is given by
provided exists.
- References
Golub, G H and Van Loan, C F, 1996, Matrix Computations, (3rd Edition), Johns Hopkins University Press, Baltimore
McCullagh, P and Nelder, J A, 1983, Generalized Linear Models, Chapman and Hall
Searle, S R, 1971, Linear Models, Wiley