In a sample of 100 emails, a rule fires on 40 of them. Of the 50 emails that are spam, the rule fires on 30. The 50 non-spam emails give the other 10 firings. The critical value for 1 degree of freedom at 5% is . According to a chi-squared test of independence, are the rule and the spam label independent?
Probability and statistics, Hypothesis testing
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can build the expected table from marginals and compute the statistic and degrees of freedom for a contingency table.
Key idea
For an table, , and .
Steps
- Write the observed table. Rows: spam, not spam. Columns: fires, does not fire. Spam: and . Not spam: and .
- Row totals are and . Column totals are and . .
- Expected counts: , , , .
- Terms: , , , .
- Sum: . Degrees of freedom: .
- Since (the p-value is about ), reject independence. The rule is strongly associated with the spam label.
Common mistakes
- Using as the degrees of freedom. For a table it is .
- Computing an expected count as (row total) times (column total) and forgetting to divide by .
- Reading significance as strength. Use an effect size (here, the difference between 60% and 20% firing rates) too.
How long your answer should be
Half a page, 4 minutes.
Read this
Previous in Probability and statistics: A die is rolled 60 times and faces 1 to 6 appear times. The critical value for 5 degrees of freedom is . Is the die fair according to a chi-squared goodness-of-fit test at the 5% level?
Next in Probability and statistics: Model A and model B are compared on the same 5 cross-validation folds. A's accuracy minus B's accuracy, in percentage points, is . Run a paired t-test of "no difference" at 5% (the two-sided critical value for 4 degrees of freedom is ). Why should you be careful with this test?