Chapter page 27 / 3819 Inference for a single mean
English

19  Inference for a single mean

Focusing now on Statistical Inference for numerical data, again, we will revisit and expand upon the foundational aspects of hypothesis testing from Chapter 11.

The important data structure for this chapter is a numeric response variable (that is, the outcome is quantitative). The four data structures we detail are one numeric response variable, one numeric response variable which is a difference across a pair of observations, a numeric response variable broken down by a binary explanatory variable, and a numeric response variable broken down by an explanatory variable that has two or more levels. When appropriate, each of the data structures will be analyzed using the three methods from Chapter 11, Chapter 12, and Chapter 13: randomization test, bootstrapping, and mathematical models, respectively.

As we build on the inferential ideas, we will visit new foundational concepts in statistical inference. One key new idea rests in estimating how the sample mean (as opposed to the sample proportion) varies from sample to sample; the resulting value is referred to as the standard error of the mean. We will also introduce a new important mathematical model, the \(t\)-distribution (as the foundation for the \(t\)-test).

In this chapter, we focus on the sample mean (instead of, for example, the sample median or the range of the observations) because of the well-studied mathematical model which describes the behavior of the sample mean. We will not cover mathematical models which describe other statistics, but the bootstrap and randomization techniques described below are immediately extendable to any function of the observed data. The sample mean will be calculated in one group, two paired groups, two independent groups, and many groups settings. The techniques described for each setting will vary slightly, but you will be well served to find the structural similarities across the different settings.

Similar to how we can model the behavior of the sample proportion \(\hat{p}\) using a normal distribution, the sample mean \(\bar{x}\) can also be modeled using a normal distribution when certain conditions are met. However, we’ll soon learn that a new distribution, called the \(t\)-distribution, is more useful when working with the sample mean. We’ll first learn about this new distribution, then we’ll use it for confidence intervals and hypothesis tests for the mean.

19.1 Bootstrap confidence interval for a mean

Consider a situation where you want to know whether you should buy a franchise of the used car store Awesome Autos. As part of your planning, you’d like to know for how much an average car from Awesome Autos sells. In order to go through the example more clearly, let’s say that you are only able to randomly sample five cars from Awesome Auto. (If this were a real example, you would surely be able to take a much larger sample size, possibly even being able to measure the entire population!)

19.1.1 Observed data

Figure 19.1 shows a (small) random sample of observations from Awesome Auto. The actual cars as well as their selling price are shown.

Photographs of 5 different automobiles. The cars are different colors and different makes and models. On top of the image of each car is its price; the five prices range from 9600 dollars to 27000 dollars.
Figure 19.1: A sample of five cars from Awesome Auto.

The sample average car price of $17140.00 is a first guess at the price of the average car price at Awesome Auto. However, as a student of statistics, you understand that one sample mean based on a sample of five observations will not necessarily equal the true population average car price for all the cars at Awesome Auto. Indeed, you can see that the observed car prices vary with a standard deviation of $7170.29, and surely the average car price would be different if a different sample of size five had been taken from the population. Fortunately, as it did in previous chapters for the sample proportion, bootstrapping will approximate the variability of the sample mean from sample to sample.

19.1.2 Variability of the statistic

As with the inferential ideas covered in Chapter 11, Chapter 12, and Chapter 13, the inferential analysis methods in this chapter are grounded in quantifying how one dataset differs from another when they are both taken from the same population. To repeat, the idea is that we want to know how datasets differ from one another, but we aren’t ever going to take more than one sample of observations. It does not make sense to take repeated samples from the same population because if you have the ability to take more samples, a larger sample size will benefit you more than taking two samples from the population. Instead, of taking repeated samples from the actual population, we use bootstrapping to measure how the samples behave under an estimate of the population.

As mentioned previously, to get a sense of the cars at Awesome Auto, you take a sample of five cars from the Awesome Auto branch near you as a way to gauge the price of the cars being sold. Figure 19.2 shows how the unknown population of car prices at Awesome Auto can be approximated using the sample.

The sample of 5 cars is drawn from a large population with other values (i.e., other car prices) unknown. The sample of five cars is replicated infinitely many times to create a proxy population where the car prices are given by the original dataset in the same relative distribution as measured in the sample.
Figure 19.2: As seen previously, the idea behind bootstrapping is to consider the sample at hand as an estimate of the population. Sampling from the sample (of 5 cars) is identical to sampling from an infinite population which is made up of only the cars in the original sample.

By taking repeated samples from the estimated population, the variability from sample to sample can be observed. In Figure 12.2 the repeated bootstrap samples are seen to be different both from each other and from the original population. Recall that the bootstrap samples were taken from the same (estimated) population, and so the differences in bootstrap samples are due entirely to natural variability in the sampling procedure. For the situation at hand where the sample mean is the statistic of interest, the variability from sample to sample can be seen in Figure 19.3.

The sample is shown being taken from the large unknown population. The bootstrap resamples, however, are taken directly from the original sample (sampling with replacement) as if the resamples had been taken from an infinitely large proxy population. Three bootstrap resamples of 5 cars each are shown, each resample is slightly different due to the process of resampling with replacement.
Figure 19.3: To estimate the natural variability in the sample mean, different bootstrap samples are taken from the original sample. Notice that each bootstrap resample is different from each other as well as from the original sample

By summarizing each of the bootstrap samples (here, using the sample mean), we see, directly, the variability of the sample mean, \(\bar{x},\) from sample to sample. The distribution of \(\bar{x}_{bs}\) for the Awesome Auto cars is shown in Figure 19.4.

The sample is shown being taken from the large unknown population. Three bootstrap resamples of 5 cars each are shown; the three resamples have an average car price of 11780 dollars, 19020 dollars, and 20260 dollars, respectively. A histogram representing many bootstrap resamples indicates that the bootstrap averages vary from roughly 10000 dollars to 25000 dollars.
Figure 19.4: Because each of the bootstrap resamples represents a different set of cars, the mean of the each bootstrap resample will be a different value. Each of the bootstrapped means is calculated, and a histogram of the values describes the inherent natural variability of the sample mean which is due to the sampling process.

Figure 19.5 summarizes one thousand bootstrap samples in a histogram of the bootstrap sample means. The bootstrapped average car prices vary from about $10,000 to $25,000. The bootstrap percentile confidence interval is found by locating the middle 90% (for a 90% confidence interval) or a 95% (for a 95% confidence interval) of the bootstrapped statistics.

Using Figure 19.5, find the 90% and 95% bootstrap percentile confidence intervals for the true average price of a car from Awesome Auto.


A 90% confidence interval is $12,140 to $22,007. The conclusion is that we are 90% confident that the true average car price at Awesome Auto lies somewhere between $12,140 and $22,007.

A 95% confidence interval is $11,778 to $22,500. The conclusion is that we are 95% confident that the true average car price at Awesome Auto lies somewhere between $11,778 to $22,500.

A histogram of the means of 1000 bootstrapped samples from the Awesome Auto data. The percentiles of the bootstrapped means are given to create 80%, 90%, 95%, or 99% bootstrap confidence intervals for the true mean of the population.
Figure 19.5: The original Awesome Auto data is bootstrapped 1,000 times. The histogram provides a sense for the variability of the average car prices from sample to sample.

19.1.3 Bootstrap SE confidence interval

As seen in Section 17.2, another method for creating bootstrap confidence intervals directly uses a calculation of the variability of the bootstrap statistics (here, the bootstrap means). If the bootstrap distribution is relatively symmetric and bell-shaped, then the 95% bootstrap SE confidence interval can be constructed with the formula familiar from the mathematical models in previous chapters:

\[\mbox{point estimate} \pm 2 \cdot SE_{BS}\] The number 2 is an approximation connected to the “95%” part of the confidence interval (remember the 68-95-99.7 rule). As will be seen in Section 19.2, a new distribution (the \(t\)-distribution) will be applied to most mathematical inference on numerical variables. However, because bootstrapping is not grounded in the same theory as the mathematical approach given in this text, we stick with the standard normal quantiles (in R use the function qnorm() to find normal percentiles other than 95%) for different confidence percentages.1

Explain how the standard error (SE) of the bootstrapped means is calculated and what it is measuring.


The SE of the bootstrapped means measures how variable the means are from resample to resample. The bootstrap SE is a good approximation to the SE of means as if we had taken repeated samples from the original population (which we agreed isn’t something we would do because of wasted resources).

Logistically, we can find the standard deviation of the bootstrapped means using the same calculations from Chapter 5. That is, the bootstrapped means are the individual observations about which we measure the variability.

Although we won’t spend a lot of energy on this concept, you may be wondering some of the differences between a standard error and a standard deviation. The standard error describes how a statistic (e.g., sample mean or sample proportion) varies from sample to sample. The standard deviation can be thought of as a function applied to any list of numbers which measures how far those numbers vary from their own average. So, you can have a standard deviation calculated on a column of dog heights or a standard deviation calculated on a column of bootstrapped means from the resampled data. Note that the standard deviation calculated on the bootstrapped means is referred to as the bootstrap standard error of the mean.

It turns out that the standard deviation of the bootstrapped means from Figure 19.5 is $2,891.87 (a value which is an excellent approximation for the standard error of sample means if we were to take repeated samples from the population). (Note: in R the calculation was done using the function sd().) The average of the observed prices is $17,140, and we will consider the sample average to be the best guess point estimate for \(\mu.\) Find and interpret the confidence interval for \(\mu\) (the true average cost of a car at Awesome Auto) using the bootstrap SE confidence interval formula.2

Compare and contrast the two different 95% confidence intervals for \(\mu\) created by finding the percentiles of the bootstrapped means and created by finding the SE of the bootstrapped means. Do you think the intervals should be identical?


  • Percentile interval: ($11,778, $22,500)
  • SE interval: ($11,356.26, $22,923.74)

The intervals were created using different methods, so it is not surprising that they are not identical. However, we are pleased to see that the two methods provide very similar interval approximations. The technical details surrounding which data structures are best for percentile intervals and which are best for SE intervals is beyond the scope of this text. However, the larger the samples are, the better (and closer) the interval estimates will be.

19.1.4 Bootstrap percentile confidence interval for a standard deviation

Suppose that we want to understand how variable the prices of the cars are at Awesome Auto. That is, your interest is no longer in the average car price but in the standard deviation of the prices of all cars at Awesome Auto, \(\sigma.\) You may have already realized that the sample standard deviation, \(s,\) will work as a good point estimate for the parameter of interest: the population standard deviation, \(\sigma.\) The point estimate of the five observations is calculated to be \(s = \$7,170.286.\) While \(s = \$7,170.286\) might be a good guess for \(\sigma,\) we prefer to have an interval estimate for the parameter of interest. Although there is a mathematical model which describes how \(s\) varies from sample to sample, the mathematical model will not be presented in this text. Instead, bootstrapping can be used to find a confidence interval for the parameter \(\sigma.\) Using the same technique as presented for a confidence interval for \(\mu,\) here we find the bootstrap percentile confidence interval for \(\sigma.\)

Describe the bootstrap distribution for the standard deviation shown in Figure 19.6.


The distribution is skewed left and centered near $7,170.286, which is the point estimate from the original data. Most observations in this distribution lie between $0 and $10,000.

Using Figure 19.6, find and interpret a 90% bootstrap percentile confidence interval for the population standard deviation for car prices at Awesome Auto.3

A histogram of the standard deviations of 1000 bootstrapped samples from the Awesome Auto data. The percentiles of the bootstrapped standard deviations are given to create 80%, 90%, 95%, or 99% bootstrap confidence intervals for the true standard deviation of the population.
Figure 19.6: The original Awesome Auto data is bootstrapped 1,000 times. The histogram provides a sense for the variability of the standard deviation of car prices from sample to sample.

19.1.5 Bootstrapping is not a solution to small sample sizes!

The example presented above is done for a sample with only five observations. As with analysis techniques that build on mathematical models, bootstrapping works best when a large random sample has been taken from the population. Bootstrapping is a method for capturing the variability of a statistic when the mathematical model is unknown (it is not a method for navigating small samples). As you might guess, the larger the random sample, the more accurately that sample will represent the population of interest.

