# Archive for

## #13 A question of trust

Which do you trust more: a simulation-based* or normal-based analysis of an inference question?  In other words, if a simulation analysis and normal approximation give noticeably different p-values, which would you believe to be closer to the correct p-value?  Please think about this question in the abstract for a moment.  Soon we’ll come back to it in specific example.

* If you’re not familiar with simulation-based inference, I recommend reading post #12 (here) first.

Here’s the example that we’ll consider throughout this post: Stemming from concern over childhood obesity, researchers investigated whether children might be as tempted by toys as by candy for Halloween treats (see abstract of article here).  Test households in five Connecticut neighborhoods offered two bowls to trick-or-treating children: one with candy and one with small toys.  For each child, researchers kept track of whether the child selected the candy or the toy.  The research question was whether trick-or-treaters are equally likely to select the candy or toy.  More specifically, we will investigate whether the sample data provide strong evidence that trick-or-treaters have a tendency to select either the candy or toy more than the other.

In my previous post (here) I argued against using terminology and formalism when first introducing the reasoning process of statistical inference.  In this post I’ll assume that students have now been introduced to the structure of hypothesis tests, so we’ll start with a series of background questions before we analyze the data (my questions to students appear in italics):

• What are the observational units?  The trick-or-treaters are the observational units.
• What is the variable, and what type of variable is it?  The variable is the kind of treat selected by the child: candy or toy.  This is a binary, categorical variable.
• What is the population of interest?  The population is all* trick-or-treaters in the U.S.  Or perhaps we should restrict the population to all trick-or-treaters in Connecticut, or in this particular community.
• What is the sample?  The sample is the trick-or-treaters in these Connecticut neighborhoods whose selections were recorded by the researchers.
• Was the sample selected randomly from the population?  No, it would be very difficult to obtain a list of trick-or-treaters from which one could select a random sample.  Instead this is a convenience sample of trick-or-treaters who came to the homes that agreed to participate in the study.  We can hope that these trick-or-treaters are nevertheless representative of a larger population, but they were not randomly selected from a population.
• What is the parameter of interest?  The parameter is the population proportion of all* trick-or-treaters who would select the candy if presented with this choice between candy and toy.  Alternatively, we could define the parameter to be the population proportion who would select the toy.  It really doesn’t matter which of the two options we designate as the “success,” but we do need to be consistent throughout our analysis.  Let’s stick with candy as success.
• What is the null hypothesis, in words?  The null hypothesis is that trick-or-treaters are equally likely to select the candy or toy.  In other words, the null hypothesis is that 50% of all trick-or-treaters would select the candy.
• What is the alternative hypothesis, in words?  The alternative hypothesis is that trick-or-treaters are not equally likely to select the candy or toy.  In other words, the alternative hypothesis is that the proportion of all trick-or-treaters who would select the candy is not 0.5.  Notice that this is a two-sided hypothesis.
• What is the null hypothesis, in symbols?  First we have to decide what symbol to use for a population proportion.  Most teachers and textbooks use p, but I prefer to use π.  I like the convention of using Greek letters for parameters (such as μ for a population mean and σ for a population standard deviation), and I see no reason to abandon that convention for a population proportion.  Some teachers worry that students will immediately think of the mathematical constant 3.14159265… when they see the symbol π, but I have not found this to be a problem.  The null hypothesis is H0: π = 0.5.
• What is the alternative hypothesis, in symbols?  The two-sided alternative hypothesis is Ha: π ≠ 0.5.

* I advise students that it’s always a nice touch to insert the word “all” when describing a population and parameter.

Whew, that was a lot of background questions!  Notice that I have not yet told you how the sample data turned out.   I think it’s worth showing students that the issues above can and should be considered before looking at the data.  So, how did the data turn out?  The researchers found that 148 children selected the candy and 135 selected the toy.  The value of the sample proportion who selected the candy is therefore 148/283 ≈ 0.523.

Let’s not lose sight of the research question here: Do the sample data provide strong evidence that trick-or-treaters have a tendency to select either the candy or toy more than the other?  To pursue this I ask: How can we investigate whether the observed value of the sample statistic (.523 who selected the candy) would be very surprising under the null hypothesis that trick-or-treaters are equally likely to select the candy or toy?  I hope that my students will erupt in a chorus of, “Simulate!”*

* I tell my students that if they ever drift off to sleep in class and are startled awake to find that I have called on them with a question, they should immediately respond with: Simulate!  So many of my questions are about simulation that there’s a reasonable chance that this will be the correct answer.  Even if it’s not correct, I’ll be impressed.

Here is a graph of the distribution of sample proportions resulting from 10,000 repetitions of 283 coin flips (using the One Proportion applet here):

I ask students: Describe the shape, center, and variability of the distribution of these simulated sample proportions.  The shape is very symmetric and normal-looking.  The center appears to be near 0.5, which makes sense because our simulation assumed that 50% of all children would choose the candy.  Almost all of the sample proportions fall between 0.4 and 0.6, and it looks like about 90% of them fall between 0.45 and 0.55.

But asking about shape, center, and variability ignores the key issue.  Next I ask this series of questions:

• What do we look for in the graph, in order to assess the strength of evidence about the research question?  We need to see whether the observed value of the sample statistic (0.523) is very unusual.
• Well, does it appear that 0.523 is unusual?  Not unusual at all.  The simulation produced sample proportions as far from 0.5 as 0.523 fairly frequently.
• So, what do we conclude about the research question, and why?  The sample data (0.523 selecting the candy) would not be surprising if children were equally likely to choose the candy or toy, so the data do not provide enough evidence to reject the (null) hypothesis that children are equally likely to choose the candy or toy.

We could stop there, absolutely.  We don’t need to calculate a p-value or anything else in order to draw this conclusion.  We can see all we need from the graph of simulation results.  But let’s go ahead and calculate the (approximate) p-value from the simulation.  Because we have a two-sided alternative, a sample proportion will be considered as “extreme” as the observed one if it’s at least as far from 0.5 as 0.523 is.  In other words, the p-value is the probability of obtaining a sample proportion of 0.477 or less, or 0.523 or more, if the null hypothesis were true.  The applet reveals that 4775 of the 10,000 simulated sample proportions are that extreme, as shown in red below:

The approximate p-value from the simulation analysis is therefore 0.4775.  This p-value is nowhere near being less than 0.05 or 0.10 or any reasonable significance level, so we conclude that the sample data do not provide sufficient evidence to reject the null hypothesis that children are equally likely to choose the candy or toy.

When I first asked about how to investigate the research question, you might have been thinking that we could use a normal approximation, also known as a one-proportion z-test.  Let’s do that now: Apply a one-proportion z-test to these data, after checking the sample size condition.  The condition is certainly satisfied: 283(.5) = 141.5 is far larger than 10.  The z-test statistic can be calculated as:

This z-score tells us that the observed sample proportion who selected candy (0.523) is less than one standard deviation away from the hypothesized value of 0.5.  The two-sided p-value from the normal distribution to be ≈ 2×0.2198 = 0.4396.  Again, of course, the p-value is not small and so we conclude that the sample data do not provide sufficient evidence to reject the null hypothesis of equal likeliness.

But look at the two p-values we have generated: 0.4775 and 0.4396.  Sure, they’re in the same ballpark, but they’re noticeably different.  On a percentage basis, they differ by 8-9%, which is non-trivial.  Which p-value is correct?  This one is easy: Neither is correct!  These are both approximations.

Finally, we are back to the key question of the day, alluded to the title of this post and posed in the first paragraph: Which do you trust more: the (approximate) p-value based on simulation, or the (approximate) p-value based on the normal distribution?  Now that we have a specific example with two competing p-values to compare, please think some more about your answer before you read on.

Many students (and instructors) place more trust in the normal approximation.  One reason for this is that the normal distribution is based on a complicated formula and sophisticated mathematics.  Take a look at the probability density function* of a normal distribution:

* Oh dear, I must admit that in this expression the symbol π does represent the mathematical constant 3.14159265….

How could such a fancy-looking formula possibly go wrong?  More to the point, how could this sophisticated mathematical expression possibly do worse than simulation, which amounts to just flipping a coin a whole bunch of times?

An even more persuasive argument for trusting the normal approximation, in many students’ minds, is that everyone gets the same answer if they perform the normal-based method correctly.  But different people get different answers from a simulation analysis.  Even a single person gets different answers if they conduct a simulation analysis a second time.  This lack of exact replicability feels untrustworthy, doesn’t it?

So, how can we figure out which approximation is better?  Well, what does “better” mean here?  It means closer to the actual, exact, correct p-value.  Can we calculate that exact, correct p-value for this Halloween example? If so, how? Yes, by using the binomial distribution.

If we let X represent a binomial distribution with parameters n = 283 and π = 0.5, the exact p-value is calculated as Pr(X ≤ 135) + Pr(X ≥ 148)*.  This probability turns out (to four decimal places) to be 0.4757.  This is the exact p-value, to which we can compare the approximate p-values.

* Notice that the values 135 and 148 are simply the observed number who selected toy and candy, respectively, in the sample.

So, which approximation method does better?  Simulation-based wins in a landslide over normal-based:

This is not a fluke.  With 10,000 repetitions, it’s not surprising that the simulation-based p-value* came so close to the exact binomial p-value.  The real question is why the normal approximation did so poorly, especially in this example where the validity conditions were easily satisfied, thanks to a large sample size of 283 and a population proportion of 0.5.

* I promise that I only ran the simulation analysis once; I did not go searching for a p-value close to the exact one. We could also calculate a rough margin-of-error for the simulation-based p-value to be about 1/sqrt(10,000) ≈ .01.

The problem with the normal approximation, and a method for improving it, go beyond the scope of a typical Stat 101 course, but I do present this in courses for mathematically inclined students.  First think about it: Why did the normal approximation do somewhat poorly here, and how might you improve the normal approximation?

The problem lies in approximating a discrete probability distribution (binomial) with a continuous one (normal).  The exact binomial probability is the sum of the heights of the red segments in the graph below, whereas the normal approximation calculates the area under the normal curve to the left of 135 and the right of 148:

The normal approximation can be improved with a continuity correction, which means using 135.5 and 147.5, rather than 135 and 148, as the endpoints for the area under the curve.  This small adjustment leads to including a bit more of the area under the normal curve.  The continuity-corrected z-score becomes 0.713 (compared to 0.773 without the correction) and the two-sided normal-based p-value (to four decimal places) becomes 0.4756, which differs from the exact binomial p-value by only 0.0001.  This seemingly minor continuity correction greatly improves the normal approximation to the binomial distribution.

My take-away message is not that normal-based methods are bad, and also not that we should teach the continuity correction to introductory students.  My point is that simulation-based inference is good!  I think many teachers regard simulation as an effective tool for studying concepts such as sampling distributions and for justifying the use of normal approximations.  I agree with this use of simulation wholeheartedly, as far as it goes.  But we can help our students to go further, recognizing that simulation-based inference is very valuable (and trustworthy!) in its own right.

## #12 Simulation-based inference, part 1

We have had tastes of simulation-based inference (abbreviated SBI) in earlier posts.  Post #2 (here), about my all-time favorite question, presented simulation results for the statistic (mean/median) as a measure of skewness.  Post #9 (here), about the 1970 draft lottery, presented a simulation analysis of the correlation coefficient as a measure of lottery fairness.  Now let’s take a step back and consider how one might first introduce students to the concept of statistical inference, more specifically the concept of strength of evidence, through simulation.  You could do this near the very beginning of a course as an introduction to statistical thinking, or you could present this as an introduction to a unit on statistical inference.

Let’s start with real data from a genuine research study in brain science* (described here).  A patient suffered brain damage that caused a loss of vision on the left side of her visual field.  A researcher showed two cards to this patient.  Each card showed a simple line drawing of a house.  However, one of the drawings showed flames coming out of the left side of the house.  The researcher shuffled the two cards, placed them down on a table with one card above the other, and asked the patient which house she would rather live in.  The patient replied that this was a silly question because “they are the same.”  The researcher asked her to choose anyway. The cards were shuffled and placed on the table a total of 17 times. The patient chose the non-burning house in 14 of those 17 showings.  The researcher investigated whether these data provide strong evidence that this patient has a condition known as “blindsight,” meaning that she responds to information from the blind part of her visual field even though she cannot “see” those stimuli.

* I learned about this study from a presentation by Rob Kass at the 2017 U.S. Conference on Teaching Statistics, and I saw Doug Tyson give a workshop presentation about using this context to introduce simulation-based inference.

After I present the background of this study, I first ask students*: Identify the observational units and variable in this study.  The observational units are the 17 showings of pairs of cards, and the variable is which house the patient chose, a binary categorical variable.  Then I ask an obvious question: Did the patient identify the non-burning house for more than half of the showings?  Of course the answer is yes, but I think this question helps to prepare students for the challenging question that comes next: Identify two possible explanations for this result.

* Those of you who read post #11 (here) will not be surprised by this.

I often have to nudge students in the direction I’m looking for.  I have in mind that one explanation is that this patient truly has blindsight, so she really is more likely to choose the non-burning house.  The other explanation, which is surprisingly difficult for students to consider without prompting, is that the patient’s selections are simply the result of random chance. In other words, this second explanation asserts that the patient is equally likely to choose either version of the house on each showing.

Then I ask: Which of these two explanations is easier to investigate, and how might we investigate it with a common device?  Most students realize that the “random chance” explanation is fairly easy to investigate by tossing a coin.  How many coin tosses do we need?  Seventeen, one for each showing of a pair of houses to the patient.  What will heads and tails represent?  Heads will represent choosing the non-burning house, tails will represent choosing the burning house.  (Or you could swap these, it doesn’t matter which is which.)

At this point I ask each student in the class to toss a coin* 17 times and count the number of heads.  As the students finish their tosses, they go to the board and put a dot on a dotplot to indicate how many heads they obtained in their 17 tosses.  In this manner a class of 35 students produces a graph** such as:

* I recommend taking coins to class with you, because carrying coins is not very common for today’s students!

** You might ask students about the observational units and variable in this graph.  The variable is fairly clear and should appear in the axis label: number of heads in 17 coin tosses.  But the observational units are trickier to think about: 35 sets of 17 coin tosses.  I often wait until the end of the activity to ask students about this, because I don’t want to distract attention from the focus on understanding strength of evidence.

What can we learn from this graph, about whether the study’s result provides strong evidence that this patient has blindsight?  The important aspect of the graph for addressing this question is not the symmetric shape or the center near 8.5 (half of 17), although those are worth pointing out as what we expect in this situation.  Our goal is to assess whether the observed result for this patient (14 selections of the non-burning house in 17 showings) would be surprising, if in fact the subject’s selections were random.  What’s important in the graph is that none of these 35 repetitions of the study produced 14 or more heads in 17 simulated coin tosses.  This suggests that it would be pretty surprising to obtain a result as extreme as the one in this study, if the subject was making selections at random.  So, this suggests that the patient’s selections were not random, that she was actually more likely to select the non-burning house.  In other words, our simulation analysis appears to provide fairly strong evidence that this subject truly has blindsight.

Now I hope that a student will ask: Wait a minute, is 35 repetitions enough to be very informative?  Good question! We really should conduct this simulation analysis with thousands of repetitions, not just 35, in order to get a better sense for what would happen if the subject’s selections are random.  I jokingly ask students whether they would like to spend the next several hours tossing coins, but we agree that using software would be much quicker.

We turn to an applet from the RossmanChance* collection to perform the simulation (link; click on One Proportion).  First we need to provide three inputs for the simulation analysis:

* As I have mentioned before, Beth Chance deserves virtually all of the credit for these applets.

One of my favorite aspects of this applet is that it mimics the tactile simulation.  The applet shows coins being tossed, just as students have already done with their own coins:

Here are the results of 10,000 repetitions:

With so many repetitions, we now have a very good sense for what would happen with 17 selections made at random, if this study were repeated over and over.  We see a symmetric distribution centered around 8.5 heads.  We also notice that getting 14 heads in 17 tosses is not impossible with a random coin.  But we see (and this is the key) that it’s very unlikely to obtain 14 or more heads in 17 tosses of a random coin.  We can take this one step further by counting how many of the 10,000 repetitions produced 14 or more heads:

In 10,000 simulated repetitions of this study, under the assumption that only random chance controlled the patient’s selections, we find that only 59 of those repetitions (less than one percent) resulted in 14 or more selections of the non-burning house.  What can we conclude from this, and why?  Well, this particular patient really did select the non-burning house 14 times.  That would be a very surprising result if she were making selections randomly.  Therefore, we have very strong evidence that the patient was not making selections randomly, in other words that she does have this ability known as blindsight.

There you have it: the reasoning process of statistical inference as it relates to strength of evidence, presented in the context of real data from a genuine research study.  I think students can begin to grasp that reasoning process after a half-hour activity such as this.  I think it’s important not to clutter up the presentation with unnecessary terminology and formalism.  Some of the most important decisions a teacher makes concern what to leave out.  We have left out a lot here: We have not used the terms null and alternative hypothesis, we have not identified a parameter, we have not calculated a test statistic, we have not used the term p-value, we have not spoken of a test decision or significance level or rejecting a null hypothesis.  All of that can wait for future classes; keep the focus for now on the underlying concepts and reasoning process.

Before the end of this class period, I like to introduce students to a new study to see whether they can reproduce such a simulation analysis, draw the appropriate conclusion about strength of evidence, and explain the reasoning process behind their conclusion.  Here’s a fun in-class data collection, based again on a genuine research study: A phenomenon called facial prototyping suggests that people tend to associate certain facial characteristics with certain names.  I present students with two faces from the article here), tell them that the names are Bob and Tim, and ask who (Bob or Tim) is on the left:

In a recent class, 36 of 46 students associated the name Tim with the face on the left.  I asked my students: Conduct a simulation analysis to investigate whether this provides strong evidence that college students have a tendency to associate Tim with the face on the left.  Summarize your conclusion, and explain your reasoning.

First students need to think about what values to enter for the applet inputs:

Just as with the blindsight study, we again need 0.5 for the probability of heads, because if people attach names to faces at random, they would put Tim on the left 50% of the time.  We need 46 tosses, one for each student in the sample.  Any large number will suffice for the number of repetitions; I like to use 10,000. Here are the results:

We see that it’s incredibly unlikely to obtain 36 or more heads in 46 tosses of a random coin.  So, it would be extremely surprising for 36 or more of 46 students to attach Tim to the face on the left, if in fact students make selections purely at random.  Therefore, our class data provide very strong evidence that college students do have a genuine tendency to associate the name Tim with the face on the left.

I like starting with the blindsight example before facial prototyping, because I find it comforting to know in advance that the data are 14 successes in 17 trials for the first example.  I also like that the p-value* turns out to be less than .01 in the blindsight example.  Collecting data from students in class is fun and worthwhile, but you never know in advance how the data will turn out.  The Bob/Tim example is quite dependable; I have used it with many classes and have found consistent results that roughly 65-85% put Tim on the left.

* I’m very glad to be able to use this term with you, even though I hold off on using it with my students.  Having a common language that your readers understand can save a lot of time!

Simulation-based inference (SBI) has become a prominent aspect of my teaching, so it will be a common theme throughout this blog.  Part 2 of this post will introduce SBI for comparing two groups, but I will hold off on that post for a while.  Next week’s post will continue the SBI theme by asking which you put more trust in: simulation-based inference or normal-based inference?

## #11 Repeat after me

I often repeat myself in class to emphasize a particular point.  A prominent example of this is that I ask the same series of questions at the outset of almost every example throughout the entire course, from the first day of class to the last.  No doubt some of my students roll their eyes as I ask these same questions over and over and over again.  I join in the fun by poking fun at myself as I ask these questions, time after time after time.

What are these questions that I ask so repeatedly as I introduce every example?  The answer is so boring that it’s bound to be a big letdown after this long lead-in.  I’m almost too embarrassed to tell you.  Okay, here goes: What are the observational units and variables in this study?  I also ask students to classify the type of variable (categorical or numerical*).  If there is more than one variable, I also ask about the role of each variable (explanatory or response).  Like I said, very boring.  But I ask these questions in class every single day.

* Until very recently, I always said quantitative rather than numerical.  But now I have decided that just as many of us have retired qualitative in favor of categorical, we can keep things simpler and more consistent by abandoning quantitative for numerical.

Why do I make such a big deal of repeating these questions for every example?  Because students often struggle with knowing what kind of analysis to perform on a given dataset, and the first step toward answering this question is to identify what the observational units and variables are.  These questions are fundamental to knowing how to analyze the data: what kind of graph to produce, which statistic(s) to calculate, and what inference procedure to use.

Very early in the course, I ask my students: Consider yourselves as the observational units in a statistical study; classify the following variables as categorical or numerical:

• Whether or not you were born in California
• The day of the week on which you were born
• How many miles you are from where you were born
• How many of the original seven Harry Potter books you have read
• The hand you use to write
• How many minutes of sleep you have gotten in the past 24 hours
• Whether or not you have gotten at least 7 hours of sleep in the past 24 hours

Most students find classifying these variables to be straight-forward, but then I ask: Explain why the following are not variables (still considering yourselves to be observational units):

• Average amount of sleep in the past 24 hours among students in our class
• Proportion of students in our class who are left-handed

Most students find this question to be difficult.  I explain that these are summaries that describe our class as a whole, not something that can vary from student to student.  If we were to consider classes at our school as the observational units, then we could legitimately consider these to be variables, because these quantities would vary from class to class.

Then I ask: Explain why this question is not a variable:

• Have left-handers read more Harry Potter books, on average, compared to right-handers?

My point here is that this is a research question, not a variable that can be recorded for each student in the class. This research question involves two variables: handedness (categorical) and number of Harry Potter books read (numerical).

I proceed to give students a series of research questions and ask: What are the observational units and variable(s) in a study to address these questions?  Here are five examples:

1. How long do singers take to sing the national anthem at the start of the Super Bowl?  The observational units here are Super Bowl games.  The variable is the time taken for singing the national anthem at the game, which is numerical.  Here’s a graph of the data from 1991 through 2019:

2. What percentage of kissing couples lean their heads to the right?  The observational units are kissing couples, not individual people.  The variable is the direction in which the couple leans their heads while kissing, which is categorical and binary.  A study of this phenomenon published in Nature in 2003 found that 80 of 124 kissing couples leaned their heads to the right, as shown in this graph:

3. Can a cat’s percent body fat be used to predict its takeoff velocity when jumping?  The observational units are cats, the explanatory variable is percent body fat, and the response variable is takeoff velocity.  Both variables are numerical.  Some students get tripped up by percent body fat being numerical, because they mistakenly think that percents are only associated with categorical variables.  Researchers investigated this question by collecting data on a sample of domestic housecats, producing the following graph:

4. Do people display different amounts of creativity depending on whether they experience intrinsic or extrinsic motivation?  People with extensive experience with creative writing were randomly assigned to one of two groups: 24 people answered a survey about intrinsic motivations for writing (such as the pleasure of self-expression) and the other 23 people answered a survey about extrinsic motivations (such as public recognition).  Then all 47 people were instructed to write a Haiku poem, and these poems were evaluated for creativity on a numerical scale of 0-30 by a panel of judges.  The observational units here are the writers.  The explanatory variable is the motivation type – intrinsic or extrinsic, which is categorical and binary.  The response variable is the creativity score of their Haiku poem, which is numerical.  The resulting data are displayed in the following graph*:

* Links to data sources can be found in a P.S. at the end of this post.  For now I want to say that I came across these data in The Statistical Sleuth by Ramsey and Schafer.  In addition to having the best title of any statistics textbook, the Sleuth also includes this wonderful sentence: Statistics is like grout – the word feels decidedly unpleasant in the mouth, but it describes something essential for holding a mosaic in place.

5. Were eight-hour hospital shifts on which Kristen Gilbert worked as a nurse more likely to have a patient death than shifts on which Gilbert did not work?  Data on this question were presented in the murder case of Kristen Gilbert, a nurse accused of being a serial killer of patients.  Many students are tempted to say that the observational units are patients, but the shifts are the observational units here.  The explanatory variable is whether or not Gilbert was working on the shift, which is categorical and binary.  The response variable is whether or not a patient died on the shift, which is also categorical and binary. The data are summarized in the table and displayed in the graph below:

Notice that these research questions involve five different scenarios: one numerical variable, one categorical variable, two numerical variables, one variable of each type, and two categorical variables.  I draw students’ attention to how the type of graph is different for each scenario.  You might also notice that one of these studies (#4) is a randomized experiment, but the others are observational.  Another question that I ask repeatedly at the outset of most examples is whether the study involved random sampling, random assignment, both, or neither.  I will return to this theme in a future post.

I also like to show Hans Rosling’s video about human progress across 200 countries in 200 years in 4 minutes, and then I present the following “bubble” graph from Rosling’s gapminder software:

Before we get to interesting questions about this graph, I start with these (boring, repetitive) questions: a) What are the observational units in this graph? b) What variable does Rosling use to represent health?  What type of variable is this?  Is this the explanatory or response variable in the graph? c) What variable does Rosling use to represent wealth?  What type of variable is this?  ?  Is this the explanatory or response variable in the graph? d) What variable is represented by the color of the dots?  What type of variable is this e) What variable is represented by the size of the dots?  What type of variable is this?

Everything I’ve described here happens very early in the course, but these questions about observational units and variables keep coming and coming throughout the entire term.  When we study five-number summaries and boxplots, first I ask about the observational units and variables in the dataset.  When I am ready to introducing scatterplots and correlation and regression, first I ask about the observational units and variables in the dataset.  When it’s time to study chi-square tests, first I ask about the observational units and variables in the dataset.  You get the idea.

Observational units and variables are especially important when studying sampling distributions.  Consider these two graphs, from an activity about sampling words from the Gettysburg Address:

The graph on the left shows the distribution of word length, as measured by number of letters, in a random sample of 10 words.  The observational units are words, and the variable (that varies from word to word) is word length.  On the other hand, the graph on the right displays the distribution of sample mean word lengths in 1000 random samples of size 10.  The observational units now are not individual words but samples of 10 words each, and the variable (that varies from sample to sample) is the sample mean word length.  This distinction can be challenging for students to follow, but it’s crucial for understanding what a sampling distribution is.

To assess how well students understand observational units and variables, I ask questions such as the following on assignments, quizzes, and exams:

A1. Suppose that the observational units in a study are patients who entered the emergency room at French Hospital in the previous week.  For each of the following, indicate whether it is a categorical variable, a numerical variable, or not a variable with regard to these observational units. a) How long the patient waits to be seen by a medical professional b) Whether or not the patient has health insurance c) Day of the week on which the patient arrives d) Average wait time before the patient is seen by a medical professional e) Whether or not wait times tend to be longer on weekends than weekdays f) Total cost of the emergency room visit

These are fairly straightforward for most students, but some struggle with the ones that are not variables at all (d, e).

A2. Select either all Super Bowl games that have been played or all movies that have won the Academy Award for Best Picture as the observational units in a study.  Identify one categorical variable and one numerical variable that could be recorded for these observational units.

This can be a bit tricky for students, in part because the observational units are not people.  It’s also naturally harder for students to think up variables for themselves rather than answer questions about variables provided to them.

A3. Researchers studied whether metal bands used for tagging penguins are harmful to their survival.  Researchers tagged 100 penguins with RFID chips, and then they randomly assigned half of the penguins to also receive a metal band.  Researchers then kept track of which penguins survived throughout the study and which did not. a) Identify the observational units. b) Identify and classify the explanatory variable. c) Identify and classify the response variable.

This question is not especially challenging, but some students have trouble with providing a clear description of the variables.  I prefer language such as “whether or not the penguin received a metal band” and “whether or not the penguin survived.”  If a student writes “metal band” and “survival,” it’s not clear whether they are describing the variables or one of the outcomes for each variable.

A4. Consider transactions at the on-campus snack bar to be the observational units in a statistical study.  State a research question that involves a categorical variable and a numerical variable for these observational units.  Also clearly identify and classify the two variables.

I have found that this question is very challenging for students.  I now realize that they need lots of practice with coming up with their own research questions.  I have in mind answers such as: Do people who pay with cash take longer to serve, on average, compared to people who pay with a card?  The explanatory variable is whether the customer pays with cash or card, which is categorical and binary. The response variable is how long the transaction takes to complete, which is numerical.

Let me wrap this up: I know these are boring questions.  I frequently say to my students: Like always, let’s answer the boring questions before we get to the interesting parts.  I’m truly reluctant to publish this blog post about such boring questions!  But I do think these are important questions to ask, and I am convinced that it’s helpful to ask them over and over and over again.  I have also come to believe that answering these questions is not as straightforward for students as I used to think.  In addition, I hope that students appreciate the interesting research questions and datasets and contexts, which we revisit later in the course, in which I pose these questions.

I forget: Did I mention that I often repeat myself in class to emphasize a particular point?

P.S. The data on Super Bowl national anthem singing times came from here and here. The article about kissing couples can be found here. The article about cat jumping is here. The abstract for the article about motivation and creativity is here. The data about the Kristen Gilbert case came from an article written for Statistics: A Guide to the Unknown (described here) by George Cobb and Steven Gelbach, who were statistical expert witnesses on opposite sides of the case. The Rosling video is available here, and the gapminder software is here. The study about penguin survival can be found here.

## #10 My favorite theorem

This blog does not do suspense*, so I’ll come right out with it: Bayes’ Theorem is my favorite theorem.  But even though it is my unabashed favorite, I introduce Bayes’ Theorem to students in a stealth manner.  I don’t present the theorem itself, or even its name, until after students have answered an important question by essentially deriving the result for themselves.  The key is to use a hypothetical table of counts, as the following examples illustrate.  As always, questions that I pose to students appear in italics.

* See question #8 in post #1 here.

1. The ELISA test for HIV was developed in the mid-1980s for screening blood donations.  An article from 1987 (here) gave the following estimates about the ELISA test’s effectiveness in the early stages of its development:

• The test gives a (correct) positive result for 97.7% of blood samples that are infected with HIV.
• The test gives a (correct) negative result for 92.6% of blood samples that are not infected with HIV.
• About 0.5% of the American public was infected with HIV.

