| robust {sjstats} | R Documentation |
robust() computes 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.
svy() is intended to compute standard errors for survey
designs (complex samples) fitted with regular lm or
glm functions, as alternative to the survey-package.
It simulates sampling weights by adjusting the residual degrees
of freedom based on the precision weights used to fit x,
and then calls robust() with the adjusted model.
robust(x, vcov = c("HC3", "const", "HC", "HC0", "HC1", "HC2", "HC4", "HC4m",
"HC5"), conf.int = FALSE, exponentiate = FALSE)
svy(x, vcov = c("HC1", "const", "HC", "HC0", "HC2", "HC3", "HC4", "HC4m",
"HC5"), conf.int = FALSE, exponentiate = FALSE)
x |
A fitted model of any class that is supported by the |
vcov |
Character vector, specifying the estimation type for the
heteroskedasticity-consistent covariance matrix estimation
(see |
conf.int |
Logical, |
exponentiate |
Logical, whether to exponentiate the coefficient estimates and confidence intervals (typical for logistic regression). |
A summary of the model, including estimates, robust standard error, p-value and - optionally - the confidence intervals.
svy() simply calls robust(), but first adjusts the
residual degrees of freedom based on the model weights.
Hence, for svy(), x should be fitted with weights.
This simulates sampling weights like in survey designs, though
lm and glm implement precision weights.
The results from svy() are usually more accurate than simple
weighted standard errors for complex samples. However, results from
the survey package are still more exactly, especially
regarding the estimates.
vcov for svy() defaults to "HC1", because
standard errors with this estimation type come closest to the standard
errors from the survey-package.
Currently, svy() only works for objects of class lm.
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)