Hypothesis Testing

In this lesson, you'll learn about hypothesis testing, a fundamental tool for data scientists to make informed decisions based on data. We'll explore how to use sample data to make inferences about a larger population and determine if observed results are statistically significant.

Learning Objectives

  • Define and differentiate between the null and alternative hypotheses.
  • Understand the concept of p-values and their role in hypothesis testing.
  • Explain the process of significance testing and the types of errors (Type I and Type II).
  • Apply hypothesis testing principles to simple real-world scenarios.

Text-to-Speech

Listen to the lesson content

Lesson Content

Introduction to Hypothesis Testing

Hypothesis testing is a formal procedure for investigating our ideas (hypotheses) about the world using data. It's like a trial where we collect evidence (data) to test a specific claim (hypothesis). The goal is to determine if there's enough evidence to reject a statement about a population. This statement can be something like, 'The average height of men is 5'10"' or 'A new drug is more effective than the old one.' We use sample data to test these claims. The results are probabilistic and can have errors, but they are essential for informed decision-making.

Formulating Hypotheses: Null and Alternative

The foundation of hypothesis testing is the formulation of two hypotheses: the null hypothesis (H0) and the alternative hypothesis (H1 or Ha).

  • Null Hypothesis (H0): This is the default or baseline assumption. It's a statement of 'no effect' or 'no difference.' It represents the status quo. For example, 'There is no difference in the average test scores of students before and after attending a new tutoring program.'
  • Alternative Hypothesis (H1 or Ha): This is the claim we are trying to find evidence for. It contradicts the null hypothesis. It represents what we think might be true. For example, 'The average test scores of students are higher after attending the new tutoring program.' The alternative hypothesis can be one-sided (e.g., higher, lower) or two-sided (e.g., different).

Example:

Let's say a company claims its new battery lasts for 10 hours.

  • H0: The average battery life is equal to 10 hours (µ = 10 hours).
  • Ha: The average battery life is less than 10 hours (µ < 10 hours) – if we suspect it's shorter.

Understanding P-Values

The p-value is a crucial concept in hypothesis testing. It represents the probability of observing results as extreme as, or more extreme than, those observed in our sample data, assuming that the null hypothesis is true. A small p-value (typically less than a predetermined significance level, often 0.05) suggests that the observed data are unlikely if the null hypothesis is true, leading us to reject the null hypothesis. A large p-value suggests that the data are consistent with the null hypothesis.

Example:

If we run a test and get a p-value of 0.03 (with a significance level of 0.05), we would reject the null hypothesis. This means there's a 3% chance of seeing our results (or more extreme results) if the null hypothesis is true. Since this probability is low (less than 5%), we conclude that the null hypothesis is likely false and the alternative hypothesis is more plausible.

Significance Level (α): This is the threshold we set for rejecting the null hypothesis. It represents the probability of making a Type I error (rejecting a true null hypothesis). Common significance levels are 0.05 (5%) and 0.01 (1%).

The Hypothesis Testing Process and Errors

The general steps of hypothesis testing include:

  1. State the Hypotheses: Define H0 and Ha.
  2. Choose a Significance Level (α): Determine the threshold for rejecting H0 (e.g., 0.05).
  3. Collect and Analyze Data: Compute a test statistic (e.g., t-statistic, z-statistic) from the sample data.
  4. Calculate the P-value: Determine the probability of observing the test statistic (or more extreme values) if H0 is true.
  5. Make a Decision: If the p-value ≤ α, reject H0. Otherwise, fail to reject H0.
  6. Draw a Conclusion: Based on the decision, interpret the results in the context of the problem.

Type I and Type II Errors:

  • Type I Error (False Positive): Rejecting the null hypothesis when it is actually true. The probability of making a Type I error is α (the significance level).
  • Type II Error (False Negative): Failing to reject the null hypothesis when it is false. The probability of making a Type II error is β. The power of a test (1 - β) is the probability of correctly rejecting a false null hypothesis.
Progress
0%