Course contentsShow
← Data Science
Lesson 316 of 2,1459. Hypothesis Testing FoundationsFree lesson

Calculating Test Statistics from Sample Data

Step-by-step process for computing test statistics using sample means, standard errors, and hypothesized values.

Calculating Test Statistics from Sample Data

You'll learn: How to turn raw sample numbers into a test statistic that measures how far your data is from what the null hypothesis predicts.

The Core Idea

A test statistic is your evidence score — it quantifies how unusual your sample result is if the null hypothesis were true. Calculating it follows a simple recipe: take your sample estimate, subtract what the null hypothesis claims, then divide by the standard error.

Think of it like grading on a curve: you measure how many "standard units" away your observation is from the expected value.

The General Formula

For most common scenarios:

Test Statistic = (Sample Estimate - Hypothesized Value) / Standard Error

Step-by-Step Process

1. Identify Your Sample Estimate

Calculate the relevant statistic from your data (sample mean, sample proportion, etc.)

2. State the Hypothesized Value

This comes from your null hypothesis H₀ (e.g., μ₀ = 50, or p₀ = 0.30)

3. Calculate the Standard Error

Use the appropriate formula based on your parameter (SE for mean, proportion, difference, etc.)

4. Compute the Test Statistic

Subtract the hypothesized value from your sample estimate, then divide by the standard error.

Example Walkthrough

Testing if mean customer age = 35:

  • Sample mean: 38
  • Hypothesized mean: 35
  • Standard error: 1.5
  • Test statistic (t): (38 - 35) / 1.5 = 2.0

This tells us the sample mean is 2 standard errors above what H₀ predicts.

Key Takeaway: Test statistics standardize your sample evidence into a single number showing how many standard errors your result is from the null hypothesis value — the larger the absolute value, the stronger the evidence against H₀.