Learn R Programming

sjstats (version 0.7.1)

robust: Robust standard errors for regression models

Description

Compute robust standard error for regression models. This method wraps the coeftest-function with robust covariance matrix estimators based on the vcovHC-function, and returns the result as tidy data frame.

Usage

robust(x, vcov = c("HC3", "const", "HC", "HC0", "HC1", "HC2", "HC4", "HC4m", "HC5"), conf.int = FALSE, exponentiate = FALSE)

Arguments

x
A fitted model of any class that is supported by the coeftest()-function.
vcov
Character vector, specifying the estimation type for the heteroskedasticity-consistent covariance matrix estimation (see vcovHC for details).
conf.int
Logical, TRUE if confidence intervals based on robust standard errors should be included.
exponentiate
Logical, whether to exponentiate the coefficient estimates and confidence intervals (typical for logistic regression).

Value

A summary of the model, including estimates, robust standard error, p-value and - optionally - the confidence intervals.

Examples

Run this code
data(efc)
fit <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc)
summary(fit)
robust(fit)

confint(fit)
robust(fit, conf.int = TRUE)
robust(fit, vcov = "HC1", conf.int = TRUE) # "HC1" should be Stata default

library(sjmisc)
# dichtomozize service usage by "service usage yes/no"
efc$services <- sjmisc::dicho(efc$tot_sc_e, dich.by = 0)
fit <- glm(services ~ neg_c_7 + c161sex + e42dep,
           data = efc, family = binomial(link = "logit"))

robust(fit)
robust(fit, conf.int = TRUE, exponentiate = TRUE)

Run the code above in your browser using DataLab