gnm (version 1.1-0)

vcov.gnm: 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 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.

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.

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.

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

Run this code
# NOT RUN {
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
# }

Run the code above in your browser using DataCamp Workspace