Hypothesis Testing Basics


Hypothesis Testing Basics

Hope
Welcome to our lesson on hypothesis testing, part one. We’ll build from the question we want to answer to a real-world conclusion, using randomization distributions and p-values along the way.

Corey
The main skills are writing null and alternative hypotheses, describing a randomization procedure, finding and interpreting a p-value with StatKey or Minitab Express, and using that p-value to make a conclusion.

Hope
Let’s start with the big picture. A sample statistic can vary from sample to sample, so it’s a random variable. We use sample data to learn about population parameters. In earlier work, we used confidence intervals to estimate those parameters; now we’ll use formal hypothesis tests to ask whether sample data could reasonably come from a population with a particular parameter value.

Corey
The parameters we’ll test are a single mean, a difference in two means, a single proportion, a difference in two proportions, correlation, and the slope in simple linear regression. We won’t test standard deviations in this lesson.

Hope
Here’s our running example: a company claims that five percent of its products are defective. You randomly purchase 100 products, and nine are defective. The question is whether there’s evidence that more than five percent of products in the population are defective.

Corey
That’s a question about a population proportion, not just the nine defects in our sample. The sample proportion is nine out of 100, or 0.09. The company’s claim gives us a hypothesized population proportion of 0.05, and the test will help us judge how surprising a sample result like ours would be if that claim were true.

Hope
Every test starts with two hypotheses. The null hypothesis, written H-zero, represents no difference or the stated baseline, and it always includes equality. The alternative hypothesis, sometimes written H-a or H-one, describes the difference we’re looking for and uses less than, greater than, or not equal to.

Corey
To write them, identify three things: the parameter of interest, the direction of the research question, and the hypothesized parameter value. Hypotheses are always statements about population parameters, even though we use sample data to test them.

Hope
The direction determines the kind of test. If the question asks whether a parameter is greater than the hypothesized value, that’s a right-tailed test. If it asks whether it’s less, that’s left-tailed. If it asks whether it’s simply different, that’s two-tailed.

Corey
For one mean or one proportion, the scenario usually supplies the hypothesized value. For differences between two means or two proportions, the usual null value is zero, meaning no difference. For correlation and a regression slope, zero typically represents no relationship.

Hope
Back to the defective-products question: the parameter is p, the population proportion of defective products. The question asks whether more than 0.05 are defective, so the alternative is right-tailed: p is greater than 0.05. The null is p equals 0.05.

Corey
Here’s a different kind of question: in the population of American women, is age related to number of shoes owned? Both variables are quantitative, and we’re asking about a relationship, so the parameter is the population correlation, rho. Since no positive or negative direction is specified, this is two-tailed: the null says rho equals zero, and the alternative says rho does not equal zero.

Hope
And for two proportions, consider whether female Penn State World Campus students are more likely than male students to have gym memberships. The parameter is the proportion for females minus the proportion for males. ‘More likely’ means that difference is greater than zero.

Corey
So the alternative is that the female proportion minus the male proportion is greater than zero, and the null says the difference equals zero. You can also write those as equal proportions under the null and a greater female proportion under the alternative; they express the same comparison.

Hope
Once the hypotheses are set, we need a sampling distribution under the assumption that the null hypothesis is true. We use resampling to build it. Bootstrapping, which you saw earlier, builds a distribution centered on the sample statistic; randomization instead builds one centered on the value specified by the null.

Corey
The exact randomization procedure depends on the parameter. But the key idea is the same: make simulated samples that fit the null hypothesis, calculate the statistic for each one, and use the resulting distribution to see how unusual our observed statistic would be under the null.

Hope
For a single mean, StatKey can shift the original sample so its mean matches the null value, then repeatedly resample from that shifted data. In the Canton, New York house-price example, the sample mean is 146.8 thousand dollars, while the null value is 200 thousand.

