vcov: Calculate variance-covariance matrix for marginal effects

vcovR Documentation

Calculate variance-covariance matrix for marginal effects


Returns the variance-covariance matrix for the predicted values from object.


## S3 method for class 'ggeffects'
vcov(object, = NULL, vcov.type = NULL, vcov.args = NULL, ...)



An object of class "ggeffects", as returned by ggpredict().

String, indicating the name of the vcov*()-function from the sandwich or clubSandwich-package, e.g. = "vcovCL", which is used to compute (cluster) robust standard errors for predictions. If NULL, standard errors (and confidence intervals) for predictions are based on the standard errors as returned by the predict()-function. Note that probably not all model objects that work with ggpredict() are also supported by the sandwich or clubSandwich-package.


Character vector, specifying the estimation type for the robust covariance matrix estimation (see ?sandwich::vcovHC or ?clubSandwich::vcovCR for details).


List of named vectors, used as additional arguments that are passed down to


Currently not used.


The returned matrix has as many rows (and columns) as possible combinations of predicted values from the ggpredict() call. For example, if there are two variables in the terms-argument of ggpredict() with 3 and 4 levels each, there will be 3*4 combinations of predicted values, so the returned matrix has a 12x12 dimension. In short, nrow(object) is always equal to nrow(vcov(object)). See also 'Examples'.


The variance-covariance matrix for the predicted values from object.


model <- lm(barthtot ~ c12hour + neg_c_7 + c161sex + c172code, data = efc)
result <- ggpredict(model, c("c12hour [meansd]", "c161sex"))


# compare standard errors

# only two predicted values, no further terms
# vcov() returns a 2x2 matrix
result <- ggpredict(model, "c161sex")

# 2 levels for c161sex multiplied by 3 levels for c172code
# result in 6 combinations of predicted values
# thus vcov() returns a 6x6 matrix
result <- ggpredict(model, c("c161sex", "c172code"))

strengejacke/ggeffects documentation built on March 18, 2023, 10:31 p.m.