First I ask students: Make a prediction for the percentage of blood samples with positive test results that are actually infected with HIV.  Very few people make a good prediction here, but I think this prediction step is crucial for creating cognitive dissonance that leads students to take a closer look at what’s going on.  Lately I have rephrased this question as multiple choice, asking students to select whether their prediction is closest to 10%, 30%, 50%, 70%, or 90%.  Most students respond with 70% or 90%.

Then I propose the following solution strategy: Assume that the given percentages hold exactly for a hypothetical population of 1,000,000 people, and use the percentages fill in the following table of counts:

The numbers in parentheses indicate the order in which we can use the given percentages to complete the table of counts.  I insist that all of my students get out their calculators, or use their phone as a calculator, as we fill in the table together, as follows:

1. 005 × 1,000,000 = 5,000
2. 1,000,000 – 5,000 = 995,000
3. 0.977 × 5,000 = 4,885
4. 5,000 – 4,885 = 115
5. 0.926 × 995,000 = 921,370
6. 995,000 – 921,370 = 73,630
7. 4,885 + 73,630 = 78,515
8. 115 + 921,370 = 921,485

These calculations produce the following table:

Then I say to my students: That was fun, and it filled 10 minutes of class time, but what was the point?  What do we do now with this table to answer the original question?  Many students are quick to point out that we can determine the percentage of positive results that are actually HIV-infected by starting with 78,515 (the total number of positive results) as the denominator and using 4,885 (the number of these positive results that are actually HIV-infected) as the numerator.  This produces: 4,885 / 78,515 ≈ 0.062, or 6.2%.

At this point I act perplexed* and say: Can this really be right?  Why would this percentage be so small when the accuracy percentages for the test are both greater than 90%?  This question is much harder for students, but I encourage them to examine the table and see what’s going on.  A student eventually points out that there are a lot more false positives (people who test positive but do not have the disease) than there are true positives (people who test positive and do have the disease).  Exactly! And why is that?  I often need to direct students’ attention to the base rate: Only half of one percent have the disease, so a very large percentage of them are outnumbered by a fairly small percentage of the 99.5% who don’t have the disease.  In other words, 7.4% of 995,000 people greatly outnumbers 97.7% of 5,000 people.

* I am often truly perplexed, so I have no trouble with acting perplexed to emphasize a point.

I like to think that most students understand this explanation, but there’s no denying that this is a difficult concept.  Simply understanding the question, which requires recognizing the difference between the two conditional percentages (percentage of people with disease who test positive versus percentage of people with positive test result who have disease), can be a hurdle.  To help with this I like to ask: What percentage of U.S. Senators are American males?  What percentage of American males are U.S. Senators?  Are these two percentages the same, fairly close, or very different?  The answer to the first question is a very large percentage: 80/100 = 80% in 2019, but the answer to the second question is an extremely small percentage: 80 / about 160 million ≈ 0.00005%.  These percentages are very different, so it shouldn’t be so surprising that the two conditional percentages* with the ELISA test are also quite different.  At any rate I am convinced that the table of counts makes this more understandable than plugging values into a formula for Bayes’ Theorem would.

* I have avoided using the term conditional probability here, because I think the term conditional percentage is less intimidating to students, suggesting something that can be figured out from a table of counts rather than requiring a mathematical formula.

Some students think this fairly small percentage of 6.2% means that the test result is not very informative, so I ask: How many times more likely is a person to be HIV-infected if they have tested positive, as compared to a person who has not been tested?  This requires some thought, but students recognize that they need to compare 6.2% with 0.5%.  The wording how many times can trip some students up, but many realize that they must take the ratio of the two percentages: 6.2% / 0.5% = 12.4. Then I challenge students with: Write a sentence, using this context, to interpret this value.  A person with a positive test result is 12.4 times more likely to be HIV-infected than someone who has not yet been tested.

I also ask students: Can a person who tests negative feel very confident that they are free of the disease?  Among the blood samples that test negative, what percentage are truly not HIV-infected?  Most students realize that this answer can be determined from the table above: Among the 921,485 who test negative, 921,370 do not have the disease, which is a proportion of 0.999875, or 99.9875%.  A person who tests negative can be quite confident that they do not have the disease.  Such a very high percentage is very important for screening blood donations.  It’s less problematic that only 6.2% of the blood samples that are rejected (due to a positive test result) are actually HIV-infected.

You might want to introduce students to some terminology before moving on.  The 97.7% value is called the sensitivity of the test, and the 92.6% value is called the specificity.  You could also tell students that they have essentially derived a result called Bayes’ Theorem as they produced and analyzed the table of counts.  You could give them a formula or two for Bayes’ Theorem.  The one on the left, presented in terms of H for hypothesis and E for evidence, has a two-event partition (such as disease, not).  A more general of Bayes’ Theorem appears on the right.

I present these versions of Bayes’ Theorem in probability courses and in courses for mathematically inclined students, but I do not show any formulas in my statistical literacy course.  For a standard “Stat 101” introductory course, I do not present this topic at all, as the focus is exclusively on statistical concepts and not probability.

Before we leave this example, I remind students that these percentages were from early versions of the ELISA test in the 1980s, when the HIV/AIDS crisis was first beginning.  Improvements in testing procedures have produced much higher sensitivity and specificity (link).  Running more sophisticated tests on those who test positive initially also greatly decreases the rate of false positives.

I have debated with myself whether to change this HIV testing context for students’ first introduction to these ideas.  One argument against using this context is that the information about sensitivity and specificity is more than three decades old.  Another argument is that 97.7% and 92.6% are not convenient values to work with; perhaps students would be more comfortable with “rounder” values like 90% and 80%.  But I continue to use this context, partly to remind students of how serious the HIV/AIDS crisis was, and because I think the example is compelling.  An alternative that I found recently is to present these ideas in terms of a 2014 study of diagnostic accuracy of breathalyzers sold to the public (link).

Where to next?  With my statistical literacy course, I give students more practice with constructing and analyzing tables of counts to calculate reverse conditional percentages, as in the following example.