Corey
So StatKey shifts each original price up by 53.2 thousand dollars before resampling. The resulting randomization distribution of sample means is centered at 200, the value assumed by the null. The example has ten houses, and generating thousands of samples—often at least 5,000—is recommended to form the distribution.

Hope
For a single proportion, you enter the sample size and observed count, along with the null proportion. In the defective-products example, that’s 100 products, nine defectives, and a null proportion of 0.05. StatKey uses that information to generate a randomization distribution of sample proportions under the null.

Corey
For a difference in two means, the course uses StatKey’s default ‘reallocate groups’ method. It takes all the observed values, randomly assigns them into two groups, and calculates the difference between the group means. For the commute-time example, values from Atlanta and St. Louis are reallocated, and each simulated statistic is mean Atlanta minus mean St. Louis.

Hope
Because the null says the two population means are equal, that randomization distribution should be centered on zero. Each reallocation gives a different difference; one example produced 0.54, and another produced negative 0.15. Many repetitions create the distribution we need for the test.

Corey
Now we can define the p-value. It’s the proportion of results on the randomization distribution that are as extreme as, or more extreme than, our observed statistic in the direction of the alternative hypothesis. In conditional-probability language, it’s the probability of getting a result at least that extreme, assuming the null hypothesis is true.

Hope
That last condition matters: a p-value is not the probability that the null hypothesis is true. It describes how often we’d see a result like ours, or more extreme, if the null were true.

Corey
For the defective-products example, the alternative is p greater than 0.05, so we look in the right tail. Our observed sample proportion is 0.090. In StatKey, set the cutoff to 0.090 and count the randomization results at or above it; the highlighted right-tail area is the p-value.

Hope
In the example, StatKey gives about 0.070. Minitab Express gives about 0.0620 for the same data and test. Those don’t match exactly because the randomization results vary from run to run, but both estimates lead to the same decision.

Corey
In Minitab Express, you can find the one-sample proportion randomization test under Statistics, then Resampling. Enter summarized data—nine defective products out of 100—and the hypothesized proportion of 0.05. Under Options, change the default two-tailed test to right-tailed.

Hope
Minitab displays a histogram of the randomization distribution with the p-value area highlighted, and it also reports the hypotheses and p-value in a table. In StatKey, remember to set the cutoff to your observed statistic; for a two-tailed test, add the shaded areas in both tails.

Corey
What counts as a small p-value? The usual cutoff in this lesson is 0.05. If the p-value is at most 0.05, reject the null hypothesis; the result is statistically significant. If it’s greater than 0.05, fail to reject the null; the result is not statistically significant.

Hope
‘Fail to reject’ is the appropriate wording when the p-value is above the cutoff. In the defective-products example, both software estimates are above 0.05, so we fail to reject the null. In context, there isn’t evidence that more than five percent of the company’s products are defective.

Corey
Let’s finish the Canton house-price example. The question asks whether the population mean price differs from 200 thousand dollars. That’s a test for a single mean, with the null mu equals 200 and the alternative mu does not equal 200—a two-tailed test.

Hope
After generating the randomization distribution in StatKey, use the observed sample mean, 146.8, to set the cutoff on the left, and account for the equally extreme area on the right. In the example, the two tail areas are about 0.015 each, for a total p-value of 0.03.

Corey
Since 0.03 is less than 0.05, we reject the null hypothesis. The real-world conclusion is that there is evidence the mean price in the population of houses in Canton, New York, differs from 200 thousand dollars.

Hope
So the full workflow has five steps: identify the test and write the hypotheses; construct a randomization distribution assuming the null is true; use it to find the p-value; decide whether to reject or fail to reject; and state a conclusion in the context of the original question.

Corey
When you report a test, make that final step explicit. Don’t stop at ‘reject’ or ‘fail to reject’—say what the evidence does or does not show about the population and the research question.

Hope
That’s the foundation of hypothesis testing in this lesson: choose the right population parameter and tail, simulate what results look like under the null, compare your observed result with that distribution, and explain what the p-value and decision mean in context.

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