19.2 Mathematical model for a mean

As with the sample proportion, the variability of the sample mean is well described by the mathematical theory given by the Central Limit Theorem. However, because of missing information about the inherent variability in the population (\(\sigma\)), a \(t\)-distribution is used in place of the standard normal when performing hypothesis test or confidence interval analyses.

19.2.1 Mathematical distribution of the sample mean

The sample mean tends to follow a normal distribution centered at the population mean, \(\mu,\) when certain conditions are met. Additionally, we can compute a standard error for the sample mean using the population standard deviation \(\sigma\) and the sample size \(n.\)

Central Limit Theorem for the sample mean.

When we collect a sufficiently large sample of \(n\) independent observations from a population with mean \(\mu\) and standard deviation \(\sigma,\) the sampling distribution of \(\bar{x}\) will be nearly normal with

\[\text{Mean} = \mu \qquad \text{Standard Error }(SE) = \frac{\sigma}{\sqrt{n}}\]

Before diving into confidence intervals and hypothesis tests using \(\bar{x},\) we first need to cover two topics:

  • When we modeled \(\hat{p}\) using the normal distribution, certain conditions had to be satisfied. The conditions for working with \(\bar{x}\) are a little more complex, and below, we will discuss how to check conditions for inference using a mathematical model.
  • The standard error is dependent on the population standard deviation, \(\sigma.\) However, we rarely know \(\sigma,\) and instead we must estimate it. Because this estimation is itself imperfect, we use a new distribution called the \(t\)-distribution to fix this problem.

19.2.2 Evaluating the two conditions required for modeling \(\bar{x}\)

Two conditions are required to apply the Central Limit Theorem for a sample mean \(\bar{x}:\)

  • Independence. The sample observations must be independent. The most common way to satisfy this condition is when the sample is a simple random sample from the population. If the data come from a random process, analogous to rolling a die, this would also satisfy the independence condition.

  • Normality. When a sample is small, we also require that the sample observations come from a normally distributed population. We can relax this condition more and more for larger and larger sample sizes. This condition is vague, making it difficult to evaluate, so next we introduce a couple rules of thumb to checking it.

General rule for performing the normality check.

There is no perfect way to check the normality condition, so instead we use two general rules based on the number and magnitude of extreme observations. Note, it often takes practice to get a sense for whether a normal approximation is appropriate.

  • Small \(n\): If the sample size \(n\) is small and there are no clear outliers in the data, then we typically assume the data come from a nearly normal distribution to satisfy the condition.
  • Large \(n\): If the sample size \(n\) is large and there are no particularly extreme outliers, then we typically assume the sampling distribution of \(\bar{x}\) is nearly normal, even if the underlying distribution of individual observations is not.

Some guidelines for determining whether \(n\) is considered small or large are as follows: slight skew is okay for sample sizes of 15, moderate skew for sample sizes of 30, and strong skew for sample sizes of 60.

In this first course in statistics, you aren’t expected to develop perfect judgment on the normality condition. However, you are expected to be able to handle clear cut cases based on the rules of thumb.4

Consider the four plots provided in Figure 19.7 that come from simple random samples from different populations. Their sample sizes are \(n_1 = 15\) and \(n_2 = 50.\)

Are the independence and normality conditions met in each case?


Each samples is from a simple random sample of its respective population, so the independence condition is satisfied. Let’s next check the normality condition for each using the rule of thumb.

The first sample has fewer than 30 observations, so we are watching for any clear outliers. None are present; while there is a small gap in the histogram on the right, this gap is small and over 20% of the observations in this small sample are represented to the left of the gap, so we can hardly call these clear outliers. With no clear outliers, the normality condition can be reasonably assumed to be met.

The second sample has a sample size greater than 30 and includes an outlier that appears to be roughly 5 times further from the center of the distribution than the next furthest observation. This is an example of a particularly extreme outlier, so the normality condition would not be satisfied.

It’s often helpful to also visualize the data using a box plot to assess skewness and existence of outliers. The box plots provided underneath each histogram confirms our conclusions that the first sample does not have any outliers and the second sample does, with one outlier being particularly more extreme than the others.

Two histogram and box plot pairs. The first pair of plots describes a sample size of 15 and the points are distributed between zero and six with no outliers. The second pair of plots describes a sample of size 50 and the points are distributed between zero and six with one additional outlying point above 20.
Figure 19.7: Histograms of samples from two different populations.

In practice, it’s typical to also do a mental check to evaluate whether we have reason to believe the underlying population would have moderate skew (if \(n < 30)\) or have particularly extreme outliers \((n \geq 30)\) beyond what we observe in the data. For example, consider the number of followers for each individual account on Twitter, and then imagine this distribution. The large majority of accounts have built up a couple thousand followers or fewer, while a relatively tiny fraction have amassed tens of millions of followers, meaning the distribution is extremely skewed. When we know the data come from such an extremely skewed distribution, it takes some effort to understand what sample size is large enough for the normality condition to be satisfied.

19.2.3 Introducing the t-distribution

In practice, we cannot directly calculate the standard error for \(\bar{x}\) since we do not know the population standard deviation, \(\sigma.\) We encountered a similar issue when computing the standard error for a sample proportion, which relied on the population proportion, \(p.\) Our solution in the proportion context was to use the sample value in place of the population value when computing the standard error. We’ll employ a similar strategy for computing the standard error of \(\bar{x},\) using the sample standard deviation \(s\) in place of \(\sigma:\)

\[SE = \frac{\sigma}{\sqrt{n}} \approx \frac{s}{\sqrt{n}}\]

This strategy tends to work well when we have a lot of data and can estimate \(\sigma\) using \(s\) accurately. However, the estimate is less precise with smaller samples, and this leads to problems when using the normal distribution to model \(\bar{x}.\)

We’ll find it useful to use a new distribution for inference calculations called the \(t\)-distribution. A \(t\)-distribution, shown as a solid line in Figure 19.8, has a bell shape. However, its tails are thicker than the normal distribution’s, meaning observations are more likely to fall beyond two standard deviations from the mean than under the normal distribution.

The extra thick tails of the \(t\)-distribution are exactly the correction needed to resolve the problem (due to extra variability of the T score) of using \(s\) in place of \(\sigma\) in the \(SE\) calculation.

Two symmetric bell-shaped curves on top of one another. One is a normal curve with smaller tails and a higher peak in the middle. The other is a t-distribution with longer tails, meaning that there are more observations far from the center of a t-distribution than of a normal distribution.
Figure 19.8: Comparison of a \(t\)-distribution and a normal distribution.

The \(t\)-distribution is always centered at zero and has a single parameter: degrees of freedom. The degrees of freedom describes the precise form of the bell-shaped \(t\)-distribution. Several \(t\)-distributions are shown in Figure 19.9 in comparison to the normal distribution. Similar to the Chi-square distribution, the shape of the \(t\)-distribution also depends on the degrees of freedom.

In general, we’ll use a \(t\)-distribution with \(df = n - 1\) to model the sample mean when the sample size is \(n.\) That is, when we have more observations, the degrees of freedom will be larger and the \(t\)-distribution will look more like the standard normal distribution; when the degrees of freedom is about 30 or more, the \(t\)-distribution is nearly indistinguishable from the normal distribution.

A normal distribution and four t distributions, all super imposed on top of one another. The smaller the degrees of freedom, the wider the tails in the t distribution.
Figure 19.9: The larger the degrees of freedom, the more closely the \(t\)-distribution resembles the standard normal distribution.

Degrees of freedom: df.

The degrees of freedom describes the shape of the \(t\)-distribution. The larger the degrees of freedom, the more closely the distribution approximates the normal distribution.

When modeling \(\bar{x}\) using the \(t\)-distribution, use \(df = n - 1.\)

The \(t\)-distribution allows us greater flexibility than the normal distribution when analyzing numerical data. In practice, it’s common to use statistical software, such as R, Python, or SAS for these analyses. In R, the function used for calculating probabilities under a \(t\)-distribution is pt() (which should seem similar to previous R functions, pnorm() and pchisq()). Don’t forget that with the \(t\)-distribution, the degrees of freedom must always be specified!

For the examples and guided practices below, you may have to use a table or statistical software to find the answers. We recommend trying the problems so as to get a sense for how the \(t\)-distribution can vary in width depending on the degrees of freedom. No matter the approach you choose, apply your method using the examples below to confirm your working understanding of the \(t\)-distribution.

What proportion of the \(t\)-distribution with 18 degrees of freedom falls below -2.10?


Let’s first draw the picture and shade the area below -2.10.

A t distribution with 18 degrees of freedom. The area below -2.10 has been shaded.

Using statistical software, we can obtain a precise value: 0.0250.

# use pt() to find probability under the t-distribution
pt(-2.10, df = 18)
[1] 0.025

What proportion of the 𝑡-distribution with 20 degrees of freedom falls above 1.65?


Note that with 20 degrees of freedom, the \(t\)-distribution is relatively close to the normal distribution. With a normal distribution, this would correspond to about 0.05, so we should expect the \(t\)-distribution to give us a similar value. Using statistical software, we can obtain a precise value: 0.0573.

# use pt() to find probability under the t-distribution
1 - pt(1.65, df = 20)
[1] 0.0573

A \(t\)-distribution with 2 degrees of freedom is shown below. Estimate the proportion of the distribution falling more than 3 units from the mean (above or below).

A t distribution with 2 degrees of freedom. The area below negative 3 and above positive 3 has been shaded.


With so few degrees of freedom, the \(t\)-distribution will give a more notably different value than the normal distribution. Under a normal distribution, the area would be about 0.003 using the 68-95-99.7 rule. For a \(t\)-distribution with \(df = 2,\) the area in both tails beyond 3 units totals 0.0955. This area is dramatically different than what we obtain from the normal distribution.

# use pt() to find probability under the t-distribution
pt(-3, df = 2) + (1 - pt(3, df = 2))
[1] 0.0955

What proportion of the \(t\)-distribution with 19 degrees of freedom falls above -1.79 units? Use your preferred method for finding tail areas.5

19.2.4 One sample t-intervals

Let’s get our first taste of applying the \(t\)-distribution in the context of an example about the mercury content of dolphin muscle. Elevated mercury concentrations are an important problem for both dolphins and other animals, like humans, who occasionally eat them.

A photograph of a Risso's dolphin in the water.
Figure 19.10: A Risso’s dolphin. Photo by Mike Baird, www.bairdphotos.com. CC BY 2.0 license.

We will identify a confidence interval for the average mercury content in dolphin muscle using a sample of 19 Risso’s dolphins from the Taiji area in Japan. The data are summarized in Table 19.1. The minimum and maximum observed values can be used to evaluate whether there are clear outliers.

Table 19.1: Summary of mercury content in the muscle of 19 Risso’s dolphins from the Taiji area. Measurements are in micrograms of mercury per wet gram of muscle \((\mu\)g/wet g).
n Mean SD Min Max
19 4.4 2.3 1.7 9.2

Are the independence and normality conditions satisfied for this dataset?


The observations are a simple random sample, therefore it is reasonable to assume that the dolphins are independent. The summary statistics in Table 19.1 do not suggest any clear outliers, with all observations within 2.5 standard deviations of the mean. Based on this evidence, the normality condition seems reasonable.

In the normal model, we used \(z^{\star}\) and the standard error to determine the width of a confidence interval. We revise the confidence interval formula slightly when using the \(t\)-distribution:

\[ \begin{aligned} \text{point estimate} \ &\pm\ t^{\star}_{df} \times SE \\ \bar{x} \ &\pm\ t^{\star}_{df} \times \frac{s}{\sqrt{n}} \end{aligned} \]

Using the summary statistics in Table 19.1, compute the standard error for the average mercury content in the \(n = 19\) dolphins.


We plug in \(s\) and \(n\) into the formula: \(SE = \frac{s}{\sqrt{n}} = \frac{2.3}{\sqrt{19}} = 0.528.\)

