library(AER)
data(CPS1985)
dummy_mod <- lm(wage ~ gender, data = CPS1985)
# complete the function below
Rob_CI <- function(model) {
SEs <- ???
lower <- model$coef - ???
upper <- model$coef + ???
return(
cbind("Lower" = lower, "Upper" = upper)
)
}
# use Rob_CI() to compute the confidence intervals for both model coefficients
# complete the function below
Rob_CI <- function(model) {
SEs <- sqrt(diag(vcovHC(model, type = "HC1")))
lower <- model$coef - 1.96 * SEs
upper <- model$coef + 1.96 * SEs
return(
cbind("Lower" = lower, "Upper" = upper)
)
}
# use Rob_CI() to compute the confidence intervals for both model coefficients
Rob_CI(dummy_mod)
test_function_definition("Rob_CI",
function_test = test_expression_result("Rob_CI(dummy_mod)"))
test_output_contains("Rob_CI(dummy_mod)")
success_msg("Nice!")