The function may be called by the names: g02gcc, nag_correg_glm_poisson or nag_glm_poisson.
A generalized linear model with Poisson errors consists of the following elements:
(a)a set of observations, , from a Poisson distribution:
(b), a set of independent variables for each observation, .
(c)a linear model:
(d)a link between the linear predictor, , and the mean of the distribution, , . The possible link functions are:
(i)exponent link: , for a constant ,
(ii)identity link: ,
(iii)log link: ,
(iv)square root link: ,
(e)reciprocal link: .
(f)a measure of fit, the deviance:
The linear arguments are estimated by iterative weighted least squares. An adjusted dependent variable, , is formed:
and a working weight, ,
At each iteration an approximation to the estimate of , is found by the weighted least squares regression of on with weights .
g02gcc finds a decomposition of , i.e., where is a triangular matrix and is an column orthogonal matrix.
If is of full rank then is the solution to:
If is not of full rank a solution is obtained by means of a singular value decomposition (SVD) of .
where is a diagonal matrix with nonzero diagonal elements, being the rank of and .
This gives the solution
being the first columns of , i.e., .
The iterations are continued until there is only a small change in the deviance.
The initial values for the algorithm are obtained by taking
The fit of the model can be assessed by examining and testing the deviance, in particular, by comparing the difference in deviance between nested models, i.e., when one model is a sub-model of the other. The difference in deviance between two nested models has, asymptotically, a distribution with degrees of freedom given by the difference in the degrees of freedom associated with the two deviances.
The arguments estimates, , are asymptotically Normally distributed with variance-covariance matrix:
in the full rank case, otherwise
The residuals and influence statistics can also be examined.
The estimated linear predictor , 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. These are known as leverages.
The fitted values are given by .
g02gcc also computes the deviance residuals, :
An option allows prior weights to be used with the model.
In many linear regression models the first term is taken as a mean term or an intercept, i.e., , for . This is provided as an option.
Often only some of the possible independent variables are included in a model; the facility to select variables to be included in the model is provided.
If part of the linear predictor can be represented by a variable with a known coefficient then this can be included in the model by using an offset, :
If the model is not of full rank the solution given will be only one of the possible solutions. Other estimates be may be obtained by applying constraints to the arguments. These solutions can be obtained by using g02gkc after using g02gcc.
Only certain linear combinations of the arguments will have unique estimates, these are known as estimable functions, these can be estimated and tested using g02gnc.
Details of the SVD, are made available, in the form of the matrix :
On exit: the degrees of freedom associated with the deviance for the fitted model.
15: – doubleOutput
On exit: the estimates of the arguments of the generalized linear model, .
If , then will contain the estimate of the mean argument and will contain the coefficient of the variable contained in column of x, where is the th positive value in the array sx.
If , then will contain the coefficient of the variable contained in column of x, where is the th positive value in the array sx.
16: – Integer *Output
On exit: the rank of the independent variables.
If the model is of full rank, then .
If the model is not of full rank, then rank is an estimate of the rank of the independent variables. rank is calculated as the number of singular values greater than (largest singular value). It is possible for the SVD to be carried out but rank to be returned as ip.
17: – doubleOutput
On exit: the standard errors of the linear arguments.
contains the standard error of the parameter estimate in , for .
18: – doubleOutput
On exit: the elements of cov contain the upper triangular part of the variance-covariance matrix of the ip parameter estimates given in b. 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 , for and .
19: – doubleOutput
On exit: auxiliary information on the fitted model.
, contains the linear predictor value, , for .
, contains the fitted value, , for .
, contains the variance standardization, , for .
, contains the working weight, , for .
, contains the deviance residual, , for .
, contains the leverage, , for .
, for , contains the results of the decomposition or the singular value decomposition.
If the model is not of full rank, i.e., , then the first ip rows of columns to contain the matrix.
20: – IntegerInput
On entry: the stride separating matrix column elements in the array v.
21: – doubleInput
On entry: indicates the accuracy required for the fit of the model.
The iterative weighted least squares procedure is deemed to have converged if the absolute change in deviance between interactions is less than (1.0+Current Deviance). This is approximately an absolute precision if the deviance is small and a relative precision if the deviance is large.
If machine precision, then the function will use machine precision.
22: – IntegerInput
On entry: the maximum number of iterations for the iterative weighted least squares.
If , then a default value of 10 is used.
23: – IntegerInput
On entry: indicates if the printing of information on the iterations is required and the rate at which printing is produced.
There is no printing.
The following items are printed every print_iter iterations:
(ii)the current estimates, and
(iii)if the weighted least squares equations are singular then this is indicated.
24: – const char *Input
On entry: a null terminated character string giving the name of the file to which results should be printed. If outfile is NULL or an empty string then the stdout stream is used. Note that the file will be opened in the append mode.
25: – doubleInput
On entry: the value of eps is used to decide if the independent variables are of full rank and, if not, what the rank of the independent variables is. The smaller the value of eps the stricter the criterion for selecting the singular value decomposition.
If machine precision, then the function will use machine precision instead.
26: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
The iterative weighted least squares has failed to converge in iterations. The value of max_iter could be increased but it may be advantageous to examine the convergence using the print_iter option. This may indicate that the convergence is slow because the solution is at a boundary in which case it may be better to reformulate the model.
Cannot open file for appending.
Cannot close file .
The rank of the model has changed during the weighted least squares iterations. The estimate for returned may be reasonable, but you should check how the deviance has changed during iterations.
The singular value decomposition has failed to converge.
A fitted value is at a boundary, i.e., . This may occur if there are values of and the model is too complex for the data. The model should be reformulated with, perhaps, some observations dropped.
The degrees of freedom for error are . A saturated model has been fitted.
The accuracy is determined by tol as described in Section 5. As the adjusted deviance is a function of the accuracy of the 's will be a function of tol. tol should, therefore, be set to a smaller value than the accuracy required for .
8Parallelism and Performance
g02gcc is not threaded in any implementation.
A 3 by 5 contingency table given by Plackett (1974) is analysed by fitting terms for rows and columns. The table is: