Learn R Programming

parameters (version 0.4.0)

standard_error_robust: Extract standard errors

Description

standard_error() attempts to return standard errors of model parameters, while standard_error_robust() attempts to return robust standard errors.

Usage

standard_error_robust(
  model,
  vcov_estimation = "HC",
  vcov_type = c("HC3", "const", "HC", "HC0", "HC1", "HC2", "HC4", "HC4m", "HC5", "CR0",
    "CR1", "CR1p", "CR1S", "CR2", "CR3"),
  vcov_args = NULL,
  ...
)

standard_error(model, ...)

# S3 method for factor standard_error(model, force = FALSE, verbose = TRUE, ...)

# S3 method for default standard_error(model, method = NULL, ...)

# S3 method for merMod standard_error(model, effects = c("fixed", "random"), method = NULL, ...)

# S3 method for glmmTMB standard_error( model, effects = c("fixed", "random"), component = c("all", "conditional", "zi", "zero_inflated"), ... )

# S3 method for MixMod standard_error( model, effects = c("fixed", "random"), component = c("all", "conditional", "zi", "zero_inflated"), ... )

# S3 method for mixor standard_error(model, effects = c("all", "fixed", "random"), ...)

# S3 method for clm2 standard_error(model, component = c("all", "conditional", "scale"), ...)

Arguments

model

A model.

vcov_estimation

String, indicating the suffix of the vcov*()-function from the sandwich-package, e.g. vcov_estimation = "CL" (which calls vcovCL to compute clustered covariance matrix estimators), or vcov_estimation = "HC" (which calls vcovHC to compute heteroskedasticity-consistent covariance matrix estimators).

vcov_type

Character vector, specifying the estimation type for the robust covariance matrix estimation (see vcovHC for details).

vcov_args

List of named vectors, used as additional arguments that are passed down to the sandwich-function specified in vcov_estimation.

...

Arguments passed to or from other methods. For standard_error(), if method = "robust", arguments vcov_estimation, vcov_type and vcov_args can be passed down to standard_error_robust().

force

Logical, if TRUE, factors are converted to numerical values to calculate the standard error, with the lowest level being the value 1 (unless the factor has numeric levels, which are converted to the corresponding numeric value). By default, NA is returned for factors or character vectors.

verbose

Toggle off warnings.

method

If "robust", robust standard errors are computed by calling standard_error_robust(). standard_error_robust(), in turn, calls one of the vcov*()-functions from the sandwich-package for robust covariance matrix estimators.

effects

Should standard errors for fixed effects or random effects be returned? Only applies to mixed models. May be abbreviated. When standard errors for random effects are requested, for each grouping factor a list of standard errors (per group level) for random intercepts and slopes is returned.

component

Should all parameters, parameters for the conditional model, or for the zero-inflated part of the model be returned? Applies to models with zero-inflated component. component may be one of "conditional", "zi", "zero-inflated" or "all" (default). May be abbreviated.

Value

A data frame.

Examples

Run this code
# NOT RUN {
model <- lm(Petal.Length ~ Sepal.Length * Species, data = iris)
standard_error(model)

# robust standard errors, calling sandwich::vcovHC(type="HC3") by default
standard_error_robust(model)

# cluster-robust standard errors, using clubSandwich
iris$cluster <- factor(rep(LETTERS[1:8], length.out = nrow(iris)))
standard_error_robust(
  model,
  vcov_type = "CR2",
  vcov_args = list(cluster = iris$cluster)
)
# }

Run the code above in your browser using DataLab