The value \(t^{\star}_{df}\) is a cutoff we obtain based on the confidence level and the \(t\)-distribution with \(df\) degrees of freedom. That cutoff is found in the same way as with a normal distribution: we find \(t^{\star}_{df}\) such that the fraction of the \(t\)-distribution with \(df\) degrees of freedom within a distance \(t^{\star}_{df}\) of 0 matches the confidence level of interest.

When \(n = 19,\) what is the appropriate degrees of freedom? Find \(t^{\star}_{df}\) for this degrees of freedom and the confidence level of 95%


The degrees of freedom is easy to calculate: \(df = n - 1 = 18.\)

Using statistical software, we find the cutoff where the upper tail is equal to 2.5%: \(t^{\star}_{18} = 2.10.\) The area below -2.10 will also be equal to 2.5%. That is, 95% of the \(t\)-distribution with \(df = 18\) lies within 2.10 units of 0.

# use qt() to find the t-cutoff (with 95% in the middle)
qt(0.025, df = 18)
[1] -2.1
qt(0.975, df = 18)
[1] 2.1

Degrees of freedom for a single sample.

If the sample has \(n\) observations and we are examining a single mean, then we use the \(t\)-distribution with \(df=n-1\) degrees of freedom.

Compute and interpret the 95% confidence interval for the average mercury content in Risso’s dolphins.


We can construct the confidence interval as

\[ \begin{aligned} \bar{x} \ &\pm\ t^{\star}_{18} \times SE \\ 4.4 \ &\pm\ 2.10 \times 0.528 \\ (3.29 \ &, \ 5.51) \end{aligned} \] We are 95% confident the average mercury content of muscles in Risso’s dolphins is between 3.29 and 5.51 \(\mu\)g/wet gram, which is considered extremely high.

Calculating a \(t\)-confidence interval for the mean, \(\mu.\)

Based on a sample of \(n\) independent and nearly normal observations, a confidence interval for the population mean is

\[ \begin{aligned} \text{point estimate} \ &\pm\ t^{\star}_{df} \times SE \\ \bar{x} \ &\pm\ t^{\star}_{df} \times \frac{s}{\sqrt{n}} \end{aligned} \]

where \(\bar{x}\) is the sample mean, \(t^{\star}_{df}\) corresponds to the confidence level and degrees of freedom \(df,\) and \(SE\) is the standard error as estimated by the sample.

The FDA’s webpage provides some data on mercury content of fish. Based on a sample of 15 croaker white fish (Pacific), a sample mean and standard deviation were computed as 0.287 and 0.069 ppm (parts per million), respectively. The 15 observations ranged from 0.18 to 0.41 ppm. We will assume these observations are independent. Based on the summary statistics of the data, do you have any objections to the normality condition of the individual observations?6

Estimate the standard error of \(\bar{x} = 0.287\) ppm using the data summaries in the previous Guided Practice. If we are to use the \(t\)-distribution to create a 90% confidence interval for the actual mean of the mercury content, identify the degrees of freedom and \(t^{\star}_{df}.\)


The standard error: \(SE = \frac{0.069}{\sqrt{15}} = 0.0178.\) Degrees of freedom: \(df = n - 1 = 14.\) Since the goal is a 90% confidence interval, we choose \(t_{14}^{\star}\) so that the two-tail area is 0.1: \(t^{\star}_{14} = 1.76.\)

# use qt() to find the t-cutoff (with 90% in the middle)
qt(0.05, df = 14)
[1] -1.76
qt(0.95, df = 14)
[1] 1.76

Using the information and results of the previous Guided Practice and Example, compute a 90% confidence interval for the average mercury content of croaker white fish (Pacific).7

The 90% confidence interval from the previous Guided Practice is 0.256 ppm to 0.318 ppm. Can we say that 90% of croaker white fish (Pacific) have mercury levels between 0.256 and 0.318 ppm?8

Recall that the margin of error is defined by the standard error. The margin of error for \(\bar{x}\) can be directly obtained from \(SE(\bar{x}).\)

Margin of error for \(\bar{x}.\)

The margin of error is \(t^\star_{df} \times s/\sqrt{n}\) where \(t^\star_{df}\) is calculated from a specified percentile on the t-distribution with df degrees of freedom.

19.2.5 One sample t-tests

Now that we have used the \(t\)-distribution for making a confidence interval for a mean, let’s speed on through to hypothesis tests for the mean.

The test statistic for assessing a single mean is a T.

The T score is a ratio of how the sample mean differs from the hypothesized mean as compared to how the observations vary.

\[ T = \frac{\bar{x} - \mbox{null value}}{s/\sqrt{n}} \]

When the null hypothesis is true and the conditions are met, T has a t-distribution with \(df = n - 1.\)

Conditions:

  • Independent observations.
  • Large samples and no extreme outliers.

Is the typical US runner getting faster or slower over time? We consider this question in the context of the Cherry Blossom Race, which is a 10-mile race in Washington, DC each spring. The average time for all runners who finished the Cherry Blossom Race in 2006 was 93.29 minutes (93 minutes and about 17 seconds). We want to determine using data from 100 participants in the 2017 Cherry Blossom Race whether runners in this race are getting faster or slower, versus the other possibility that there has been no change.

The run17 data can be found in the cherryblossom R package.

What are appropriate hypotheses for this context?9

When completing a hypothesis test for the one-sample mean, the process is nearly identical to completing a hypothesis test for a single proportion. First, we find the Z score using the observed value, null value, and standard error; however, we call it a T score since we use a \(t\)-distribution for calculating the tail area. Then we find the p-value using the same ideas we used previously: find the one-tail area under the sampling distribution, and double it.

But first, we check the conditions.

The data come from a simple random sample of all participants, so the observations are independent. A histogram of the race times is given below to evaluate if we can move forward with a t-test. Is the normality condition met?10

With both the independence and normality conditions satisfied, we can proceed with a hypothesis test using the \(t\)-distribution. The sample mean and sample standard deviation of the sample of 100 runners from the 2017 Cherry Blossom Race are 98.78 and 16.59 minutes, respectively. Recall that the average run time in 2006 was 93.29 minutes. Find the test statistic and p-value. What is your conclusion?


To find the test statistic (T score), we first must determine the standard error:

\[ SE = 16.6 / \sqrt{100} = 1.66 \] Now we can compute the T score using the sample mean (98.78), null value (93.29), and \(SE:\)

\[ T = \frac{98.8 - 93.29}{1.66} = 3.32 \] For \(df = 100 - 1 = 99,\) we can determine using statistical software (or a \(t\)-table) that the one-tail area is 0.000631, which we double to get the p-value: 0.00126.

# use pt() to find the left tail and multiply by 2 to get both tails
(1 - pt(3.32, df = 99)) * 2
[1] 0.00126

Because the p-value is smaller than 0.05, we reject the null hypothesis. That is, the data provide convincing evidence that the average run time for the Cherry Blossom Run in 2017 is different than the 2006 average.

When using a \(t\)-distribution, we use a T score (similar to a Z score).

To help us remember to use the \(t\)-distribution, we use a \(T\) to represent the test statistic, and we often call this a T score. The Z score and T score are computed in the exact same way and are conceptually identical: each represents how many standard errors the observed value is from the null value.

19.3 Chapter review

19.3.1 Summary

In this chapter we extended the randomization / bootstrap / mathematical model paradigm to questions involving quantitative variables of interest. When there is only one variable of interest, we are often hypothesizing or finding confidence intervals about the population mean. Note, however, the bootstrap method can be used for other statistics like the population median or the population IQR. When comparing a quantitative variable across two groups, the question often focuses on the difference in population means (or sometimes a paired difference in means). The questions revolving around one, two, and paired samples of means are addressed using the t-distribution; they are therefore called “t-tests” and “t-intervals.” When considering a quantitative variable across 3 or more groups, a method called ANOVA is applied. Again, almost all the research questions can be approached using computational methods (e.g., randomization tests or bootstrapping) or using mathematical models. We continue to emphasize the importance of experimental design in making conclusions about research claims. In particular, recall that variability can come from different sources (e.g., random sampling vs. random allocation, see Figure 2.8).

19.3.2 Terms

The terms introduced in this chapter are presented in Table 19.2. If you’re not sure what some of these terms mean, we recommend you go back in the text and review their definitions. You should be able to easily spot them as bolded text.

Table 19.2: Terms introduced in this chapter.
Central Limit Theorem point estimate T score single mean
degrees of freedom SD of observations t-distribution
numerical data SE single mean t-test

19.4 Exercises

Answers to odd-numbered exercises can be found in Appendix A.19.

  1. Statistics vs. parameters: one mean. Each of the following scenarios were set up to assess an average value. For each one, identify, in words: the statistic and the parameter.

    1. A sample of 25 New Yorkers were asked how much sleep they get per night.

    2. Researchers at two different universities in California collected information on undergraduates’ heights.

  1. Statistics vs. parameters: one mean. Each of the following scenarios were set up to assess an average value. For each one, identify, in words: the statistic and the parameter.

    1. Georgianna samples 20 children from a particular city and measures how many years they have each been playing piano.

    2. Traffic police officers (who are regularly exposed to lead from automobile exhaust) had their lead levels measured in their blood.

  1. Heights of adults. Researchers studying anthropometry collected body measurements, as well as age, weight, height and gender, for 507 physically active adults. Summary statistics for the distribution of heights (measured in centimeters, cm), along with a histogram, are provided below.11 (Heinz et al. 2003)

    Min 147.2
    Q1 163.8
    Median 170.3
    Mean 171.1
    Q3 177.8
    Max 198.1
    SD 9.4
    IQR 14.0

    1. What are the point estimates for the average and median heights of active adults?

    2. What are the point estimates for the standard deviation and IQR of heights of active adults?

    3. Is a person who is 1m 80cm (180 cm) tall considered unusually tall? And is a person who is 1m 55cm (155cm) considered unusually short? Explain your reasoning.

    4. The researchers take another random sample of physically active adults. Would you expect the mean and the standard deviation of this new sample to be the ones given above? Explain your reasoning.

    5. The sample means obtained are point estimates for the mean height of all active individuals, if the sample of individuals is equivalent to a simple random sample. What measure do we use to quantify the variability of such an estimate? Compute this quantity using the data from the original sample under the condition that the data are a simple random sample.

  1. Heights of adults, standard error. Heights of 507 physically active adults have a mean of 171 cm and a standard deviation of 9.4 cm. Provide an estimate for the standard error of the mean for samples of following sizes.12 (Heinz et al. 2003)

    1. n = 10

    2. n = 50

    3. n = 100

    4. n = 1000

    5. The standard error of the mean is a number which describes what?

  1. Heights of adults vs. kindergartners. Heights of 507 physically active adults have a mean of 171 cm and a standard deviation of 9.4 cm.13 (Heinz et al. 2003)

    1. Would you expect the standard deviation of the heights of a few hundred kindergartners to be higher or lower than 9.4 cm? Explain your reasoning.

    2. Suppose many samples of size 100 adults is taken and, separately, many samples of size 100 kindergarteners are taken. For each of the many samples, the average height is computed. Which set of sample averages would have a larger standard error of the mean, the adult sample averages or the kindergartner sample averages?

  1. Heights of adults, bootstrap interval. Researchers studying anthropometry collected body measurements, as well as age, weight, height and gender, for 507 physically active adults. The histogram below shows the sample distribution of bootstrapped means from 1,000 different bootstrap samples.14 (Heinz et al. 2003)

    1. Given the bootstrap sampling distribution for the sample mean, find an approximate value for the standard error of the mean.

    2. By looking at the bootstrap sampling distribution (1,000 bootstrap samples were taken), find an approximate 90% bootstrap percentile confidence interval for the true average adult height in the population from which the data were randomly sampled. Provide the interval as well as a one-sentence interpretation of the interval.

    3. By looking at the bootstrap sampling distribution (1,000 bootstrap samples were taken), find an approximate 90% bootstrap SE confidence interval for the true average adult height in the population from which the data were randomly sampled. Provide the interval as well as a one-sentence interpretation of the interval.

  1. Identify the critical \(t\). A random sample is selected from an approximately normal population with unknown standard deviation. Find the degrees of freedom and the critical \(t\)-value (t\(^\star\)) for the given sample size and confidence level.

    1. \(n = 6\), CL = 90%

    2. \(n = 21\), CL = 98%

    3. \(n = 29\), CL = 95%

    4. \(n = 12\), CL = 99%

  1. \(t\)-distribution. The figure below shows three unimodal and symmetric curves: the standard normal (z) distribution, the \(t\)-distribution with 5 degrees of freedom, and the \(t\)-distribution with 1 degree of freedom. Determine which is which, and explain your reasoning.

  1. Find the p-value, I. A random sample is selected from an approximately normal population with an unknown standard deviation. Find the p-value for the given sample size and test statistic. Also determine if the null hypothesis would be rejected at \(\alpha = 0.05\).

     

    1. \(n = 11\), \(T = 1.91\)

    2. \(n = 17\), \(T = -3.45\)

    1. \(n = 7\), \(T = 0.83\)

    2. \(n = 28\), \(T = 2.13\)

  1. Find the p-value, II. A random sample is selected from an approximately normal population with an unknown standard deviation. Find the p-value for the given sample size and test statistic. Also determine if the null hypothesis would be rejected at \(\alpha = 0.01\).

    1. \(n = 26\), \(T = 2.485\)

    2. \(n = 18\), \(T = 0.5\)

  1. Length of gestation, confidence interval. Every year, the United States Department of Health and Human Services releases to the public a large dataset containing information on births recorded in the country. This dataset has been of interest to medical researchers who are studying the relation between habits and practices of expectant mothers and the birth of their children. In this exercise we work with a random sample of 1,000 cases from the dataset released in 2014. The length of pregnancy, measured in weeks, is commonly referred to as gestation. The histograms below show the distribution of lengths of gestation from the random sample of 1,000 births (on the left) and the distribution of bootstrapped means of gestation from 1,500 different bootstrap samples (on the right).15

    1. Given the bootstrap sampling distribution for the sample mean, find an approximate value for the standard error of the mean.

    2. By looking at the bootstrap sampling distribution (1,500 bootstrap samples were taken), find an approximate 99% bootstrap percentile confidence interval for the true average gestation length in the population from which the data were randomly sampled. Provide the interval as well as a one-sentence interpretation of the interval.

    3. By looking at the bootstrap sampling distribution (1,500 bootstrap samples were taken), find an approximate 99% bootstrap SE confidence interval for the true average gestation length in the population from which the data were randomly sampled. Provide the interval as well as a one-sentence interpretation of the interval.

  2. Length of gestation, hypothesis test. In this exercise we work with a random sample of 1,000 cases from the dataset released by the United States Department of Health and Human Services in 2014. Provided below are sample statistics for gestation (length of pregnancy, measured in weeks) of births in this sample.16

    Min Q1 Median Mean Q3 Max SD IQR
    21 38 39 38.7 40 46 2.6 2
    1. What is the point estimate for the average length of pregnancy for all women? What about the median?

    2. You might have heard that human gestation is typically 40 weeks. Using the data, perform a complete hypothesis test, using mathematical models, to assess the 40 week claim. State the null and alternative hypotheses, find the T score, find the p-value, and provide a conclusion in context of the data.

    3. A quick internet search validates the claim of “40 weeks gestation” for humans. A friend of yours claims that there are different ways to measure gestation (starting at first day of last period, ovulation, or conception) which will result in estimates that are a week or two different. Another friend mentions that recent increases in cesarean births is likely to have decreased length of gestation. Do the data provide a mechanism to distinguish between your two friends’ claims?

  1. Interpreting confidence intervals for population mean. For each of the following statements, indicate if they are a true or false interpretation of the confidence interval. If false, provide a reason or correction to the misinterpretation. You collect a large sample and calculate a 95% confidence interval for the average number of cans of sodas consumed annually per adult in the US to be (440 cans, 520 cans), i.e., on average, adults in the US consume just under two cans of soda per day.

    1. 95% of adults in the US consume between 440 and 520 cans of soda per year.

    2. There is a 95% probability that the true population average per adult yearly soda consumption is between 440 and 520 cans.

    3. The true population average per adult yearly soda consumption is between 440 and 520 cans, with 95% confidence.

    4. The average soda consumption of the people who were sampled is between 440 and 520 cans of soda per year, with 95% confidence.

  1. Interpreting p-values for population mean. For each of the following statements, indicate if they are a true or false interpretation of the p-value. If false, provide a reason or correction to the misinterpretation. You are wondering if the average amount of cereal in a 10oz cereal box is greater than 10oz. You collect 50 boxes of cereal, weigh them carefully, find a T score, and a p-value of 0.23.

    1. The probability that the average weight of all cereal boxes is 10 oz is 0.23.

    2. The probability that the average weight of all cereal boxes is greater than 10 oz is 0.23.

    3. Because the p-value is 0.23, the average weight of all cereal boxes is 10 oz.

    4. Because the p-value is small, the population average must be just barely above 10 oz.

    5. If \(H_0\) is true, the probability of observing another sample with an average as or more extreme as the data is 0.23.

  1. Working backwards, I. A 95% confidence interval for a population mean, \(\mu\), is given as (18.985, 21.015). The population distribution is approximately normal and the population standard deviation is unknown. This confidence interval is based on a simple random sample of 36 observations. Assuming that all conditions necessary for inference are satisfied, and using the \(t\)-distribution, calculate the sample mean, the margin of error, and the sample standard deviation.
  1. Working backwards, II. A 90% confidence interval for a population mean is (65, 77). The population distribution is approximately normal and the population standard deviation is unknown. This confidence interval is based on a simple random sample of 25 observations. Assuming that all conditions necessary for inference are satisfied, and using the \(t\)-distribution, calculate the sample mean, the margin of error, and the sample standard deviation.
  1. Sleep habits of New Yorkers. New York is known as “the city that never sleeps”. A random sample of 25 New Yorkers were asked how much sleep they get per night. Statistical summaries of these data are shown below. The point estimate suggests New Yorkers sleep less than 8 hours a night on average. Evaluate the claim that New York is the city that never sleeps keeping in mind that, despite this claim, the true average number of hours New Yorkers sleep could be less than 8 hours or more than 8 hours.

    n Mean SD Min Max
    25 7.73 0.77 6.17 9.78
    1. Write the hypotheses in symbols and in words.

    2. Check conditions, then calculate the test statistic, \(T\), and the associated degrees of freedom.

    3. Find and interpret the p-value in this context. Drawing a picture may be helpful.

    4. What is the conclusion of the hypothesis test?

    5. If you were to construct a 90% confidence interval that corresponded to this hypothesis test, would you expect 8 hours to be in the interval?

  1. Find the mean. You are given the hypotheses shown below. We know that the sample standard deviation is 8 and the sample size is 20. For what sample mean would the p-value be equal to 0.05? Assume that all conditions necessary for inference are satisfied.

    \[H_0: \mu = 60 \quad \quad H_A: \mu \neq 60\]

  1. \(t^\star\) for the correct confidence level. As you’ve seen, the tails of a \(t-\)distribution are longer than the standard normal which results in \(t^{\star}_{df}\) being larger than \(z^{\star}\) for any given confidence level. When finding a CI for a population mean, explain how mistakenly using \(z^{\star}\) (instead of the correct \(t^{*}_{df}\)) would affect the confidence level.
  1. Possible bootstrap samples. Consider a simple random sample of the following observations: 47, 4, 92, 47, 12, 8. Which of the following could be a possible bootstrap samples from the observed data above? If the set of values could not be a bootstrap sample, indicate why not.

    1. 47, 47, 47, 47, 47, 47

    2. 92, 4, 13, 8, 47, 4

    3. 92, 47, 12

    4. 8, 47, 12, 12, 8, 4, 92

    5. 12, 4, 8, 8, 92, 12

  1. Play the piano. Georgianna claims that in a small city renowned for its music school, the average child takes less than 5 years of piano lessons. We have a random sample of 20 children from the city, with a mean of 4.6 years of piano lessons and a standard deviation of 2.2 years.

    1. Evaluate Georgianna’s claim (or that the opposite might be true) using a hypothesis test.

    2. Construct a 95% confidence interval for the number of years students in this city take piano lessons, and interpret it in context of the data.

    3. Do your results from the hypothesis test and the confidence interval agree? Explain your reasoning.

  1. Auto exhaust and lead exposure. Researchers interested in lead exposure due to car exhaust sampled the blood of 52 police officers subjected to constant inhalation of automobile exhaust fumes while working traffic enforcement in a primarily urban environment. The blood samples of these officers had an average lead concentration of 124.32 \(\mu\)g/l and a SD of 37.74 \(\mu\)g/l; a previous study of individuals from a nearby suburb, with no history of exposure, found an average blood level concentration of 35 \(\mu\)g/l. (Mortada et al. 2000)

    1. Write down the hypotheses that would be appropriate for testing if the police officers appear to have been exposed to a different concentration of lead.

    2. Explicitly state and check all conditions necessary for inference on these data.

    3. Test the hypothesis that the downtown police officers have a higher lead exposure than the group in the previous study. Interpret your results in context.


  1. There is a large literature on understanding and improving bootstrap intervals, see Hesterberg (2015) titled “What Teachers Should Know About the Bootstrap” and Hayden (2019) titled “Questionable Claims for Simple Versions of the Bootstrap” for more information.↩︎

  2. Using the formula for the bootstrap SE interval, we find the 95% confidence interval for \(\mu\) is: \(17,140 \pm 2 \cdot 2,891.87 \rightarrow\) ($11,356.26, $22,923.74). We are 95% confident that the true average car price at Awesome Auto is somewhere between $11,356.26 and $22,923.74.↩︎

  3. Based on the percentile values in Figure 19.6, the middle 90% of the bootstrapped standard deviations is given by the 5th ($3,602.5) and the 95th percentiles ($8,737.2). That is, we are 90% confident that the true standard deviation of car prices is between $3,602.5 and $8,737.2. A 90% confidence level indicates that there was not a need for a high level of confidence, such a 95% or 99%. A lower confidence level has higher potential for error, but it also produces a narrower interval.↩︎

  4. More nuanced guidelines would consider further relaxing the particularly extreme outlier check when the sample size is very large. However, we’ll leave further discussion here to a future course.↩︎

  5. We want to find the shaded area above -1.79 (we leave the picture to you). The lower tail area has an area of 0.0447, so the upper area would have an area of \(1 - 0.0447 = 0.9553.\)↩︎

  6. The sample size is under 30, so we check for obvious outliers: since all observations are within 2 standard deviations of the mean, there are no such clear outliers.↩︎

  7. \(\bar{x} \ \pm\ t^{\star}_{14} \times SE \ \to\ 0.287 \ \pm\ 1.76 \times 0.0178 \ \to\ (0.256, 0.318).\) We are 90% confident that the average mercury content of croaker white fish (Pacific) is between 0.256 and 0.318 ppm.↩︎

  8. No, a confidence interval only provides a range of plausible values for a population parameter, in this case the population mean. It does not describe what we might observe for individual observations.↩︎

  9. \(H_0:\) The average 10-mile run time was the same for 2006 and 2017. \(\mu = 93.29\) minutes. \(H_A:\) The average 10-mile run time for 2017 was different than that of 2006. \(\mu \neq 93.29\) minutes.↩︎

  10. With a sample of 100, we should only be concerned if there is are particularly extreme outliers. The histogram of the data does not show any outliers of concern (and arguably, no outliers at all).↩︎

  11. The bdims data used in this exercise can be found in the openintro R package.↩︎

  12. The bdims data used in this exercise can be found in the openintro R package.↩︎

  13. The bdims data used in this exercise can be found in the openintro R package.↩︎

  14. The bdims data used in this exercise can be found in the openintro R package.↩︎

  15. The births14 data used in this exercise can be found in the openintro R package.↩︎

  16. The births14 data used in this exercise can be found in the openintro R package.↩︎

中文

19  单均值的推断

现在我们聚焦于 数值数据的统计推断,我们将再次回顾并扩展 第 11.

本章重要的数据结构是数值响应变量(即结果是定量的)。我们详细介绍的四种数据结构是:一个数值响应变量;一个数值响应变量,其值为成对观测之间的差异;按二元解释变量划分的数值响应变量;以及按具有两个或更多水平的解释变量划分的数值响应变量。在适当的情况下,每种数据结构都将分别使用 第 11, 第 12第 13中的三种方法进行分析:随机化检验、自助法和数学模型。

在构建推断思想的过程中,我们将探讨统计推断中新的基础概念。一个关键的新想法在于估计样本均值(与样本比例相对)在样本之间的变化;所得的值被称为均值的标准误。我们还将介绍一个新的重要数学模型,即 \(t\)-分布(作为 \(t\)-检验的基础)。

在本章中,我们关注样本均值(而不是例如样本中位数或观测值的极差),因为有一个经过充分研究的数学模型可以描述样本均值的行为。我们不会介绍描述其他统计量的数学模型,但下文描述的自助法和随机化技术可以立即扩展到观测数据的任何函数。样本均值将在单组、两组配对、两组独立以及多组的设置中进行计算。针对每种设置所描述的技术会略有不同,但你会发现不同设置之间的结构相似性,这对你大有裨益。

类似于我们可以用正态分布对样本比例 \(\hat{p}\) 的行为建模,在一定条件满足时,样本均值 \(\bar{x}\) 也可以用正态分布建模。然而,我们很快会了解到,在处理样本均值时,一种称为 \(t\)-分布的新分布更为有用。我们将首先学习这个新分布,然后将其用于均值的置信区间和假设检验。

19.1 均值的自助置信区间

设想这样一种情况:你想知道是否应该购买二手车商店 Awesome Autos 的特许经营权。作为规划的一部分,你想知道 Awesome Autos 的一辆汽车的平均售价。为了更清楚地演示这个例子,假设你只能从 Awesome Auto 随机抽取五辆汽车作为样本。(如果这是一个真实的例子,你肯定能够抽取大得多的样本量,甚至可能能够测量整个总体!)

19.1.1 观测数据

图 19.1 展示了来自 Awesome Auto 的一个(很小的)随机观测样本。图中显示了实际的汽车及其售价。

Photographs of 5 different automobiles. The cars are different colors and different makes and models. On top of the image of each car is its price; the five prices range from 9600 dollars to 27000 dollars.
图 19.1:来自 Awesome Auto 的五辆汽车样本。

样本平均车价 $17140.00 是对 Awesome Autos 平均车价的初步猜测。然而,作为一名统计学学习者,你明白基于五个观测值的样本所得出的一个样本均值不一定等于 Awesome Autos 所有汽车的真实总体平均车价。事实上,你可以看到观测到的车价各不相同,标准差为 $7170.29,而且如果从总体中抽取的是另一个容量为五的样本,平均车价肯定会有所不同。幸运的是,正如前几章中对样本比例所做的处理那样,自助法将近似刻画样本均值在样本之间的变异性。

19.1.2 统计量的变异性

正如 第 11, 第 12第 13中介绍的推断思想一样,本章的推断分析方法的基础是量化来自同一总体的两个数据集之间的差异。重申一下,其思路是:我们想知道数据集之间如何不同,但我们绝不会抽取多个观测样本。从同一总体重复抽样是没有意义的,因为如果你有能力抽取更多样本,更大的样本量会比从总体中抽取两个样本对你更有利。因此,我们不是从实际总体中重复抽样,而是使用自助法来衡量样本在总体估计下的表现。

如前所述,为了了解 Awesome Autos 的汽车情况,你从附近的一家 Awesome Auto 门店抽取了五辆汽车作为样本,以此估计在售汽车的价格。 图 19.2 展示了如何使用该样本对 Awesome Autos 未知的车价总体进行近似。

The sample of 5 cars is drawn from a large population with other values (i.e., other car prices) unknown. The sample of five cars is replicated infinitely many times to create a proxy population where the car prices are given by the original dataset in the same relative distribution as measured in the sample.
图 19.2:如前所述,自助法的思想是将手头的样本视为总体的估计。从样本(5 辆汽车)中抽样等同于从一个仅由原始样本中的汽车组成的无限总体中抽样。

通过从估计总体中重复抽样,可以观察到样本之间的变异性。在 图 12.2 可以看到,重复的自助样本彼此之间不同,也与原始总体不同。请记住,自助样本是从同一个(估计的)总体中抽取的,因此自助样本之间的差异完全来自抽样过程的自然变异性。对于当前以样本均值作为所关注统计量的情形,样本与样本之间的变异性可以在 图 19.3.

The sample is shown being taken from the large unknown population. The bootstrap resamples, however, are taken directly from the original sample (sampling with replacement) as if the resamples had been taken from an infinitely large proxy population. Three bootstrap resamples of 5 cars each are shown, each resample is slightly different due to the process of resampling with replacement.
图 19.3:为了估计样本均值的自然变异性,从原始样本中抽取不同的自助样本。请注意,每个自助重抽样样本彼此不同,也与原始样本不同

通过汇总每个自助样本(此处使用样本均值),我们可以直接看到样本均值的变异性, \(\bar{x},\) 在样本之间的变异性。示例情景中 \(\bar{x}_{bs}\) Awesome Auto 汽车的数据展示在 图 19.4.

The sample is shown being taken from the large unknown population. Three bootstrap resamples of 5 cars each are shown; the three resamples have an average car price of 11780 dollars, 19020 dollars, and 20260 dollars, respectively. A histogram representing many bootstrap resamples indicates that the bootstrap averages vary from roughly 10000 dollars to 25000 dollars.
图 19.4:由于每个自助重抽样样本代表不同的汽车集合,因此每个自助重抽样样本的均值将是不同的值。计算每个自助均值,这些值的直方图描述了由抽样过程引起的样本均值的固有自然变异性。

图 19.5 以自助样本均值的直方图汇总了一千个自助样本。自助得到的平均车价从大约 $10,000 到 $25,000 不等。自助百分位置信区间通过找出自助统计量中间的 90%(对于 90% 置信区间)或 95%(对于 95% 置信区间)来求得。

使用 图 19.5,求 Awesome Auto 汽车真实平均车价的 90% 和 95% 自助百分位置信区间。


90% 置信区间为 $12,140 到 $22,007。结论是:我们有 90% 的信心认为 Awesome Auto 的真实平均车价介于 $12,140 和 $22,007 之间。

95% 置信区间为 $11,778 到 $22,500。结论是:我们有 95% 的信心认为 Awesome Auto 的真实平均车价介于 $11,778 到 $22,500 之间。

A histogram of the means of 1000 bootstrapped samples from the Awesome Auto data. The percentiles of the bootstrapped means are given to create 80%, 90%, 95%, or 99% bootstrap confidence intervals for the true mean of the population.
图 19.5:原始的 Awesome Auto 数据被自助重抽样 1,000 次。该直方图展示了平均车价在样本与样本之间的变异性。

19.1.3 自助标准误(SE)置信区间

第 17.2 节,另一种构建自助置信区间的方法直接使用自助统计量(此处为自助均值)变异性的计算。如果自助分布相对对称且呈钟形,则可以使用前几章数学模型中熟悉的公式构建 95% 自助标准误置信区间:

\[\mbox{point estimate} \pm 2 \cdot SE_{BS}\] 数字 2 是与置信区间的“95%”部分相关的一个近似值(请记住 68-95-99.7 法则)。正如将在 第 19.2 节中看到的,一个新的分布( \(t\)-分布)将应用于对数值变量的大多数数学推断。然而,由于自助法并非基于与本文中给出的数学方法相同的理论,我们坚持使用标准正态分位数(在 R 中使用函数 qnorm() 来查找 95% 以外的其他置信水平对应的正态分位数)。1

解释自助法均值的 standard error (SE)(标准误)是如何计算的,以及它衡量的是什么。


自助法均值的标准误衡量的是各次重抽样所得均值之间的变异程度。自助法标准误是对均值标准误的一个很好的近似,就好像我们从原始总体中重复抽取了样本一样(我们已同意不会这样做,因为会浪费资源)。

在实际操作上,我们可以使用与 第 5中相同的计算方法来求自助法均值的标准差。也就是说,自助法均值就是我们要测量其变异性的单个观测值。

虽然我们不会在这个概念上花费太多精力,但你可能想知道标准误和标准差之间的一些区别。 标准误 描述的是统计量(例如样本均值或样本比例)在样本与样本之间的变化情况。而 标准差 可以被看作是应用于任何一列数字的函数,衡量这些数字与其自身平均值的偏离程度。因此,你可以对一列狗的身高计算标准差,也可以对从重抽样数据中得到的一列自助法均值计算标准差。注意,对自助法均值计算的标准差被称为均值的标准误(bootstrap standard error of the mean)。

事实证明,来自 图 19.5 的自助法均值的标准差为 $2,891.87(如果我们从总体中重复抽样,该值是对样本均值标准误的一个极好的近似)。(注意:在 R 中该计算使用了函数 sd()。)观测价格的平均值为 $17,140,我们将把样本平均值视为 \(\mu.\) 的最佳猜测点估计。 \(\mu\) 使用自助法标准误置信区间公式,求出2

(Awesome Auto 汽车真实平均成本)的置信区间并对其进行解释。 \(\mu\) 比较和对比通过求自助法均值的分位数与通过求自助法均值的标准误这两种不同方法为 应该 是否完全相同?


  • 百分位数区间:($11,778, $22,500)
  • 标准误区间:($11,356.26, $22,923.74)

这两个区间是用不同的方法构建的,因此它们不完全相同并不令人意外。不过,令人欣慰的是,这两种方法给出了非常接近的区间近似。关于哪种数据结构最适合百分位数区间、哪种最适合标准误区间的技术细节超出了本书的范围。但是,样本量越大,区间估计就会越好(也越接近)。

19.1.4 标准差的 Bootstrap 百分位数置信区间

假设我们想了解 Awesome Auto 的汽车价格的变异程度。也就是说,你关注的不再是汽车的平均价格,而是 Awesome Auto 所有汽车价格的 标准差\(\sigma.\) 你可能已经意识到,样本标准差 \(s,\) 可以作为目标参数的一个很好的 点估计 :即总体标准差 \(\sigma.\) 这五个观测值计算出的点估计为 \(s = \$7,170.286.\) 虽然 \(s = \$7,170.286\) 可能是 \(\sigma,\) 的一个不错的猜测,但我们更希望得到目标参数的区间估计。尽管有一个描述 \(s\) 在不同样本之间如何变化的数学模型,但本书不会介绍该数学模型。相反,可以使用自助法(bootstrapping)来求出该参数的置信区间 \(\sigma.\) 使用与之前介绍的置信区间相同的技术, \(\mu,\) 这里我们求 \(\sigma.\)

描述 图 19.6.


中所示标准差的 bootstrap 分布。

使用 图 19.6该分布左偏,中心接近 $7,170.286,即来自原始数据的点估计。该分布中的大多数观测值位于 $0 到 $10,000 之间。3

A histogram of the standard deviations of 1000 bootstrapped samples from the Awesome Auto data. The percentiles of the bootstrapped standard deviations are given to create 80%, 90%, 95%, or 99% bootstrap confidence intervals for the true standard deviation of the population.
,求并解释 Awesome Auto 汽车价格总体标准差的 90% bootstrap 百分位数置信区间。

19.1.5 图 19.6:对原始的 Awesome Auto 数据进行 1,000 次 bootstrap。直方图展示了汽车价格标准差在样本之间的变异性。

Bootstrap 并不是解决小样本问题的方法!

19.2 上面给出的例子仅使用了只有五个观测值的样本。与基于数学模型的分析方法一样,当从总体中抽取了较大的随机样本时,bootstrap 的效果最好。Bootstrap 是一种在数学模型未知时捕捉统计量变异性的方法(它不是应对小样本的方法)。可以猜到,随机样本越大,该样本就越能准确地代表所研究的总体。

