Topic 11: Hypothesis Tests and Confidence Intervals for Categorical Data (Spreadsheets)

About

This activity formally introduces confidence intervals and hypothesis tests as tools for statistical inference. We work through two motivating scenarios — one requiring the construction of a confidence interval and the other involving a hypothesis test — in the context of real survey data about immigration policy.

Note. The button above resets multiple choice and checkbox questions. Currently, resetting code cells must be done manually via hitting the Start Over button on each individual interactive cell.

Using a Spreadsheet Program

There are times throughout this activity where you’ll be asked to do work inside of your favorite spreadsheet program.

Hypothesis Testing and Confidence Intervals for Categorical Data

In this activity, we continue our exploration of statistical inference. We’ll cover the basic hypothesis testing framework in addition to discussing confidence intervals more formally than we did in the previous activity.

We’ll motivate this activity by watching three short videos from volunteers at OpenIntro.org. The first two are from Dr. David Diez, a data scientist, and the last is from Dr. Shannon McClintock Pileggi, a member of the statistics faculty at Cal Poly. After each video, you’ll walk through a hands-on application of the video content to a real scenario.

Variability in Point Estimates

Our first video discusses variability in point estimates. Some of the content will sound familiar from the previous activity. Watch the video, then we’ll engage with the ideas by walking through an example together.

Scenario I: A June 2020 Pew Research survey revealed that 74% of Americans support offering a path to citizenship for undocumented immigrants who were brought to the US illegally as children — often referred to as DREAMers.

We’ve discussed the impossibility of a true census, so the Pew study did not poll every single American. Instead, they surveyed 9,654 US adults between June 4 and June 10, 2020. You can find out more about the study logistics here if you are interested. This means that the 74% referenced in the article is the proportion of individuals from the study who were in favor of a path to citizenship for the DREAMers.

Check Your Understanding: Terminology I

The 74% from the Pew Research article is a/an (select all that apply):

Note on Terminology

We often use sample statistic and point estimate interchangeably. A sample statistic serves as a point estimate for the corresponding population parameter.

Check Your Understanding: Terminology II

What is the parameter of interest here?

Check Your Understanding: Terminology III

According to the methodology document, the 9,654 participants were a random sample representative of the population of American adults. If the study were completed again with a new set of 9,654 participants, we would expect:

The code below simulates a random sample of 9,654 individuals for which there is a 74% chance the individual is in support of a path to citizenship for DREAMers. Run the code a few times to see the results.

By running the code block above multiple times, you’ve probably seen that most of the samples resulted in a sample proportion within about one percentage point (0.01) of the assumed proportion \(p = 0.74\).

In the video, Dr. Diez discusses how we can use the Central Limit Theorem to quantify how much variability we should see in the point estimate from one sample to the next. In the case of a single proportion, the Central Limit Theorem states:

Central Limit Theorem for a Sample Proportion

When observations are independent and the sample size is sufficiently large, the sample proportion \(\hat{p}\) will tend to follow a normal distribution with mean \(\mu = p\) (the true population proportion) and standard error \(\displaystyle{S_E = \sqrt{\frac{p\left(1-p\right)}{n}}}\). That is:

\[\hat{p} \sim N\!\left(\mu = p,\ S_E = \sqrt{\frac{p\left(1-p\right)}{n}}\right)\]

It is typical to assume that sufficiently large means that the success-failure condition is satisfied. This condition requires that the sample is large enough that we should expect at least 10 “successes” and at least 10 “failures”.

Find blank cells in your spreadsheet to help you answer the questions that follow. Do “future you” a favor and make sure to label the cells so that you know what you’re doing, and why. The calculations involve checking the success-failure condition and computing the standard error.

Check Your Understanding: Success-Failure Condition I

The sample size is sufficiently large if the success-failure condition is satisfied. What is the success-failure condition? Select all that apply.

Check the green callout box on Central Limit Theorem for a Sample Proportion above.

The success-failure condition is defined in the final two sentences of the box.

Check Your Understanding: Success-Failure Condition II

Is the success-failure condition satisfied for the Pew study with 9,654 participants?

The success-failure condition requires \(n \cdot p \geq 10\) and \(n \cdot (1-p) \geq 10\).

In your spreadsheet, compute =9654*0.74 and =9654*0.26 and check whether both are at least 10.

