get_varcov {insight} | R Documentation |
Returns the variance-covariance, as retrieved by stats::vcov()
, but works
for more model objects that probably don't provide a vcov()
-method.
get_varcov(x, ...) ## Default S3 method: get_varcov(x, verbose = TRUE, vcov = NULL, vcov_args = NULL, ...) ## S3 method for class 'betareg' get_varcov( x, component = c("conditional", "precision", "all"), verbose = TRUE, ... ) ## S3 method for class 'clm2' get_varcov(x, component = c("all", "conditional", "scale"), ...) ## S3 method for class 'truncreg' get_varcov(x, component = c("conditional", "all"), verbose = TRUE, ...) ## S3 method for class 'hurdle' get_varcov( x, component = c("conditional", "zero_inflated", "zi", "all"), vcov = NULL, vcov_args = NULL, verbose = TRUE, ... ) ## S3 method for class 'glmmTMB' get_varcov( x, component = c("conditional", "zero_inflated", "zi", "dispersion", "all"), verbose = TRUE, ... ) ## S3 method for class 'MixMod' get_varcov( x, effects = c("fixed", "random"), component = c("conditional", "zero_inflated", "zi", "dispersion", "auxiliary", "all"), verbose = TRUE, ... ) ## S3 method for class 'brmsfit' get_varcov(x, component = "conditional", verbose = TRUE, ...) ## S3 method for class 'betamfx' get_varcov( x, component = c("conditional", "precision", "all"), verbose = TRUE, ... ) ## S3 method for class 'aov' get_varcov(x, complete = FALSE, verbose = TRUE, ...) ## S3 method for class 'mixor' get_varcov(x, effects = c("all", "fixed", "random"), verbose = TRUE, ...)
x |
A model. |
... |
Currently not used. |
verbose |
Toggle warnings. |
vcov |
Variance-covariance matrix used to compute uncertainty estimates (e.g., for robust standard errors). This argument accepts a covariance matrix, a function which returns a covariance matrix, or a string which identifies the function to be used to compute the covariance matrix.
|
vcov_args |
List of arguments to be passed to the function identified by
the |
component |
Should the complete variance-covariance matrix of the model
be returned, or only for specific model components only (like count or
zero-inflated model parts)? Applies to models with zero-inflated component,
or models with precision (e.g. |
effects |
Should the complete variance-covariance matrix of the model
be returned, or only for specific model parameters only? Currently only
applies to models of class |
complete |
Logical, if |
The variance-covariance matrix, as matrix
-object.
get_varcov()
tries to return the nearest positive definite matrix
in case of negative eigenvalues of the variance-covariance matrix. This
ensures that it is still possible, for instance, to calculate standard
errors of model parameters. A message is shown when the matrix is negative
definite and a corrected matrix is returned.
data(mtcars) m <- lm(mpg ~ wt + cyl + vs, data = mtcars) get_varcov(m) # vcov of zero-inflation component from hurdle-model if (require("pscl")) { data("bioChemists", package = "pscl") mod <- hurdle(art ~ phd + fem | ment, data = bioChemists, dist = "negbin") get_varcov(mod, component = "zero_inflated") } # robust vcov of, count component from hurdle-model if (require("pscl") && require("sandwich")) { data("bioChemists", package = "pscl") mod <- hurdle(art ~ phd + fem | ment, data = bioChemists, dist = "negbin") get_varcov( mod, component = "conditional", vcov = "BS", vcov_args = list(R = 50) ) }