library(AER)
library(MASS)
mod <- lm(medv ~ lstat + crim + age, data = Boston)
# construct a 99% confidence set for the coefficients of `crim` and `lstat`
# conduct the corresponding F-test
# construct a 99% confidence set for the coefficients of `crim` and `lstat`
confidenceEllipse(mod, which.coef = c("crim", "lstat"), levels = 0.99)
# conduct the corresponding F-test
linearHypothesis(mod, c("crim = 0", "lstat = 0"))
test_or({
fun <- ex() %>% check_function("confidenceEllipse")
fun %>% check_arg("model") %>% check_equal()
fun %>% check_arg("which.coef") %>% check_equal()
fun %>% check_arg("levels") %>% check_equal()
}, {
fun <- ex() %>% override_solution("confidenceEllipse(mod, which.coef = c(\"lstat\", \"crim\"), levels = 0.99)") %>% check_function("confidenceEllipse")
fun %>% check_arg("model") %>% check_equal()
fun %>% check_arg("which.coef") %>% check_equal()
fun %>% check_arg("levels") %>% check_equal()
})
test_function_result("linearHypothesis")
success_msg("Correct! Since (0,0) is not an element of the 99% confidence set, the null hypothesis is rejected at the 1% level.")