library(AER)
library(MASS)
coefs <- summary(lm(medv ~ lstat + crim + age, data = Boston))$coef[, 1]
SEs <- summary(lm(medv ~ lstat + crim + age, data = Boston))$coef[, 2]
# compute t-statistics for all coefficients. Assign them to `tstats`
# compute p-values for all significance tests. Assign them to `pval`
# check whether the hypotheses are rejected at the 1% significance level
# compute t-statistics for each coefficient. Assign them to `tstat`
tstats <- coefs/SEs
# compute p-values for all significance tests. Assign them to `pval`
pvals <- 2*(pnorm(-abs(tstats)))
# check whether the hypotheses are rejected at the 1% significance level
pvals < 0.01
test_object("tstats")
test_object("pvals")
test_or({test_output_contains("pvals < 0.01"),
},{
test_output_contains("pvals =< 0.01")
},{
test_output_contains("pvals >= 0.01")
},{}
test_output_contains("pvals > 0.01")})
success_msg("All coefficients but the one on the crime rate (crim) are statistically different from zero at the 1% significance level.")