=9654*0.74 gives 7,143.96 and =9654*0.26 gives 2,510.04. Both are far greater than 10, so the success-failure condition is satisfied.

Check Your Understanding: Success-Failure Condition III

Would the success-failure condition be satisfied for a small study with only 35 participants?

Use the same check as before, but now with \(n = 35\).

In your spreadsheet, compute =35*0.74 and =35*0.26.

=35*0.74 gives 25.9 (which is at least 10, satisfied) but =35*0.26 gives 9.1 (is less than 10, not satisfied). So the condition fails for the “not in favor” group.

Check Your Understanding: Shape of the Sampling Distribution

What will be the shape of the sampling distribution for samples of size 9,654?

The success-failure condition determines whether assuming approximate normality of the sampling distribution is reasonable.

Check Your Understanding: Standard Error

Which of the following is the expected spread of the sampling distribution, measured by the standard error?

The standard error formula is \(S_E = \sqrt{p(1-p)/n}\).

Here \(p = 0.74\) and \(n = 9{,}654\). Use SQRT() in your spreadsheet.

Find an empty cell and type =SQRT(___*(1 - ___)/___) with the blanks filled in by the appropriate values.

In your spreadsheet, type =SQRT(0.74*(1-0.74)/9654) and press Enter. Round to at least four decimal places.

Notice that the standard error is about half of a percentage point (close to 0.005). Doubling this estimate closely matches what we observed about the sampling error using our simulations – the majority of our sample proportions were within about 1 percentage point (0.01) of the true population proportion. This brings us to our next topic — confidence intervals.

Introduction to Confidence Intervals

Watch the next video from Dr. Diez. Once you’ve watched it, we’ll continue with our example about the 2020 Pew Research study.

As Dr. Diez mentions, a confidence interval can be used to capture a population parameter with some desired degree of certainty. In general, we construct a confidence interval using the following formula:

\[\left(\text{point estimate}\right) \pm \left(\text{critical value}\right) \cdot S_E\]

where the point estimate comes from the sample data, the critical value is related to the level of confidence, and the standard error (\(S_E\)) measures the spread of the sampling distribution.

Recall that we’ve been working with a 2020 Pew Research study which included 9,654 participants. The study resulted in 74% of participants being in favor of a path to citizenship for the DREAMers, and we computed the standard error to be approximately 0.0045.

If the sampling distribution is well-modeled by a normal distribution, the following critical values are associated with several common levels of confidence:

Confidence Level Critical Value
90% 1.65
95% 1.96
98% 2.33
99% 2.58

Use what you learned in the video and your knowledge of the Pew Research study to answer the following questions. For any necessary computations, use your spreadsheet.

Check Your Understanding: Confidence Interval I

The point estimate for our confidence interval is:

The point estimate is your “best guess” at the true value of the population parameter. It comes from your collected sample data.

What was the observed sample population of American adults in favor of a path to citizenship for the DREAMers?

Check Your Understanding: Confidence Interval II

The standard error (\(S_E\)) is:

The Central Limit Theorem for proportions says that the standard error of the sampling distribution is \(S_E = \sqrt{p\left(1 - p\right)/n}\).

Find an empty cell in your spreadsheet and calculate the standard error: =SQRT(___*(1 - ___)/___). How do you fill in the blanks?

The first two blanks utilize our best guess at the true population proportion. That is our sample proportion (0.74) and the last blank is our sample size (9654).

Calculate the standard error using =SQRT(0.74*(1 - 0.74)/9654).

Check Your Understanding: Confidence Interval III

The appropriate critical value for a 98% confidence interval is:

There’s a table of typical confidence levels and corresponding critical values above to help you.

Check Your Understanding: Confidence Interval IV

Which of the following are the bounds for a 98% confidence interval? Select all that apply.

A confidence interval is constructed as \(\left(\text{point estimate}\right) \pm \left(\text{critical value}\right)\cdot S_E\). You need two formulas: one adding the margin of error and one subtracting it.

Use two separate cells to carry out your calculations. One for the addition and the other for the subtraction.

The point estimate is 0.74, the critical value for 98% confidence is 2.33, and the standard error is 0.0045. In your spreadsheet, type =0.74+(2.33*0.0045) for the upper bound. Now use another open cell to find the lower bound.

Upper bound: =0.74+(2.33*0.0045) → approximately 0.7505.

