coef_test {clubSandwich} | R Documentation |
Test all or selected regression coefficients in a fitted model
Description
coef_test
reports t-tests for each coefficient estimate in a fitted
linear regression model, using a sandwich estimator for the standard errors
and a small sample correction for the p-value. The small-sample correction is
based on a Satterthwaite approximation or a saddlepoint approximation.
Usage
coef_test(
obj,
vcov,
test = "Satterthwaite",
coefs = "All",
p_values = TRUE,
...
)
Arguments
obj |
Fitted model for which to calculate t-tests. |
vcov |
Variance covariance matrix estimated using |
test |
Character vector specifying which small-sample corrections to
calculate. |
coefs |
Character, integer, or logical vector specifying which
coefficients should be tested. The default value |
p_values |
Logical indicating whether to report p-values. The default
value is |
... |
Further arguments passed to |
Value
A data frame containing estimated regression coefficients, standard errors, and test results. For the Satterthwaite approximation, degrees of freedom and a p-value are reported. For the saddlepoint approximation, the saddlepoint and a p-value are reported.
See Also
Examples
data("ChickWeight", package = "datasets")
lm_fit <- lm(weight ~ Diet * Time, data = ChickWeight)
diet_index <- grepl("Diet.:Time", names(coef(lm_fit)))
coef_test(lm_fit, vcov = "CR2", cluster = ChickWeight$Chick, coefs = diet_index)
V_CR2 <- vcovCR(lm_fit, cluster = ChickWeight$Chick, type = "CR2")
coef_test(lm_fit, vcov = V_CR2, coefs = diet_index)