均值的数学模型\(\sigma\)与样本比例一样,样本均值的变异性可以由中心极限定理给出的数学理论很好地描述。然而,由于缺乏关于总体固有变异性的信息( \(t\)),在进行假设检验或置信区间分析时,会使用

19.2.1 分布来代替标准正态分布。

样本均值的数学分布 \(\mu,\) 在满足某些条件时,样本均值趋于服从以总体均值 \(\sigma\) 为中心的正态分布。此外,我们可以利用总体标准差(population standard deviation)和样本量计算样本均值的标准误。 \(n.\)

样本均值的中心极限定理。

当我们从均值为 \(n\) 的总体中收集足够大的 \(\mu\) ,标准差为 \(\sigma,\) 个独立观测样本时, \(\bar{x}\) 的抽样分布将近似服从正态分布,且

\[\text{Mean} = \mu \qquad \text{Standard Error }(SE) = \frac{\sigma}{\sqrt{n}}\]

在深入探讨使用 \(\bar{x},\) 进行置信区间估计和假设检验之前,我们首先需要介绍两个主题:

  • 当我们用正态分布对 \(\hat{p}\) 进行建模时,必须满足某些条件。使用 \(\bar{x}\) 进行分析的条件稍微复杂一些,下面我们将讨论如何使用数学模型检验推断的条件。
  • 标准误取决于总体标准差 \(\sigma.\) 。然而,我们很少知道 \(\sigma,\) ,而是必须对其进行估计。由于这种估计本身并不完美,我们使用一种称为 \(t\)分布的新分布来解决这个问题。

19.2.2 评估对 \(\bar{x}\)

建模所需的两个条件。应用样本均值的中心极限定理需要满足两个条件 \(\bar{x}:\)

  • 独立性。 样本观测值必须相互独立。满足这一条件最常见的方式是样本来自总体的简单随机样本。如果数据来自一个随机过程,类似于掷骰子,这也能满足独立性条件。

  • 正态性。 当样本量较小时,我们还要求样本观测值来自正态分布的总体。对于越来越大的样本量,我们可以越来越放宽这一条件。这一条件比较模糊,难以评估,因此接下来我们介绍几条用于检验它的经验法则。

进行正态性检验的一般规则。

没有完美的方法来检验正态性条件,因此我们改用基于极端观测值的数量和大小的两条一般规则。注意,判断正态近似是否适用往往需要通过练习来积累经验。

  • 小样本 \(n\): 如果样本量 \(n\) 较小且数据中 没有明显的离群点 ,那么我们通常假设数据来自近似正态分布,以满足该条件。
  • 大样本 \(n\): 如果样本量 \(n\) 较大且没有 特别极端 的离群点,那么即使单个观测值的潜在分布不是正态的,我们通常也假设 \(\bar{x}\) 的抽样分布近似正态。

判断 \(n\) 被视为较小或较大的一些指导原则如下:样本量为 15 时轻微偏度可以接受,样本量为 30 时中等偏度可以接受,样本量为 60 时强偏度可以接受。

在这门统计学入门课程中,并不要求你对正态性条件做出完美的判断。但是,你应该能够根据经验法则处理显而易见的情况。4

考虑 图 19.7 中提供的来自不同总体简单随机样本的四幅图。它们的样本量分别为 \(n_1 = 15\)\(n_2 = 50.\)

在每种情况下,独立性和正态性条件是否都满足?


每个样本都来自其相应总体的简单随机样本,因此独立性条件得到满足。接下来我们用经验法则逐一检验正态性条件。

第一个样本的观测值少于 30 个,因此我们要留意是否存在明显的离群值。结果没有;虽然直方图右侧有一个小间隙,但这个间隙很小,且该小样本中超过 20% 的观测值位于间隙左侧,所以我们很难称这些为明显的离群值。由于没有明显的离群值,可以合理地认为正态性条件得到满足。

第二个样本的样本量大于 30,并且包含一个离群值,它到分布中心的距离大约是次远观测值的 5 倍。这是一个特别极端的离群值的例子,因此正态性条件不满足。

使用箱线图将数据可视化通常也很有帮助,可以用来评估偏度和离群值的存在。每幅直方图下方的箱线图证实了我们的结论:第一个样本没有任何离群值,而第二个样本有离群值,其中一个离群值比其他离群值尤为极端。

Two histogram and box plot pairs. The first pair of plots describes a sample size of 15 and the points are distributed between zero and six with no outliers. The second pair of plots describes a sample of size 50 and the points are distributed between zero and six with one additional outlying point above 20.
图 19.7:来自两个不同总体的样本的直方图。

在实践中,通常还要进行心理上的检验,以评估我们是否有理由认为潜在总体存在中等偏度(如果 \(n < 30)\) 或存在特别极端的离群值 \((n \geq 30)\) ,超出了我们在数据中观察到的范围。例如,考虑 Twitter 上每个账户的粉丝数量,然后想象这个分布。绝大多数账户积累的粉丝只有几千或更少,而只有极小一部分账户积累了数千万粉丝,这意味着该分布极度偏斜。当我们知道数据来自这样一个极度偏斜的分布时,就需要花一些功夫来理解样本量需要多大才能满足正态性条件。

19.2.3 t 分布简介

在实践中,我们无法直接计算 \(\bar{x}\) 由于我们不知道总体标准差, \(\sigma.\) 在计算样本比例的标准误时我们遇到过类似的问题,它依赖于总体比例 \(p.\) 我们在比例情境中的解决方案是在计算标准误时用样本值代替总体值。我们将采用类似的策略来计算 \(\bar{x},\) 的标准误,即使用样本标准差 \(s\) 代替 \(\sigma:\)

\[SE = \frac{\sigma}{\sqrt{n}} \approx \frac{s}{\sqrt{n}}\]

当我们拥有大量数据并能准确估计 \(\sigma\) 使用 \(s\) 时,这种策略往往效果很好。然而,样本较小时估计的精确度较低,这会导致在使用正态分布对 \(\bar{x}.\)

进行建模时出现问题。 \(t\)我们会发现,在推断计算中使用一种称为 \(t\)分布的新分布很有用。 图 19.8分布(在

中以实线表示)呈钟形。然而,它的尾部比正态分布更厚,这意味着观测值落在距均值两个标准差之外的可能性比正态分布下更大。 \(t\)分布额外厚的尾部恰好是解决(由于 T 分数额外变异性导致的)使用 \(s\) 代替 \(\sigma\) 的 IQR,在 \(SE\) 计算问题时所需的修正。

Two symmetric bell-shaped curves on top of one another. One is a normal curve with smaller tails and a higher peak in the middle. The other is a t-distribution with longer tails, meaning that there are more observations far from the center of a t-distribution than of a normal distribution.
图 19.8: \(t\)分布与正态分布的比较。

\(t\)分布始终以零为中心,并且只有一个参数:自由度。 自由度 描述了钟形 \(t\)-分布的精确形式。图 \(t\)中展示了几个 图 19.9 -分布,并与正态分布进行了比较。与卡方分布类似, \(t\)-分布的形状也取决于自由度。

一般来说,当样本量 \(t\)\(df = n - 1\)\(n.\) -分布来对样本均值进行建模。也就是说,当观测值更多时,自由度会更大, \(t\)-分布看起来会更接近标准正态分布;当自由度约为 30 或更大时, \(t\)-分布与正态分布几乎无法区分。

A normal distribution and four t distributions, all super imposed on top of one another. The smaller the degrees of freedom, the wider the tails in the t distribution.
图 19.9:自由度越大, \(t\)-分布就越接近标准正态分布。

自由度:df。

自由度描述了 \(t\)-分布的形状。自由度越大,该分布就越接近正态分布。

在使用 \(\bar{x}\) -分布进行建模时,使用 \(t\)-分布比正态分布在分析数值数据时具有更大的灵活性。在实践中,通常使用统计软件(如 R、Python 或 SAS)来进行这些分析。在 R 中,用于计算 \(df = n - 1.\)

\(t\)-分布下概率的函数是 \(t\)(它应该看起来与之前的 R 函数 pt() 相似)。别忘了,使用 pnorm()pchisq()-分布时,必须始终指定自由度! \(t\)对于下面的示例和引导练习,你可能需要使用表格或统计软件来找到答案。我们建议尝试这些问题,以便感受

-分布的宽度如何随自由度而变化。无论你选择哪种方法,都请使用下面的示例来应用你的方法,以确认你对 \(t\)的自由度为 18 的 \(t\)分布。

自由度为 19 的 \(t\)让我们先画出图形并给 -2.10 以下的区域涂上阴影。


使用统计软件,我们可以得到精确值:0.0250。

A t distribution with 18 degrees of freedom. The area below -2.10 has been shaded.

自由度为 20 的 𝑡-分布中,有多大比例位于 1.65 以上?

# use pt() to find probability under the t-distribution
pt(-2.10, df = 18)
[1] 0.025

请注意,当自由度为 20 时,这个


请注意,在自由度为20的情况下, \(t\)-分布相对接近正态分布。对于正态分布,这大约对应于 0.05,因此我们应该期望 \(t\)-分布给出一个类似的值。使用统计软件,我们可以得到一个精确值:0.0573。

# use pt() to find probability under the t-distribution
1 - pt(1.65, df = 20)
[1] 0.0573

一个 \(t\)-分布(自由度为 2)如下所示。估计该分布中落在距均值 3 个单位以上(高于或低于)的部分所占的比例。

A t distribution with 2 degrees of freedom. The area below negative 3 and above positive 3 has been shaded.


由于自由度如此之少, \(t\)-分布将给出与正态分布明显不同的值。在正态分布下,使用 68-95-99.7 规则,该面积约为 0.003。对于自由度为 \(t\)\(df = 2,\) -分布,超过 3 个单位的双尾面积总计为 0.0955。这个面积与我们从正态分布得到的值截然不同。

# use pt() to find probability under the t-distribution
pt(-3, df = 2) + (1 - pt(3, df = 2))
[1] 0.0955

自由度为 19 的 \(t\)-分布中,有多大比例落在 -1.79 个单位以上?请使用你偏好的方法求尾部面积。5

19.2.4 单样本 t 区间

让我们通过一个关于海豚肌肉中汞含量的例子,初次体验 \(t\)-分布的应用。汞浓度升高对海豚以及其他偶尔食用海豚的动物(如人类)来说都是一个重要问题。

A photograph of a Risso's dolphin in the water.
图 19.10:一只灰海豚。照片由 Mike Baird 提供,www.bairdphotos.com。CC BY 2.0 许可。

我们将使用来自日本太地地区的 19 只灰海豚样本,确定海豚肌肉中平均汞含量的置信区间。数据总结于 表 19.1中。观测到的最小值和最大值可用于评估是否存在明显的离群值。

表 19.1:来自太地地区的 19 只灰海豚肌肉中汞含量的汇总。测量单位为每湿克肌肉中汞的微克数 \((\mu\)g/湿重 g)。
n 平均数 标准差 最小值 最大值
19 4.4 2.3 1.7 9.2

该数据集是否满足独立性和正态性条件?


观测值是简单随机样本,因此可以合理地假设这些海豚是相互独立的。 表 19.1 中的汇总统计量未显示任何明显的异常值,所有观测值均在均值的 2.5 个标准差范围内。基于这一证据,正态性条件似乎是合理的。

在正态模型中,我们使用 \(z^{\star}\) 和标准误来确定置信区间的宽度。当使用 \(t\)-分布来计算:

\[ \begin{aligned} \text{point estimate} \ &\pm\ t^{\star}_{df} \times SE \\ \bar{x} \ &\pm\ t^{\star}_{df} \times \frac{s}{\sqrt{n}} \end{aligned} \]

时,我们对置信区间公式稍作修改。 表 19.1利用 \(n = 19\) 中的汇总统计量,计算


只海豚体内汞含量平均值的标准误。 \(s\)\(n\) 我们将 \(SE = \frac{s}{\sqrt{n}} = \frac{2.3}{\sqrt{19}} = 0.528.\)

