1. Home
  2. Explore
  3. Statistics
  4. Hypothesis Testing Basics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Hypothesis Testing Basics

Hypothesis Testing and Randomization Tests

Statistical inference and hypothesis testing

Statistical inference uses sample data to draw conclusions about a population. A sample statistic is a random variable: its value can differ from one sample to another. Confidence intervals use sample statistics to estimate population parameters; hypothesis tests use sample data to evaluate a claim about a population parameter.

A hypothesis test asks whether the observed sample could reasonably have come from a population in which a specified parameter value is true. For example, if a company claims that the population proportion of defective products is 0.050.050.05, a sample with a higher defective-product proportion might prompt the question of whether the population proportion is actually greater than 0.050.050.05.

The general reasoning is:

  1. State a claim about a population parameter.

  2. Assume the null hypothesis is true.

  3. Determine how likely it would be to observe a sample statistic as extreme as the one obtained.

  4. Use that likelihood to decide whether the sample provides evidence against the null hypothesis.


Null and alternative hypotheses

A hypothesis test uses two competing statements about a population parameter:

  • The null hypothesis, written H0H_0H0​, represents no difference or no relationship relative to a specified value. It always contains equality.

  • The alternative hypothesis, written HaH_aHa​ or H1H_1H1​, represents the difference or relationship being investigated. It uses <<<, >>>, or ≠\ne=.

Hypotheses are written about population parameters, not sample statistics. The research question often determines the alternative hypothesis: a question about whether a value is greater than, less than, or different from a specified value indicates the direction of the alternative.

The null hypothesis supplies the equality assumption used to construct the test; the alternative hypothesis states the kind of departure from that assumption being investigated.

Information needed to write hypotheses

Three elements determine the hypotheses:

  1. Parameter of interest: Identify what population quantity the question concerns.

  2. Direction: Decide whether the question asks whether the parameter is less than, greater than, or different from a value.

  3. Hypothesized value: Identify the parameter value specified by the scenario.

Parameters and typical null values

The tests considered here concern:

  • A single population mean, μ\muμ

  • The difference between two population means, μ1−μ2\mu_1-\mu_2μ1​−μ2​

  • A single population proportion, ppp

  • The difference between two population proportions, p1−p2p_1-p_2p1​−p2​

  • A population correlation, ρ\rhoρ

  • A population simple linear regression slope, β\betaβ

For a single mean or single proportion, the scenario usually gives the hypothesized value. For a difference between two means or two proportions, the null value is usually 000, representing no difference. For a correlation or regression slope, the null value is also typically 000, representing no linear relationship.

Test direction

The alternative hypothesis determines the direction of the test:

  • Left-tailed: HaH_aHa​ uses <<<.

  • Right-tailed: HaH_aHa​ uses >>>.

  • Two-tailed: HaH_aHa​ uses ≠\ne=.

A question asking only whether a parameter is different does not specify a direction, so it calls for a two-tailed test.


Examples of writing hypotheses

Defective products: one population proportion

A company claims that 5%5\%5% of its products are defective. In a sample of 100100100 products, 999 are defective. The question is whether more than 5%5\%5% of products in the population are defective.

  • The variable—whether a product is defective—is categorical, so the parameter is a population proportion, ppp.

  • The phrase “more than” specifies a right-tailed test.

  • The hypothesized proportion is 0.050.050.05.

Thus,

H0:p=0.05H_0: p=0.05H0​:p=0.05
Ha:p>0.05H_a: p>0.05Ha​:p>0.05

Age and number of shoes: correlation

Suppose the question is whether age and number of shoes owned are related in a population. Both variables are quantitative, and the parameter used to describe their linear relationship is the population correlation, ρ\rhoρ.

Because the question asks whether there is a relationship without specifying whether it is positive or negative, the test is two-tailed:

H0:ρ=0H_0: \rho=0H0​:ρ=0
Ha:ρ≠0H_a: \rho\ne 0Ha​:ρ=0

A correlation of 000 represents no linear relationship.

Gym memberships: difference between two proportions

Suppose the question is whether female students are more likely than male students to have a gym membership. The parameters are the proportions of female and male students with memberships, pfp_fpf​ and pmp_mpm​. The question asks whether the female proportion is greater, so the alternative is one-sided:

H0:pf−pm=0H_0: p_f-p_m=0H0​:pf​−pm​=0
Ha:pf−pm>0H_a: p_f-p_m>0Ha​:pf​−pm​>0

These hypotheses are equivalent to:

H0:pf=pmH_0: p_f=p_mH0​:pf​=pm​
Ha:pf>pmH_a: p_f>p_mHa​:pf​>pm​

Both forms express the same comparison.


Randomization procedures

A randomization procedure is a resampling method used to construct a distribution of sample statistics under the assumption that the null hypothesis is true. That distribution is called a randomization distribution.

The key difference from bootstrapping is the assumption used to construct the distribution:

  • A bootstrap sampling distribution is centered around the observed sample statistic.

  • A randomization distribution is constructed under the null hypothesis and is centered around the value stated in the null hypothesis.

The resampling approach depends on the parameter being tested. For every type of test, however, the purpose is the same: model the sample statistics that could occur if the null hypothesis were true.

Randomization distribution for one mean

For a single-mean test, the original sample can be shifted so its mean equals the null-hypothesis mean. Random samples are then drawn from the shifted data, and their means form the randomization distribution.

