The function may be called by the names: g02gac, nag_correg_glm_normal or nag_glm_normal.
A generalized linear model with Normal errors consists of the following elements:
(a)a set of observations, , from a Normal distribution with probability density function:
where is the mean and is the variance.
(b), a set of independent variables for each observation, .
(c)a linear model:
a link between the linear predictor, , and the mean of the distribution, , i.e., . The possible link functions are:
(i)exponent link: , for a constant ,
(ii)identity link: ,
(iii)log link: ,
(iv)square root link: ,
(v)reciprocal link: .
(e)a measure of fit, the residual sum of squares
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 .
g02gac finds a decomposition of , i.e.,
where is a triangular matrix and is a 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 D 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 residual sum of squares.
The initial values for the algorithm are obtained by taking
The fit of the model can be assessed by examining and testing the residual sum of squares, in particular comparing the difference in residual sums of squares between nested models, i.e., when one model is a sub-model of the other.
Let be the residual sum of squares for the full model with degrees of freedom and let be the residual sum of squares for the sub-model with degrees of freedom then:
has, approximately, a -distribution with , degrees of freedom.
The parameter 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 sometimes known as leverages.
The fitted values are given by .
g02gac also computes the residuals, :
An option allows prior weights, to be used, this gives a model with:
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 g02gac. Only certain linear combinations of the arguments will have unique estimates; these are known as estimable functions and can be estimated and tested using g02gnc.
Details of the SVD, are made available, in the form of the matrix :
Cook R D and Weisberg S (1982) Residuals and Influence in Regression Chapman and Hall
McCullagh P and Nelder J A (1983) Generalized Linear Models Chapman and Hall
1: – Nag_LinkInput
On entry: indicates which link function is to be used.
An exponent link is used.
An identity link is used. You are advised not to use g02gac with an identity link as g02dac provides a more efficient way of fitting such a model.
A log link is used.
A square root link is used.
A reciprocal link is used.
, , , or .
2: – Nag_IncludeMeanInput
On entry: indicates if a mean term is to be included.
A mean term, (intercept), will be included in the model.
The model will pass through the origin, zero point.
3: – IntegerInput
On entry: the number of observations, .
4: – const doubleInput
On entry: must contain the th observation for the th independent variable, for and .
5: – IntegerInput
On entry: the stride separating matrix column elements in the array x.
6: – IntegerInput
On entry: the total number of independent variables.
7: – const IntegerInput
On entry: indicates which independent variables are to be included in the model. If , then the variable contained in the th column of x is included in the regression model.
On exit: the residual sum of squares for the fitted model.
15: – double *Output
On exit: the degrees of freedom associated with the residual sum of squares for the fitted model.
16: – doubleOutput
On exit: , contains 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.
17: – 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.
18: – doubleOutput
On exit: the standard errors of the linear arguments.
contains the standard error of the parameter estimate in , for .
19: – 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 .
20: – doubleOutput
On exit: auxiliary information on the fitted model.
, contains the linear predictor value, , for .
, contains the fitted value, , for .
, is only included for consistency with other functions. , for .
, contains the working weight, , for .
, contains the standardized 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.
21: – IntegerInput
On entry: the stride separating matrix column elements in the array v.
22: – 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 residual sum of squares). This is approximately an absolute precision if the residual sum of squares is small and a relative precision if the residual sum of squares is large.
If machine precision, then the function will use machine precision.
23: – IntegerInput
On entry: the maximum number of iterations for the iterative weighted least squares. If , then a default value of 10 is used.
24: – IntegerInput
On entry: indicates if the printing of information on the iterations is required and the rate at which printing is produced. The following values are available:
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.
25: – 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.
26: – 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.
27: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
Parameter ip is greater than the effective number of observations.
Parameter ip is incompatible with arguments mean and sx.
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. This will only occur with , or . This may occur if there are small values of and the model is not suitable 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 residual sum of squares is a function of the accuracy of the 's will depend on the link used and may be of the order .