代入公式: \(t^{\star}_{df}\) 数值 \(t\)\(df\)\(t^{\star}_{df}\) 分布得到的临界值。该临界值的求法与正态分布相同:我们找到这样的 \(t\)\(df\) 自由度在距离 0 为 \(t^{\star}_{df}\) 的范围内与所关注的置信水平相匹配。

\(n = 19,\) 时,合适的自由度是多少?求出该自由度下 95% 置信水平对应的 \(t^{\star}_{df}\)


自由度很容易计算: \(df = n - 1 = 18.\)

使用统计软件,我们找到上尾等于 2.5% 的临界值: \(t^{\star}_{18} = 2.10.\) -2.10 以下的面积同样等于 2.5%。也就是说,95% 的 \(t\)\(df = 18\) )位于 0 附近 2.10 个单位之内。

# use qt() to find the t-cutoff (with 95% in the middle)
qt(0.025, df = 18)
[1] -2.1
qt(0.975, df = 18)
[1] 2.1

单个样本的自由度。

如果样本有 \(n\) 个观测值,且我们正在考察单个均值,那么我们使用自由度为 \(t\)\(df=n-1\) 的t分布上的指定分位数计算得出。

计算并解释瑞索海豚体内汞含量平均值的95%置信区间。


我们可以构建置信区间如下

\[ \begin{aligned} \bar{x} \ &\pm\ t^{\star}_{18} \times SE \\ 4.4 \ &\pm\ 2.10 \times 0.528 \\ (3.29 \ &, \ 5.51) \end{aligned} \] 我们有95%的把握认为瑞索海豚肌肉中的平均汞含量介于3.29和5.51之间 \(\mu\)克/湿重克,这一数值被认为极高。

计算均值的 \(t\)-置信区间, \(\mu.\)

基于 \(n\) 个独立且近似正态的观测值样本,总体均值的置信区间为

\[ \begin{aligned} \text{point estimate} \ &\pm\ t^{\star}_{df} \times SE \\ \bar{x} \ &\pm\ t^{\star}_{df} \times \frac{s}{\sqrt{n}} \end{aligned} \]

其中 \(\bar{x}\) 是样本均值, \(t^{\star}_{df}\) 对应于置信水平和自由度 \(df,\)\(SE\) 是由样本估计的标准误。

FDA的网页提供了一些关于鱼类汞含量的数据。基于15条白姑鱼(太平洋)的样本,计算得到的样本均值和标准差分别为0.287和0.069 ppm(百万分率)。这15个观测值的范围在0.18到0.41 ppm之间。我们将假设这些观测值是独立的。根据数据的汇总统计,你对单个观测值的正态性条件有任何异议吗?6

估计 \(\bar{x} = 0.287\) 的标准误 \(t\)ppm,使用上一道引导练习中的数据汇总。如果我们要使用 \(t^{\star}_{df}.\)


分布来构建汞含量实际均值的90%置信区间,请指出自由度和,并计算。 \(SE = \frac{0.069}{\sqrt{15}} = 0.0178.\) 自由度: \(df = n - 1 = 14.\) 由于目标是90%的置信区间,我们选择 \(t_{14}^{\star}\) 使得双尾面积为0.1: \(t^{\star}_{14} = 1.76.\)

# use qt() to find the t-cutoff (with 90% in the middle)
qt(0.05, df = 14)
[1] -1.76
qt(0.95, df = 14)
[1] 1.76

利用之前的引导练习和示例中的信息与结果,计算鲈鱼(太平洋)平均汞含量的90%置信区间。7

之前引导练习中得到的90%置信区间为0.256 ppm至0.318 ppm。我们能否说90%的鲈鱼(太平洋)的汞含量介于0.256和0.318 ppm之间?8

回忆一下,误差幅度由标准误差定义。 \(\bar{x}\) 的误差幅度可以直接从 \(SE(\bar{x}).\)