Lower bound: =0.74-(2.33*0.0045) → approximately 0.7295.

Check Your Understanding: Confidence Interval V

Which of the following is the correct interpretation of the 98% confidence interval?

Check Your Understanding: Confidence Interval VI

Without computing the bounds, a 90% confidence interval would be:

If you’re willing to be less confident that you’ve captured the population mean, what can you do to your interval?

So far, so good! There’s one more topic to go. Sometimes we’ll want to test a claim about a population parameter rather than build a confidence interval for it. Inferential statistics provides a formal framework called the hypothesis test for evaluating statistical claims such as:

  • Is a population mean or proportion larger, smaller, or different from some proposed value?
  • Do the population means or proportions differ across two or more groups?

Intro to Hypothesis Testing

Here’s one more video from Dr. Shannon McClintock Pileggi introducing the notion of the hypothesis test.

Scenario II: A 2018 poll from NPR reported that 65% of Americans supported a path to citizenship for DREAMers. Assume that the 2018 population proportion truly was 65% in support. Does the 2020 Pew Research poll provide evidence that support for a pathway to citizenship has grown over the past two years? Use a significance level of \(\alpha = 0.05\).

Use what you learned from Dr. McClintock Pileggi to answer the following questions and complete the hypothesis test. Use your spreadsheet for any calculations.

Check Your Understanding: Hypothesis Test I

Which of the following are the hypotheses used to test this claim?

Your null hypothesis (\(H_0\)) is a skeptical claim.

If we’re skeptical about a change, we’d assume that there was none. The population proportion has remained 65%.

The alternative hypothesis (\(H_a\)) is the claim being tested.

Check Your Understanding: Hypothesis Test II

What is the level of significance for the test?

Check Your Understanding: Hypothesis Test III

What is the point estimate?

Just like with confidence intervals, the point estimate comes from the sample. What is the sample proportion in favor of a path to citizenship for the DREAMers?

Check Your Understanding: Hypothesis Test IV

What is the null value?

The “null value” comes from the null hypothesis. What is the assumed true population proportion under \(H_0\)?

Check Your Understanding: Hypothesis Test V

The standard error is computed as \(S_E = \sqrt{\frac{p(1-p)}{n}}\), where \(p\) is the null value. Which of the following is the standard error? (round to four decimal places)

In a hypothesis test we use the null value in place of \(p\) in the standard error formula — not the sample proportion. The null value here is 0.65, and \(n = 9{,}654\).

Find a blank cell in your spreadsheet and evaluate the standard error =SQRT(___*(1 - ___)/___).

In your spreadsheet, type =SQRT(0.65*(1-0.65)/9654) and press Enter. Round to at least four decimal places.

Why Use the Null Value in the Standard Error?

Notice that we use \(p = 0.65\) (the null value) rather than \(\hat{p} = 0.74\) (the sample proportion) when computing the standard error for the hypothesis test. This is because, during a hypothesis test, we assume the null hypothesis is true — we are asking: if the true proportion really is 0.65, how surprising is our observed sample?

Check Your Understanding: Hypothesis Test VI

The test statistic is computed as \(\displaystyle{z = \frac{(\text{point estimate}) - (\text{null value})}{S_E}}\). Which of the following is the test statistic? (round to at least two decimal places)

The test statistic formula is \(z = (\hat{p} - p_0) / S_E\).

You have all three values: the point estimate (0.74), the null value (0.65), and the standard error you just computed (0.0049).

In a blank cell of your spreadsheet, type =(0.74-0.65)/0.0049 and press Enter. Round to two at least decimal places.

Check Your Understanding: Hypothesis Test VII

Use NORM.DIST() to compute the \(p\)-value associated with this test.

The alternative hypothesis is \(H_a: p > 0.65\), so we want the probability of observing a test statistic at least as large as our computed value.

This is an upper-tail (right-tail) probability. To find the area in the upper-tail, we need to use =1 - NORM.DIST(___, ___, ___, TRUE). What are the values we need to use to fill in the blanks?

One we use the test statistic formula, we’ve moved to a distribution whose mean is 0 and whose standard deviation is 1 (that’s the standard normal distribution). Use =1 - NORM.DIST(___, 0, 1, TRUE). What is the boundary value?

The boundary value is your test statistic (~18.54). In your spreadsheet, type =1 - NORM.DIST(18.54, 0, 1, TRUE) and press Enter.

Your spreadsheet will return exactly 0. This is not because the \(p\)-value is truly zero — it is because the test statistic of 18.54 is so far into the tail of the standard normal distribution that the \(p\)-value is smaller than the precision Excel and Google Sheets can display. See the note below for how to report this correctly.

Note on Reported p-values of Zero

If your spreadsheet returns a \(p\)-value of exactly 0, this simply means the \(p\)-value is smaller than the precision the software can display. It is more accurate to say the \(p\)-value is very small — report it as \(p \approx 0\), or as \(p < 0.0001\). Never report a \(p\)-value as exactly zero in a write-up.

Check Your Understanding: Hypothesis Test VIII

Which of the following is the conclusion of the hypothesis test?

The \(p\)-value measures the probability of observing a sample at least as favorable to the alternative hypothesis (\(H_a\)) as ours, assuming that the null hypothesis is true.

Is our observed data compatible with a reality in which the null hypothesis is true?

The level of significance determines the cutoff for what it means for an observed outcome to be “unlikely”.

Since our \(p\)-value is so small (below the level of significance, \(\alpha\)), our observed data would be very surprising in a reality in which the null hypothesis (\(H_0\)) is true. We reject the null hypothesis in favor of the alternative.

Check Your Understanding: Hypothesis Test IX

Which of the following is the result of the hypothesis test stated in context?

What does it mean, in this specific scenario, to reject the null hypothesis and accept the alternative?

Submit

If you are part of a course with an instructor who is grading your work on these activities, please copy and submit the hash below using the method your instructor has requested (there is only a question hash for this activity, no exercise hash).

Question Hash

The hash below encodes your responses to the multiple choice and checkbox questions in this activity.

Exercise Hash

Since there were no code cell exercises in this activity, there is no exercise hash to generate. You’ll see exercise hashes in future activities.

Summary

Main Takeaways

On point estimates and variability:

  • Sample statistics provide point estimates for their corresponding population parameters — a sample proportion estimates a population proportion, a sample mean estimates a population mean.
  • Sample statistics provide reliable point estimates only when the sample is representative of the population.
  • Every sample produces a slightly different statistic. Much of statistics is focused on quantifying this variability.

On confidence intervals:

  • A confidence interval captures a population parameter with a desired degree of confidence, computed as: \[(\text{point estimate}) \pm (\text{critical value}) \cdot S_E\]
  • The point estimate is a sample statistic. The critical value depends on the desired confidence level. The standard error (\(S_E\)) quantifies the expected variability in the point estimate.
  • A correct interpretation: “We are [XX]% confident that the true [population parameter] lies between [lower bound] and [upper bound].”
  • Higher confidence levels require larger critical values, which produce wider intervals.
  • In a spreadsheet, bounds are computed as =point_estimate + (critical_value * SE) and =point_estimate - (critical_value * SE).

On hypothesis tests:

  • A hypothesis test provides a formal framework for evaluating claims about a population parameter.
  • We begin with a null hypothesis (\(H_0\)) representing the status quo and an alternative hypothesis (\(H_a\)) representing the claim to be tested.
  • We set a significance level \(\alpha\) — the threshold below which a \(p\)-value is considered surprising enough to reject \(H_0\).
  • We compute a test statistic: \(\displaystyle{\text{test statistic} = \frac{(\text{point estimate}) - (\text{null value})}{S_E}}\)
  • The \(p\)-value measures the probability of observing a sample at least as favorable to \(H_a\) as ours, assuming \(H_0\) is true. A \(p\)-value smaller than \(\alpha\) is taken as evidence against \(H_0\).
  • In a spreadsheet, use NORM.DIST() in calculations to help you find a \(p\)-value. If the result displayed is 0, report it as rounded to 0, \(p \approx 0\) or \(p < 0.0001\) — not as exactly zero.
Looking Ahead

This activity introduced the general frameworks for confidence intervals and hypothesis tests using proportions. In the coming activities, we’ll continue to utilize these tools to help us estimate population parameters and to test claims about them.

As a preview of what’s coming, here’s a link to a Standard Error Decision Tree that we’ll use throughout the remainder of the course. It looks intimidating now, but look at the bottom-right corner — there’s the confidence interval formula you just used! And the lower-left corner shows the general test statistic formula. Everything else on the document will be explained in the coming activities.