library(AER)
library(MASS)
mod <- lm(medv ~ lstat + crim + age, data = Boston)
# print a coefficient summary that reports robust standard errors
# check whether the hypotheses are rejected at the 1% significance level
# print a coefficient summary that reports robust standard errors
coeftest(mod, vcov. = vcovHC)
# check whether the hypotheses are rejected at the 1% significance level
coeftest(mod, vcov. = vcovHC)[, 4] < 0.01
test_function_result("coeftest")
test_or(test_output_contains("coeftest(mod, vcov. = vcovHC)[, 4] < 0.01", incorrect_msg = "Not correct! Please make sure you select the correct entries of the matrix."), test_output_contains("coeftest(mod, vcov. = vcovHC)[, 4] > 0.01", incorrect_msg = "Not correct! Please make sure you select the correct entries of the matrix."))
success_msg("Correct! We see that when using robust standard errors, the coefficient on the crime rate (crim) becomes significant, whereas the coefficient on the average age of the buildings (age) becomes insignificant at the 1% significance level.")