For example, if the original sample mean is 146.8146.8146.8 and the null mean is 200200200, both measured in thousands of dollars, the sample values can be shifted upward by 53.253.253.2. The shifted sample then has mean 200200200, as required by the null hypothesis. Repeated samples from the shifted data produce a distribution of sample means centered at 200200200.

Randomization distribution for one proportion

For a single-proportion test, the sample size and the observed number of successes are used to construct the randomization distribution under the hypothesized proportion. For example, a sample of 100100100 products with 999 defective products is tested against the null hypothesis p=0.05p=0.05p=0.05.

Repeated randomization samples produce possible sample proportions under the null assumption. Their distribution is used to assess how unusual the observed sample proportion is.

Randomization distribution for a difference between two means

For two-group comparisons, one possible procedure is to reallocate the observed values between the groups:

  1. Combine all observations from the two groups.

  2. Randomly assign the observations back into two groups of the original sizes.

  3. Calculate the difference between the group statistics.

  4. Repeat the random assignment to create a distribution of differences.

For a difference in means, if the statistic is defined as the mean of group 111 minus the mean of group 222, each randomization sample produces a value of xˉ1−xˉ2\bar{x}_1-\bar{x}_2xˉ1​−xˉ2​. Under a null hypothesis of no difference, the distribution is centered around 000.

Randomization methods can also be applied to other parameters, including differences in proportions, correlation, and regression slope. The exact procedure depends on the type of parameter, but the distribution is always constructed to reflect the null hypothesis.

Number of randomization samples

A randomization distribution is approximated by generating many random samples. Using several thousand samples—often at least 5,0005{,}0005,000—can provide a useful approximation. Results from different software runs may vary slightly because the random samples differ.


P-values

A p-value measures how unusual the observed sample statistic would be if the null hypothesis were true. It is the proportion of values in the randomization distribution that are at least as extreme as the observed statistic, in the direction specified by the alternative hypothesis.

In conditional-probability terms, a p-value is the probability of obtaining a statistic as extreme as, or more extreme than, the observed statistic given that the null hypothesis is true.

A p-value is not the probability that the null hypothesis itself is true. It describes the extremeness of the sample result under the null assumption.

One-tailed and two-tailed p-values

  • For a right-tailed test, count the randomization results at or above the observed statistic.

  • For a left-tailed test, count the results at or below the observed statistic.

  • For a two-tailed test, include extreme results in both tails. Add the proportions in the two tails to obtain the p-value.

In general, the p-value is the proportion of randomization samples that are at least as extreme as the observed result in the direction or directions specified by HaH_aHa​.


Interpreting p-values and making decisions

A small p-value indicates that a sample result like the one observed would be unusual if the null hypothesis were true. A common significance cutoff is 0.050.050.05:

  • If p≤0.05p\le 0.05p≤0.05, reject the null hypothesis. The result is called statistically significant.

  • If p>0.05p>0.05p>0.05, fail to reject the null hypothesis. The result is not statistically significant.

Failing to reject the null hypothesis does not prove that it is true. It means that the evidence from the sample is not strong enough, according to the chosen cutoff, to reject it.

A complete hypothesis test should end with a conclusion in the context of the original question. The conclusion should state whether the sample provides evidence for the claim described by the alternative hypothesis.


A five-step approach to a randomization test

  1. Identify the test and write the hypotheses. Determine the population parameter, the direction of the research question, and the hypothesized value.

  2. Construct a randomization distribution. Generate resamples under the assumption that the null hypothesis is true.

  3. Find the p-value. Determine the proportion of randomization results that are at least as extreme as the observed statistic in the direction of the alternative. For a two-tailed test, include both tails.

  4. Make a statistical decision. Reject H0H_0H0​ when p≤0.05p\le 0.05p≤0.05; otherwise, fail to reject H0H_0H0​.

  5. State a real-world conclusion. Explain what the decision means for the original research question.


Worked examples

Defective products

The sample includes 999 defective products out of 100100100, so the observed sample proportion is 0.090.090.09. The hypotheses are:

H0:p=0.05H_0: p=0.05H0​:p=0.05
Ha:p>0.05H_a: p>0.05Ha​:p>0.05

This is a right-tailed test. The p-value is the proportion of randomization samples with a proportion of at least 0.090.090.09.

Two randomization analyses gave estimates of approximately 0.0700.0700.070 and 0.0620.0620.062. These slight differences are expected because the resampling results vary from run to run. Both p-values exceed 0.050.050.05, so the null hypothesis is not rejected.

Conclusion: The sample does not provide sufficient evidence that more than 5%5\%5% of the company’s products are defective in the population.

House prices in Canton, New York

Suppose the question is whether the population mean house price in Canton differs from 200,000. House price is quantitative, and there is one group, so the parameter is a single population mean. If prices are measured in thousands of dollars, the hypotheses are:

H0:μ=200H_0: \mu=200H0​:μ=200
Ha:μ≠200H_a: \mu\ne 200Ha​:μ=200

This is a two-tailed test. The observed sample mean is 146.8146.8146.8 thousand dollars. A randomization distribution is constructed under the null mean of 200200200 thousand dollars, and the p-value includes the extreme area in both tails.

The estimated areas in the two tails were about 0.0150.0150.015 each, giving a total p-value of approximately 0.030.030.03. Since 0.03≤0.050.03\le 0.050.03≤0.05, the null hypothesis is rejected.

Conclusion: There is evidence that the mean house price in the population of Canton, New York, differs from 200,000.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent