vcov.gnm: Variance-covariance Matrix for Parameters in a Generalized...

View source: R/vcov.gnm.R

vcov.gnmR Documentation

Variance-covariance Matrix for Parameters in a Generalized Nonlinear Model

Description

This method extracts or computes a variance-covariance matrix for use in approximate inference on estimable parameter combinations in a generalized nonlinear model.

Usage

## S3 method for class 'gnm'
vcov(object, dispersion = NULL, with.eliminate = FALSE, ...)

Arguments

object

a model object of class gnm.

dispersion

the dispersion parameter for the fitting family. By default it is obtained from object.

with.eliminate

logical; should parts of the variance-covariance matrix corresponding to eliminated coefficients be computed?

...

as for vcov.

Details

The resultant matrix does not itself necessarily contain variances and covariances, since gnm typically works with over-parameterized model representations in which parameters are not all identified. Rather, the resultant matrix is to be used as the kernel of quadratic forms which are the variances or covariances for estimable parameter combinations.

The matrix values are scaled by dispersion. If the dispersion is not specified, it is taken as 1 for the binomial and Poisson families, and otherwise estimated by the residual Chi-squared statistic divided by the residual degrees of freedom. The dispersion used is returned as an attribute of the matrix.

The dimensions of the matrix correspond to the non-eliminated coefficients of the "gnm" object. If use.eliminate = TRUE then setting can sometimes give appreciable speed gains; see gnm for details of the eliminate mechanism. The use.eliminate argument is currently ignored if the model has full rank.

Value

A matrix with number of rows/columns equal to length(coef(object)). If there are eliminated coefficients and use.eliminate = TRUE, the matrix will have the following attributes:

covElim

a matrix of covariances between the eliminated and non-eliminated parameters.

varElim

a vector of variances corresponding to the eliminated parameters.

Note

The gnm class includes generalized linear models, and it should be noted that the behaviour of vcov.gnm differs from that of vcov.glm whenever any(is.na(coef(object))) is TRUE. Whereas vcov.glm drops all rows and columns which correspond to NA values in coef(object), vcov.gnm keeps those columns (which are full of zeros, since the NA represents a parameter which is fixed either by use of the constrain argument to gnm or by a convention to handle linear aliasing).

Author(s)

David Firth

References

Turner, H and Firth, D (2005). Generalized nonlinear models in R: An overview of the gnm package. At https://cran.r-project.org

See Also

getContrasts, se.gnm

Examples

set.seed(1)
## Fit the "UNIDIFF" mobility model across education levels
unidiff <- gnm(Freq ~ educ*orig + educ*dest +
               Mult(Exp(educ), orig:dest), family = poisson,
               data = yaish, subset = (dest != 7))
## Examine the education multipliers (differences on the log scale):
ind <- pickCoef(unidiff, "[.]educ")
educMultipliers <- getContrasts(unidiff, rev(ind))
## Now get the same standard errors using a suitable set of
## quadratic forms, by calling vcov() directly:
cmat <- contr.sum(ind)
sterrs <- sqrt(diag(t(cmat)
                    %*% vcov(unidiff)[ind, ind]
                    %*% cmat))
all(sterrs == (educMultipliers$SE)[-1]) ## TRUE

gnm documentation built on Sept. 16, 2023, 5:06 p.m.