A national survey conducted by the Pew Research Center in late 2018 produced the following estimates about educational attainment and Twitter use among U.S. adults:

• 10% have less than a high school diploma; 8% of these adults use Twitter
• 59% have a high school diploma but no college degree; 20% of these adults use Twitter
• 31% have a college degree; 30% of these adults use Twitter

What percentage of U.S. adults who use Twitter have less than a high school diploma?  What percentage have a high school degree but no college degree?  What percentage have a college degree?Which age groups are more likely than they were initially?  Which are less likely?

Again we can answer these questions (about reverse conditional percentages from what was given) by constructing a table of counts for a hypothetical population.  This time we need three rows rather than two, in order to account for the three education levels. I recommend providing students with the outline of the table, but without indicating the order in which to fill it in this time:

With numbers in parentheses again indicating the order in which the cells can be calculated, the completed table turns out to be:

From this table we can calculate that 8/219 ≈ .037, or 3.7% of Twitter users have less than a high school degree, 118/219 ≈ .539, or 53.9% of Twitter users have a high school but not college degree, and 93/219 ≈ .425, or 42.5% of Twitter users have a college degree.  These percentages have increased from the base rate only for the college degree holders, as 31% of the public has a college degree but 42.5% of Twitter users do.

3. A third application that I like to present concerns the famous Monty Hall Problem.  Suppose that a new car is hidden behind one door on a game show, while goats are hidden behind two other doors.  A contestant picks a door, and then (to heighten the suspense!) the host reveals what’s behind a different door that he knows to have a goat.  Then the host asks whether the contestant prefers to stay with the original door or switch to the remaining door.  The question for students is: Does it matter whether the contestant stays or switches?  If so, which strategy is better, and why?

Most people believe that staying or switching does not matter.  I recommend that students play a simulated version of the game many times, with both strategies, to get a sense for how the strategies compare.  An applet that allows students to play simulated games appears here.  The following graph shows the results of 1000 simulated games with each strategy:

It appears that switching wins more often than staying!  We can determine the theoretical probabilities of winning with each strategy by using Bayes’ Theorem.  More to the point, we can use our strategy of constructing a table of hypothetical counts.  Let’s suppose that the contestant initially selects door #1, so the host will show a goat behind door #2 or door #3.  Let’s use 300 for the number of games in our table, just so we’ll have a number that’s divisible by 3.  Here’s the outline of the table:

How do we fill in this table? Let’s proceed as follows:

1. Row totals: If the car is equally likely to be placed behind any of the three doors, then the car should be behind each door for 100 of the 300 games.
2. Bottom (not total) row: Remember that the contestant selected door #1, so when the car is actually behind door #3, the host has no choice but to reveal door #2 all 100 times.
3. Middle row: Just as with the bottom row, now the host has no choice but to reveal door #3 all 100 times.
4. Top row: When the car is actually behind the same door that the contestant selected, the host can reveal either of the other doors, so let’s assume that he reveals each 50% of the time, or 50 times in 100 games.

The completed table is therefore:

We can see from the table that for the 150 games where the host reveals door #2, the car is actually behind door #3 for 100 of those 150 games, which is 2/3 of the games.  In other words, if the contestant stays with door #1, they will win 50/150 times, but by switching to door #3, they win 100/150 times. Equivalently, for the 150 games where the host reveals door #3, the car is actually behind door #2 for 100 of those games, which is again 2/3 of the games.  Bottom line: Switching gives the contestant a 2/3 chance of winning the car, whereas staying only gives a 1/3 chance of winning the car.  The easiest way to understand this, I think, is that by switching, the contestant only loses if they picked the correct door to begin with, which happens one-third of the time.

This post is already quite long, but I can’t resist suggesting a follow-up question for students: Now suppose that the game show producers place the car behind door #1 50% of the time, door #2 40% of the time, and door #3 10% of the time.  What strategy should you use?  In other words, which door should you pick to begin, and then should you stay or switch?  What is your probability of winning the car with the optimal strategy in this case?  Explain.

Encourage students to remember the bottom line from above: By switching, you only lose if you were right to begin with.  So, the optimal strategy here is to select door #3, the least likely door, and then switch after the host reveals a door with a goat.  Then you only lose if you were right to begin with, so you only lose 10% of the time.  This optimal strategy gives you a 90% chance of winning the car.  Students who can think this through and describe the correct optimal strategy have truly understood the resolution of the famous Monty Hall Problem.

One final question for this post: Why is Bayes’ Theorem my favorite?  It provides the mechanism for updating uncertainty in light of partial information, which enables us to answer important questions, such as the reliability of medical diagnostic tests, and also fun recreational ones, such as the Monty Hall Problem.  More than that, Bayes’ Theorem provides the foundation for an entire school of thought about how to conduct statistical inference.  I’ll discuss that in a future post.

P.S. Tom Short and I wrote a JSE article (link) about this approach to teaching Bayes’ Theorem in 1995, but the idea is certainly not original with us.  Gerd Gigerenzer and his colleagues introduced the term “natural frequencies” for this approach; they have demonstrated its effectiveness for improving people’s Bayesian reasoning (link).  The Monty Hall Problem is discussed in many places, including by Jason Rosenhouse in his book (link) titled The Monty Hall Problem.  While I’m mentioning books, I will also point out Sharon Bertsch McGrayne’s wonderful book about Bayesian statistics (link), titled The Theory That Would Not Die.

## #9 Statistics of illumination, part 3

I started a series of posts a few weeks ago (here and here) with examples to demonstrate that statistics can shed light on important questions without requiring sophisticated mathematics.  I use these examples on the first day of class in a statistical literacy course and also in presentations for high school students.  A third example that I use for this purpose is the well-known 1970 draft lottery.

Almost none of my students were alive when the draft lottery was conducted on December 1, 1969.  I tell them that I was alive but not old enough to remember the event, which was televised live.  The purpose was to determine which young men would be drafted to serve in the U.S. armed forces, perhaps to end up in combat in Vietnam.  The draft lottery was based on birthdays, so as not to give any advantage or disadvantage to certain groups of people.  Three hundred and sixty-six capsules were put into a bin, with each capsule containing one of the 366 dates of the year. The capsules were drawn one-at-a-time, with draft number 1 being assigned to the birthday drawn first (which turned out to be September 14), meaning that young men born on that date were the first to be drafted.

