| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/glm.R |
| 3 |
\name{vcovCR.glm} |
| 4 |
\alias{vcovCR.glm} |
| 5 |
\title{Cluster-robust variance-covariance matrix for a glm object.} |
| 6 |
\usage{ |
| 7 |
\method{vcovCR}{glm}( |
| 8 |
obj, |
| 9 |
cluster, |
| 10 |
type, |
| 11 |
target = NULL, |
| 12 |
inverse_var = NULL, |
| 13 |
form = "sandwich", |
| 14 |
... |
| 15 |
) |
| 16 |
} |
| 17 |
\arguments{ |
| 18 |
\item{obj}{Fitted model for which to calculate the variance-covariance matrix} |
| 19 |
|
| 20 |
\item{cluster}{Expression or vector indicating which observations belong to |
| 21 |
the same cluster. Required for \code{glm} objects.} |
| 22 |
|
| 23 |
\item{type}{Character string specifying which small-sample adjustment should |
| 24 |
be used, with available options \code{"CR0"}, \code{"CR1"}, \code{"CR1p"}, |
| 25 |
\code{"CR1S"}, \code{"CR2"}, or \code{"CR3"}. See "Details" section of |
| 26 |
\code{\link{vcovCR}} for further information.} |
| 27 |
|
| 28 |
\item{target}{Optional matrix or vector describing the working |
| 29 |
variance-covariance model used to calculate the \code{CR2} and \code{CR4} |
| 30 |
adjustment matrices. If a vector, the target matrix is assumed to be |
| 31 |
diagonal. If not specified, the target is taken to be the estimated variance function.} |
| 32 |
|
| 33 |
\item{inverse_var}{Optional logical indicating whether the weights used in |
| 34 |
fitting the model are inverse-variance. If not specified, \code{vcovCR} |
| 35 |
will attempt to infer a value.} |
| 36 |
|
| 37 |
\item{form}{Controls the form of the returned matrix. The default |
| 38 |
\code{"sandwich"} will return the sandwich variance-covariance matrix. |
| 39 |
Alternately, setting \code{form = "meat"} will return only the meat of the |
| 40 |
sandwich and setting \code{form = B}, where \code{B} is a matrix of |
| 41 |
appropriate dimension, will return the sandwich variance-covariance matrix |
| 42 |
calculated using \code{B} as the bread. \code{form = "estfun"} will return the |
| 43 |
(appropriately scaled) estimating function, the transposed crossproduct of |
| 44 |
which is equal to the sandwich variance-covariance matrix.} |
| 45 |
|
| 46 |
\item{...}{Additional arguments available for some classes of objects.} |
| 47 |
} |
| 48 |
\value{ |
| 49 |
An object of class \code{c("vcovCR","clubSandwich")}, which consists |
| 50 |
of a matrix of the estimated variance of and covariances between the |
| 51 |
regression coefficient estimates. |
| 52 |
} |
| 53 |
\description{ |
| 54 |
\code{vcovCR} returns a sandwich estimate of the variance-covariance matrix |
| 55 |
of a set of regression coefficient estimates from an \code{\link{glm}} object. |
| 56 |
} |
| 57 |
\examples{ |
| 58 |
|
| 59 |
if (requireNamespace("geepack", quietly = TRUE)) { |
| 60 |
|
| 61 |
data(dietox, package = "geepack") |
| 62 |
dietox$Cu <- as.factor(dietox$Cu) |
| 63 |
weight_fit <- glm(Weight ~ Cu * poly(Time, 3), data=dietox, family = "quasipoisson") |
| 64 |
V_CR <- vcovCR(weight_fit, cluster = dietox$Pig, type = "CR2") |
| 65 |
coef_test(weight_fit, vcov = V_CR, test = "Satterthwaite") |
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
} |
| 70 |
\seealso{ |
| 71 |
\code{\link{vcovCR}} |
| 72 |
} |