误差幅度(针对 \(\bar{x}.\)

误差幅度为 \(t^\star_{df} \times s/\sqrt{n}\) ,其中 \(t^\star_{df}\) 由自由度为 df 的t分布上的指定分位数计算得出。

19.2.5 单样本t检验

既然我们已经使用 \(t\)分布对均值构建了置信区间,接下来让我们快速进入均值的假设检验。

评估单个均值的检验统计量是T。

T分数是一个比值,衡量样本均值与假设均值的差异相对于观测值变异程度的大小。

\[ T = \frac{\bar{x} - \mbox{null value}}{s/\sqrt{n}} \]

当原假设为真且条件满足时,T 服从自由度为 \(df = n - 1.\)

F 统计量是各组之间差异程度(MSG)与组内观测值变异程度(MSE)的比值。

  • 独立观测。
  • 的 t 分布。

大样本且无极端离群值。

run17 数据可以在 cherryblossom R 包中找到。

美国典型的跑步者随着时间的推移是变快了还是变慢了?我们在樱花赛(Cherry Blossom Race)的背景下考虑这个问题,这是每年春季在华盛顿特区举行的一项 10 英里赛跑。2006 年所有完成樱花赛的跑步者的平均时间为 93.29 分钟(93 分钟约 17 秒)。我们想利用 2017 年樱花赛 100 名参赛者的数据来确定该赛事的跑步者是变快了还是变慢了,另一种可能是没有变化。9

在此背景下,适当的假设是什么? T 分数 T 分数 \(t\),因为我们使用

分布来计算尾部面积。然后,我们使用与之前相同的思路求 p 值:找到抽样分布下的单尾面积,并将其加倍。

但首先,我们要检查条件。10

数据来自所有参与者的简单随机样本,因此观测值是相互独立的。下面给出了比赛时间的直方图,以评估我们是否可以继续进行 t 检验。正态性条件是否满足? \(t\)由于独立性和正态性条件均满足,我们可以使用


分布进行假设检验。来自 2017 年樱花赛的 100 名跑步者样本的样本均值和样本标准差分别为 98.78 分钟和 16.59 分钟。回顾一下,2006 年的平均跑步时间为 93.29 分钟。求检验统计量和 p 值。你的结论是什么?

\[ SE = 16.6 / \sqrt{100} = 1.66 \] 为了求检验统计量(T 分数),我们首先必须确定标准误: T 分数 来计算 T 分数 \(SE:\)

\[ T = \frac{98.8 - 93.29}{1.66} = 3.32 \] 对于 \(df = 100 - 1 = 99,\) 我们可以使用统计软件(或 \(t\)-表)确定单尾面积为 0.000631,将其乘以 2 得到 p 值:0.00126。

# use pt() to find the left tail and multiply by 2 to get both tails
(1 - pt(3.32, df = 99)) * 2
[1] 0.00126

由于 p 值小于 0.05,我们拒绝原假设。也就是说,数据提供了令人信服的证据,表明 2017 年樱花长跑(Cherry Blossom Run)的平均跑步时间与 2006 年的平均值不同。

在使用 \(t\)-分布时,我们使用 T 分数(类似于 Z 分数)。

为了帮助我们记住使用 \(t\)-分布,我们用 \(T\) 表示检验统计量,并通常将其称为 T 分数。Z 分数和 T 分数的计算方式完全相同,且在概念上完全一致:两者都表示观测值距离原假设值有多少个标准误。

19.3 本章复习

19.3.1 小结

在本章中,我们将随机化 / 自助法 / 数学模型范式扩展到涉及定量变量的问题。当只有一个感兴趣的变量时,我们通常是对总体均值进行假设检验或构建置信区间。但请注意,自助法也可用于其他统计量,例如总体中位数或总体四分位距(IQR)。当比较两个组之间的定量变量时,问题通常聚焦于总体均值之差(有时是配对均值之差)。围绕一个样本、两个样本和配对样本均值的问题使用 t 分布来解决;因此它们被称为“t 检验”和“t 区间”。当考虑跨 3 个或更多组的定量变量时,会应用一种称为方差分析(ANOVA)的方法。同样,几乎所有研究问题都可以通过计算方法(例如随机化检验或自助法)或数学模型来解决。我们继续强调实验设计在得出研究结论方面的重要性。特别是,请记住变异性可能来自不同的来源(例如,随机抽样与随机分配,参见 图 2.8).

19.3.2 术语

本章中介绍的术语列于 表 19.2。如果您不确定其中一些术语的含义,我们建议您回到正文中复习它们的定义。您应该能够很容易地发现它们是 粗体文本.

表 19.2:本章介绍的术语。
中心极限定理 点估计 T 分数(单均值)
自由度 观测值的标准差 t 分布
数值数据 SE 单一均值 t 检验

19.4 练习

奇数编号习题的答案见 附录 A.19.

  1. 统计量与参数:单一均值。 以下每个情境都是为了评估某个平均值而设计的。请针对每个情境,用文字指出:统计量和参数。

    1. 一项研究询问了 25 名纽约人每晚的睡眠时间。

    2. 加州两所不同大学的研究人员收集了本科生身高的信息。

  1. 统计量与参数:单一均值。 以下每个情境都是为了评估某个平均值而设计的。请针对每个情境,用文字指出:统计量和参数。

    1. Georgianna 从某个特定城市抽取了 20 名儿童作为样本,并测量他们每个人学弹钢琴的年数。

    2. 交通警察(经常暴露于汽车尾气中的铅)测量了他们血液中的铅含量。

  1. 成年人身高。 研究人体测量学的研究人员收集了 507 名经常运动的成年人的身体测量数据,以及年龄、体重、身高和性别。下面提供了身高分布(以厘米 cm 为单位测量)的汇总统计量,以及一个直方图。11 (Heinz 等人,2003)

    最小值 147.2
    Q1 163.8
    中位数 170.3
    平均数 171.1
    Q3 177.8
    最大值 198.1
    标准差 9.4
    IQR 14.0

    1. 经常运动的成年人平均身高和中位数的点估计是多少?

    2. 经常运动的成年人身高标准差和四分位距(IQR)的点估计是多少?

    3. 身高 1 米 80 厘米(180 cm)的人是否算异常高?身高 1 米 55 厘米(155cm)的人是否算异常矮?请解释你的理由。

    4. 研究人员再抽取一个由身体活跃的成年人组成的随机样本。你预期这个新样本的均值和标准差会是上面给出的那些数值吗?请解释你的理由。

    5. 如果所抽取的个体样本等价于一个简单随机样本,那么得到的样本均值就是所有活跃个体平均身高的点估计。我们用什么度量来量化这种估计的变异性?在假设数据为简单随机样本的条件下,用原始样本的数据计算这个量。

  1. 成年人身高,标准误。 507 名身体活跃的成年人身高的均值为 171 厘米,标准差为 9.4 厘米。请为以下样本量的均值标准误提供估计值。12 (Heinz 等人,2003)

    1. n = 10

    2. n = 50

    3. n = 100

    4. n = 1000

    5. 均值的标准误是一个描述什么的数值?

  1. 成年人身高与幼儿园儿童身高。 507 名身体活跃的成年人身高的均值为 171 厘米,标准差为 9.4 厘米。13 (Heinz 等人,2003)

    1. 你预期几百名幼儿园儿童身高的标准差会高于还是低于 9.4 厘米?请解释你的理由。

    2. 假设抽取许多个样本量为 100 的成年人样本,另外单独抽取许多个样本量为 100 的幼儿园儿童样本。对每个样本计算平均身高。哪一组样本均值会有更大的均值标准误,是成年人样本均值还是幼儿园儿童样本均值?

  1. 成年人身高,自助法区间。 研究人体测量学的研究人员收集了 507 名身体活跃的成年人的身体测量数据,以及年龄、体重、身高和性别。下面的直方图显示了来自 1,000 个不同自助法样本的自助法均值的样本分布。14 (Heinz 等人,2003)

    1. 给定样本均值的自助抽样分布,求均值标准误的近似值。

    2. 通过观察自助抽样分布(抽取了1,000个自助样本),为从中随机抽取数据的总体的真实平均成人身高求一个近似的90%自助百分位置信区间。给出该区间以及对该区间的一句话解释。

    3. 通过观察自助抽样分布(抽取了1,000个自助样本),为从中随机抽取数据的总体的真实平均成人身高求一个近似的90%自助标准误(SE)置信区间。给出该区间以及对该区间的一句话解释。

  1. 确定临界 \(t\)。从一个近似正态且标准差未知的总体中抽取一个随机样本。根据给定的样本量和置信水平,求自由度和临界 \(t\)值(t\(^\star\))。

    1. \(n = 6\),CL = 90%

    2. \(n = 21\),CL = 98%

    3. \(n = 29\),CL = 95%

    4. \(n = 12\),CL = 99%

  1. \(t\)分布。 下图显示了三条单峰且对称的曲线:标准正态(z)分布、自由度为5的 \(t\)分布,以及自由度为1的 \(t\)分布。请判断哪条曲线对应哪个分布,并解释你的理由。

  1. 求p值,I。 从一个标准差未知、近似正态的总体中抽取一个随机样本。求给定样本量和检验统计量对应的 p 值。并判断在 \(\alpha = 0.05\).

     

    1. \(n = 11\), \(T = 1.91\)

    2. \(n = 17\), \(T = -3.45\)

    1. \(n = 7\), \(T = 0.83\)

    2. \(n = 28\), \(T = 2.13\)

  1. 求p值,II。 从一个标准差未知、近似正态的总体中抽取一个随机样本。求给定样本量和检验统计量对应的 p 值。并判断在 \(\alpha = 0.01\).

    1. \(n = 26\), \(T = 2.485\)

    2. \(n = 18\), \(T = 0.5\)

  1. 妊娠时长,置信区间。 每年,美国卫生与公众服务部都会向公众发布一个大型数据集,其中包含该国记录的出生信息。该数据集一直受到研究准妈妈的习惯与行为同其孩子出生之间关系的医学研究者的关注。在本练习中,我们使用该部门 2014 年发布数据集中的 1,000 个案例的随机样本。以周为单位的妊娠时长通常被称为孕期。下面的直方图显示了 1,000 例出生的随机样本的孕期时长分布(左图),以及 1,500 个不同自助样本的孕期均值分布(右图)。15

    1. 给定样本均值的自助抽样分布,求均值标准误的近似值。

    2. 通过观察自助抽样分布(共抽取了 1,500 个自助样本),求出数据所抽取自的总体的真实平均孕期时长的近似 99% 自助百分位置信区间。给出该区间,并用一句话解释该区间的含义。

    3. 通过观察自助抽样分布(共抽取了 1,500 个自助样本),求出数据所抽取自的总体的真实平均孕期时长的近似 99% 自助 SE 置信区间。给出该区间,并用一句话解释该区间的含义。

  2. 妊娠时长,假设检验。 在本练习中,我们使用美国卫生与公众服务部 2014 年发布数据集中的 1,000 个案例的随机样本。下面给出了该样本中出生的孕期(以周为单位的妊娠时长)的样本统计量。16

    最小值 Q1 中位数 平均数 Q3 最大值 标准差 IQR
    21 38 39 38.7 40 46 2.6 2
    1. 所有女性平均妊娠时长的点估计是多少?中位数呢?

    2. 你可能听说过人类孕期通常为 40 周。利用这些数据,使用数学模型进行一次完整的假设检验,以评估 40 周这一说法。陈述原假设和备择假设,求出 T 分数,求出 p 值,并结合数据背景给出结论。

    3. 快速上网搜索可以验证人类“孕期 40 周”的说法。你的一位朋友声称,测量孕期有不同的方法(从末次月经第一天、排卵或受孕开始计算),这会导致估计结果相差一两周。另一位朋友提到,最近剖腹产的增加很可能缩短了孕期时长。这些数据是否提供了一种机制来区分你两位朋友的说法?

  1. 解释总体均值的置信区间。 对于下列每一条陈述,指出其是否为对置信区间的正确或错误解释。如果是错误的,请给出理由或更正。你收集了一个大样本,并计算出美国成年人每年平均消费汽水罐数的 95% 置信区间为(440 罐,520 罐),即平均而言,美国成年人每天消费不到两罐汽水。

    1. 95% 的美国成年人每年消费 440 到 520 罐汽水。

    2. 真实总体人均年汽水消费量在 440 到 520 罐之间的概率为 95%。

    3. 在95%的置信水平下,总体成年人每年平均汽水消费量介于440到520罐之间。

    4. 在95%的置信水平下,被抽样人群的平均汽水消费量介于每年440到520罐之间。

  1. 解释总体均值的p值。 对于以下每个陈述,指出它们是对p值的正确解释还是错误解释。如果是错误的,请给出原因或对错误解释的更正。你想知道10盎司麦片盒中麦片的平均含量是否大于10盎司。你收集了50盒麦片,仔细称重,计算出一个T分数,得到p值为0.23。

    1. 所有麦片盒的平均重量为10盎司的概率是0.23。

    2. 所有麦片盒的平均重量大于10盎司的概率是0.23。

    3. 因为p值为0.23,所以所有麦片盒的平均重量是10盎司。

    4. 因为p值很小,所以总体平均值一定只比10盎司高出一点点。

    5. 如果 \(H_0\) 为真,则观察到另一个样本的平均值与数据一样极端或更极端的概率是0.23。

  1. 逆向求解,I。 总体均值的一个95%置信区间 \(\mu\)为(18.985, 21.015)。总体分布近似正态,总体标准差未知。该置信区间基于36个观测值的简单随机样本。假设满足推断所需的所有条件,并使用 \(t\)-分布,计算样本均值、误差幅度和样本标准差。
  1. 逆向求解,II。 总体均值的一个90%置信区间为(65, 77)。总体分布近似正态,总体标准差未知。该置信区间基于25个观测值的简单随机样本。假设满足推断所需的所有条件,并使用 \(t\)-分布,计算样本均值、误差幅度和样本标准差。
  1. 纽约人的睡眠习惯。 纽约被称为“不夜城”。一项随机抽取了25名纽约人的样本被问及他们每晚睡多长时间。这些数据的统计摘要如下所示。点估计表明纽约人平均每晚睡眠时间少于8小时。请评估“纽约是不夜城”这一说法,同时要注意,尽管有这一说法,纽约人实际平均睡眠时间可能少于8小时,也可能多于8小时。

    n 平均数 标准差 最小值 最大值
    25 7.73 0.77 6.17 9.78
    1. 用符号和文字写出假设。

    2. 检查条件,然后计算检验统计量 \(T\)及其相应的自由度。

    3. 在此情境下求出并解释 p 值。画图可能有帮助。

    4. 假设检验的结论是什么?

    5. 如果要构造与该假设检验相对应的90%置信区间,你预计8小时会落在该区间内吗?

  1. 求均值。 给定如下所示的假设。已知样本标准差为8,样本量为20。样本均值等于多少时,p 值才等于0.05?假设满足推断所需的所有条件。

    \[H_0: \mu = 60 \quad \quad H_A: \mu \neq 60\]

  1. \(t^\star\) 对应正确的置信水平。 正如你所见, \(t-\)分布的尾部比标准正态分布更长,这导致对于任何给定的置信水平, \(t^{\star}_{df}\) 都大于 \(z^{\star}\) 。在求总体均值的置信区间时,请解释错误地使用 \(z^{\star}\) (而不是正确的 \(t^{*}_{df}\))会如何影响置信水平。
  1. 可能的自助抽样样本。 考虑以下观测值的简单随机样本:47, 4, 92, 47, 12, 8。下列哪一项可能是来自上述观测数据的可能的自助抽样样本?如果某组数值不可能是自助抽样样本,请说明原因。

    1. 47, 47, 47, 47, 47, 47

    2. 92, 4, 13, 8, 47, 4

    3. 92, 47, 12

    4. 8, 47, 12, 12, 8, 4, 92

    5. 12, 4, 8, 8, 92, 12

  1. 弹钢琴。 Georgianna 声称,在一座以音乐学校闻名的小城市里,儿童平均学习钢琴的时间少于 5 年。我们从该城市随机抽取了 20 名儿童作为样本,其学习钢琴的平均年数为 4.6 年,标准差为 2.2 年。

    1. 使用假设检验来评估 Georgianna 的说法(或相反情况可能为真)。

    2. 为该城市学生学习钢琴的年数构建一个 95% 置信区间,并结合数据背景对其进行解释。

    3. 你从假设检验和置信区间得到的结果是否一致?请解释你的理由。

  1. 汽车尾气与铅暴露。 对汽车尾气导致的铅暴露感兴趣的研究人员抽取了 52 名警察的血液样本,这些警察在以城市环境为主的地方执行交通执法工作时持续吸入汽车尾气。这些警察的血液样本平均铅浓度为 124.32 \(\mu\)g/l,标准差为 37.74 \(\mu\)g/l;此前一项针对附近郊区无暴露史个体的研究发现,其平均血液铅浓度为 35 \(\mu\)g/l。 (Mortada et al. 2000)

    1. 写出适用于检验警察是否暴露于不同铅浓度的假设。

    2. 明确陈述并检验对这些数据进行推断所需的所有条件。

    3. 检验市中心警察的铅暴露量高于此前研究中那一组的假设,并结合背景解释你的结果。


  1. 关于理解和改进Bootstrap置信区间有大量文献,参见 Hesterberg (2015) ,题为 “教师应该了解的Bootstrap知识”Hayden (2019) ,题为 “关于Bootstrap简单版本的可疑论断” 以获取更多信息。↩︎

  2. 使用bootstrap标准误区间的公式,我们得到 \(\mu\) 的95%置信区间为: \(17,140 \pm 2 \cdot 2,891.87 \rightarrow\) ($11,356.26, $22,923.74)。我们有95%的把握认为Awesome Auto的真实平均车价介于$11,356.26和$22,923.74之间。↩︎

  3. 基于 图 19.6中的百分位数值,bootstrap标准差中间90%的部分由第5百分位数($3,602.5)和第95百分位数($8,737.2)给出。也就是说,我们有90%的把握认为车价的真实标准差介于$3,602.5和$8,737.2之间。90%的置信水平表明不需要像95%或99%那样高的置信水平。较低的置信水平有更高的出错可能,但也会产生更窄的区间。↩︎

  4. 更细致的指导原则会考虑在样本量非常大时进一步放宽对 特别极端的离群值 的检查。不过,我们将把进一步的讨论留给未来的课程。↩︎

  5. 我们想求阴影区域的面积 上方 -1.79(图留给你自己画)。下尾面积为0.0447,所以上尾面积为 \(1 - 0.0447 = 0.9553.\)↩︎

  6. 样本量小于30,因此我们检查是否存在明显的离群值:由于所有观测值都在均值的2个标准差范围内,所以没有这样明显的离群值。↩︎

  7. \(\bar{x} \ \pm\ t^{\star}_{14} \times SE \ \to\ 0.287 \ \pm\ 1.76 \times 0.0178 \ \to\ (0.256, 0.318).\) 我们有90%的把握认为(太平洋)白姑鱼的汞含量平均值介于0.256和0.318 ppm之间。↩︎

  8. 不,置信区间只提供总体参数(此处为总体均值)的一系列合理取值范围。它并不描述我们在单个观测中可能看到的情况。↩︎

  9. \(H_0:\) 2006年和2017年的10英里跑平均用时相同。 \(\mu = 93.29\) 分钟。 \(H_A:\) 2017年10英里跑步的平均时间为 不同于 2006年的平均时间。 \(\mu \neq 93.29\) 分钟。↩︎

  10. 在样本量为100的情况下,只有当存在特别极端的异常值时我们才需要担心。数据的直方图没有显示任何值得担心的异常值(可以说,根本没有任何异常值)。↩︎

  11. bdims 本练习中使用的数据可在 openintro R 包中找到。↩︎

  12. bdims 本练习中使用的数据可在 openintro R 包中找到。↩︎

  13. bdims 本练习中使用的数据可在 openintro R 包中找到。↩︎

  14. bdims 本练习中使用的数据可在 openintro R 包中找到。↩︎

  15. births14 本练习中使用的数据可在 openintro R 包中找到。↩︎

  16. births14 本练习中使用的数据可在 openintro R 包中找到。↩︎