Let’s look at the results:

Students are naturally tempted to find the draft number assigned to their own birthday, and I encourage them to do this first.  Then we see who has the smallest draft number in the class.  I always look up the draft number for today’s date before class begins, and then in class I ask if anyone has that draft number.  Students always look perplexed about why that draft number is noteworthy, until I wish a happy birthday to anyone with that draft number*.

* If you are reading this blog entry on the day that it is first posted, and your draft number is 161: Happy birthday!

Then I show students the following scatterplot, which has sequential date on the horizontal axis (e.g., January 1 has date #1, February 1 has date #32, and so on through December 31 with date #366) and draft number on the vertical axis.  I ask students: What would you expect this graph to look like with a truly fair, random lottery process?  They quickly respond that the graph should display nothing but random scatter.  Then I ask: Does this graph appear to display random scatter, as you would expect from a fair, random lottery?  Students almost always respond in the affirmative.

I suggest to students that we dig a little deeper, just to be thorough because the stakes in this lottery were so high.  I propose that we proceed month-by-month, calculating the median draft number for each month.  Students agree that this sounds reasonable, and then I ask: What do we first need to do with the table of draft numbers in order to calculate medians?  Many will respond immediately that we need to put the draft numbers in order for each month.  Then I offer a silly follow-up question: Would the process of doing that by hand be quick and easy, or time-consuming and tedious?  After they answer that, I provide them with the following table, where the draft numbers have been sorted from smallest to largest within each month:

Just to get warmed up, we calculate January’s median draft number together as a class.  Of course, this requires finding the (31+1)/2 = 16th value in order, which is 211.  Then I ask each student to determine the median draft number for their own birth month.  I point out that those born in a 30-day month have more work to do, because they must calculate the average of the 15th and 16th ordered values.  I write the medians on the board as students call them out.  Here they are:

Now I ask: Do you see any pattern in these medians, or do they look like random scatter?  Students are quick to respond that, to their surprise, they do see a pattern!  There’s a tendency for larger medians in earlier months, smaller medians in later months.  In fact, every median in the first six months is larger than every median in the second six months.  Then I present the same scatterplot as before, but with the medians superimposed:

Now that we have the medians to help guide us, students are quick to see an abundance of dots in the top left and bottom right (high draft numbers early in the year, low draft numbers late in the year) of the graph.  They also point out a shortage of dots in the bottom left and top right.  At this point I recommend showing students portions of this video of how the lottery was conducted: link.  You might then explain that the problem was inadequate mixing of the capsules.  For example, the January and February capsules were added to the bin first and so settled near the bottom and tended to be drawn later.  The November and December capsules were added to the bin last and so remained near the top and tended to be drawn earlier.

On the first day of class I end this example there, but you could ask more questions.  For example:  We now think we see a pattern in the scatterplot, but how can we investigate how unlikely such a pattern would be with a truly fair, random lottery?  The approach to answering this is quite straightforward, at least in principle: Use software to conduct a large number of random lotteries and see how often we get a result as extreme as the actual 1970 draft lottery.  But this leads to another question: How can we measure this extremeness, how different the actual lottery results are from what would be expected with a fair, random lottery?  One answer: Use the correlation coefficient between sequential date and draft number.  What would this correlation value be for a truly fair, random lottery?  Zero.  With the actual 1970 draft lottery results, this correlation equaled -0.226.  How often would a random lottery produce a correlation coefficient of with an absolute value of 0.226 or higher?  To answer this I simulated 10,000 random lotteries, calculated the correlation coefficient for each one, and produced the following graph of the 10,000 correlation values:

What does this graph reveal about our question of the fairness of the 1970 draft lottery?  First notice what is not relevant: the approximate normality of the sampling distribution of the correlation coefficient.  That this graph is centered at 0 is also not relevant, although that does indicate that the simulation was performed correctly.  What matters is that none of the 10,000 simulated random lotteries produces a correlation coefficient of 0.226 or higher in absolute value.  This indicates that the 1970 draft lottery result would be extremely unlikely to happen from a truly fair, random lottery.  Therefore, we have extremely strong evidence that the process underlying the 1970 results was not a fair, random lottery.

Fortunately, many improvements were made in the process for the following year’s lottery.  The capsules were mixed much more thoroughly, and the process included random selection of draft numbers as well as random drawing of birthdates.  In other words, a birthdate pulled out of one bin was matched up with a draft number drawn from another bin.  The correlation coefficient for that lottery’s results turned out to be 0.014.  Looking at the simulation results, we see that such a correlation value is not at all surprising from a fair, random lottery.

Another extension of this example is to classify the birthdates and draft numbers into three categories and then summarize the 1970 draft lottery results in a 3×3 table of counts as follows:

You could then ask students to produce and describe a segmented bar graph of these results.  You could also ask them to conduct a chi-square test and summarize their conclusion.  The graph below gives another view of the association between birthdate and draft number.  The chi-square test results in a test statistic of 25.18 and a p-value of 0.00005.

I think this draft lottery example fits nicely with the “statistics of illumination” theme.  The context here is extremely important, and the straightforward calculation of medians sheds considerable light on a problem that could easily have gone unnoticed.  I recommend discussing this example in conjunction with the earlier one about readability of cancer pamphlets (link).  With the cancer pamphlets, calculating medians was an unhelpful distraction that diverted attention from the more pressing issue of comparing distributions.  But with the draft lottery, it’s very hard to see much in the scatterplot until you calculate medians, which are quite helpful for discerning a pattern amidst the noise. I also emphasize to students that achieving true randomness can be much more difficult than you might expect.

P.S. The simulation analysis above was performed with the Corr/Regression applet available at: http://www.rossmanchance.com/ISIapplets.html.  Even though my name appears first in the name of this applet collection, Beth Chance deserves the vast majority* of the credit for imagining and designing and programming these applets.  I’ll have much more to say about simulation-based inference in future posts.

* Whatever percentage of the credit you may think “vast majority” means here, your thought is almost surely an underestimate.

P.P.S. You can read more about the 1970 draft lottery in many places, including here.