Section8.1Tying the sampling distribution to estimation
In this section we revisit the chocolate-covered almonds example introduced in ChapterΒ 7 and the results from the sampling distribution of the sample mean weight of almonds, but this time we use this information in the context of estimation.
We start by introducing or reviewing some terminology using the almonds example. The bowl of chocolate-covered almonds is the population of interest. The parameter of interest is the population mean weight of almonds in the bowl, \(\mu\text{.}\) This is the quantity we want to estimate.
We want to use the sample mean to estimate this parameter. So we call the sample mean an estimator or an estimate of \(\mu\text{,}\) the population mean weight. The difference between estimator and estimate is worth discussing.
As an illustration, we decide to take a random sample of 100 almonds from the bowl and use its sample mean weight to estimate the population mean weight. In other words, we intend to sum 100 almondsβ weights, divide this sum by 100, and use this value to estimate the population mean weight. When we refer to the sample mean to describe this process via an equation, the sample mean weight is called an estimator of the population mean weight. Since different samples produce different sample means, the sample mean as an estimator is the random variable \(\overline{X}\) described in SubsectionΒ 7.4.5. As we have learned studying the sampling distribution in ChapterΒ 7, we know that this estimator follows, approximately, a normal distribution; its expected value is equal to the population mean weight. Its standard deviation, also called standard error, is
Then \(\overline{x} = 3.68\) grams is an estimate of the population mean weight. In summary, the estimator is the procedure, equation, or method that will be used on a sample to estimate a parameter before the sample has been retrieved and has many useful properties discussed in ChapterΒ 7. The moment a sample is taken and the equation of a sample mean is applied to this sample, the resulting number is an estimate.
The sample mean, as an estimator or estimate of the population mean, will be a central component of the material developed in this chapter. But, note that it is not the only quantity of interest. For example, the population standard deviation of the almondsβ weight, denoted by the Greek letter \(\sigma\text{,}\) is a parameter and the sample standard deviation can be an estimator or estimate of this parameter.
Furthermore, we have shown in ChapterΒ 7 that the expected value of the sample mean is equal to the population mean. When this happens, we call the sample mean an unbiased estimator of the population mean. This does not mean that any sample mean will be equal to the population mean; some sample means will be greater while others will be smaller but, on average, they will be equal to the population mean. In general, when the expected value of an estimator is equal to the parameter it is trying to estimate, we call the estimator unbiased. If it is not, the estimator is biased.
We now revisit the almond activity and study how the sampling distribution of the sample mean can help us build interval estimates for the population mean.
B. A point estimate is a single value used to estimate a parameter; an interval estimate provides a range of values within which the parameter likely falls.
Subsection8.1.2Revisiting the almond activity for estimation
In ChapterΒ 7, one of the activities was to take many random samples of size 100 from a bowl of 5,000 chocolate-covered almonds. Since we have access to the contents of the entire bowl, we can compute the population parameters:
We keep those numbers for future reference to determine how well our methods of estimation are doing, but recall that in real-life situations we do not have access to the population values and the population mean \(\mu\) is unknown. All we have is the information from one random sample. In our example, we assume that all we know is the almonds_sample_100 object stored in moderndive. Its ID variable shows the almond chosen from the bowl and its corresponding weight. Using this sample we calculate some sample statistics:
In one of the activities performed in ChapterΒ 7 we took many random samples, calculated their sample means, constructed a histogram using these sample means, and showed how the histogram is a good approximation of the sampling distribution of the sample mean. We redraw Figure from ChapterΒ 7 here as FigureΒ 8.1.1.
The histogram in FigureΒ 8.1.1 is drawn using many sample mean weights from random samples of size \(n = 100\text{.}\) The added red smooth curve is the density curve for the normal distribution with the appropriate expected value and standard error calculated from the sample distribution. The red dot represents the population mean \(\mu\text{,}\) the unknown parameter we are trying to estimate. The blue dot is the sample mean \(\overline{x} = 3.68\) from the random sample stored in almonds_sample_100.
In real-life applications, a sample mean is taken from a sample, but the distribution of the population and the population mean are unknown, so the location of the blue dot with respect to the red dot is also unknown. However, if we construct an interval centered on the blue dot, as long as it is wide enough the interval will contain the red dot. To understand this better, we need to learn a few additional properties of the normal distribution.
A random variable can take on different values. When those values can be represented by one or more intervals, the likelihood of those values can be expressed graphically by a density curve on a Cartesian coordinate system in two dimensions. The horizontal axis (X-axis) represents the values that the random variable can take and the height of density curve (Y-axis) provides a graphical representation of the likelihood of those values; the higher the curve the more likely those values are. In addition, the total area under a density curve is always equal to 1. The set of values a random variable can take alongside their likelihood is what we call the distribution of a random variable.
The normal distribution is the distribution of a special type of random variable. Its density curve has a distinctive bell shape, and it is fully defined by two values: (1) the mean or expected value of the random variable, \(\mu\text{,}\) which is located on the X-axis at the center of the density curve (its highest point), and (2) the standard deviation, \(\sigma\text{,}\) which reflects the dispersion of the random variable; the greater the standard deviation is the wider the curve appears. In FigureΒ 8.1.2, we plot the density curves of three random variables, all following normal distributions:
A random variable that follows a normal distribution can take any values in the real line, but those values (on the X-axis) that correspond to the peak of the density curve are more likely than those corresponding to the tails. The density curve drawn with a solid line has the same mean as the one drawn with a dotted line, \(\mu = 5\text{,}\) but the former exhibits less dispersion, measured by the standard deviation \(\sigma = 2\text{,}\) than the latter, \(\sigma = 5\text{.}\) Since the total area under any density curve is equal to 1, the wider curve has to be shorter in height to preserve this property. On the other hand, the density curve drawn with a solid line has the same standard deviation as the one drawn with a dashed line, \(\sigma = 2\text{,}\) but the latter has a greater mean, \(\mu = 15\text{,}\) than the former, \(\mu = 5\text{,}\) so they do look the same but the latter is centered farther to the right on the X-axis than the former.
Subsubsection8.1.3.1The standard normal distribution
A special normal distribution has mean \(\mu = 0\) and standard deviation \(\sigma = 1\text{.}\) It is called the standard normal distribution, and it is represented by a density curve called the \(z\)-curve. If a random variable \(Z\) follows the standard normal distribution, a realization of this random variable is called a standard value or \(z\)-value. The \(z\)-value also represents the number of standard deviations above the mean, if positive, or below the mean, if negative. For example, if \(z = 5\text{,}\) the value observed represents a realization of the random variable \(Z\) that is five standard deviations above the mean, \(\mu = 0\text{.}\)
Subsubsection8.1.3.2Linear transformations of random variables that follow the normal distribution
A linear transformation of a random variable transforms the original variable into a new random variable by adding, subtracting, multiplying, or dividing constants to the original values. The resulting random variable could have a different mean and standard deviation. The most interesting transformation is turning a random variable into another with \(\mu = 0\) and \(\sigma = 1\text{.}\) When this happens we say that the random variable has been standardized.
A property of the normal distribution is that any linear transformation of a random variable that follows the normal distribution results in a new random variable that also follows a normal distribution, potentially with different mean and standard deviation. In particular, we can turn any random variable that follows the normal distribution into a random variable that follows the standard normal distribution. For example, if a value \(x = 11\) comes from a normal distribution with mean \(\mu = 5\) and standard deviation \(\sigma = 2\text{,}\) the \(z\)-value
is the corresponding value in a standard normal curve. Moreover, we have determined that \(x = 11\) for this example is precisely 3 standard deviations above the mean.
Subsubsection8.1.3.3Finding probabilities under a density curve
When a random variable can be represented by a density curve, the probability that the random variable takes a value in any given interval (on the X-axis) is equal to the area under the density curve for that interval. If we know the equation that represents the density curve, we could use the mathematical technique from calculus known as integration to determine this area. In the case of the normal curve, the integral for any interval does not have a close-form solution, and the solution is calculated using numerical approximations.
Please review SubsectionΒ A.2.2 where we provide R code to work with different areas, probabilities, and values under a normal density curve. Here, we place focus on the insights of specific values and areas without dedicating time to those calculations.
We assume that a random variable \(Z\) follows a standard normal distribution. We would like to know how likely it is for this random variable to take a value that is within one standard deviation from the mean. Equivalently, what is the probability that the observed value \(z\) (in the X-axis) is between \(-1\) and \(1\) as shown in FigureΒ 8.1.3?
Calculations show that this area is 0.6827 (68.27%) of the total area under the curve. This is equivalent to saying that the probability of getting a value between \(-1\) and \(1\) on a standard normal is 68.27%. This also means that if a random variable representing an experiment follows a normal distribution, the probability that the outcome of this experiment is within one standard deviation from the mean is 68.27%. Similarly, the area under the standard normal density curve between \(-2\) and \(2\) is shown in FigureΒ 8.1.4.
Calculations show that this area is equal to 0.9545 or 95.45%. If a random variable representing an experiment follows a normal distribution, the probability that the outcome of this experiment is within two standard deviations from the mean is 95.45%. It is also common practice to use the exact number of standard deviations that correspond to an area around the mean exactly equal to 95% (instead of 95.45%). Please see SubsectionΒ A.2.2 to produce these or other calculations in R. The result is that the area under the density curve around the mean that is exactly equal to 0.95, or 95%, is the area within 1.96 standard deviations from the mean. Remember this number as it will be used a few times in later sections.
In summary, if the possible outcomes of an experiment can be expressed as a random variable that follows the normal distribution, the probability of getting a result that is within one standard deviation from the mean is about 68.27%, within 2 standard deviations from the mean is 95.45%, within 1.96 standard deviations from the mean is 95%, and within 3 standard deviations from the mean is about 99.73%, to name a few. Spend a few moments grasping this idea; observe, for example, that it is almost impossible to observe an outcome represented by a number that is five standard deviations above the mean as the chances of that happening are near zero. We are now ready to return to our main goal: how to find an interval estimate of the population mean based on a single sample.
We continue using the example where we try to estimate the population mean weight of almonds with a random sample of 100 almonds. We showed in ChapterΒ 7 that the sampling distribution of the sample mean weight of almonds approximates a normal distribution with expected value equal to the population mean weight of almonds and a standard error equal to
In SubsectionΒ 8.1.2 we showed that for the population of almonds, \(\mu = 3.64\) grams and \(\sigma = 0.139\text{,}\) so the standard error for the sampling distribution is
The horizontal axis (X-axis) represents the sample means that we can determine from all the possible random samples of 100 almonds. The red dot represents the expected value of the sampling distribution, \(\mu = 3.64\text{,}\) located on the X-axis at the center of the distribution. The density curveβs height can be thought of as how likely those sample means are to be observed. For example, it is more likely to get a random sample with a sample mean around \(3.645\) grams (which corresponds to the highest point of the curve) than it is to get a sample with a sample mean of around \(3.5\) grams, since the curveβs height is almost zero at that value. The blue dot is the sample mean from our sample of 100 almonds, \(\overline{x} = 3.68\) grams. It is located 0.04 grams above the population mean weight. How far is 0.04 grams? It is helpful to express this distance in standardized values:
In real-life situations, the population mean, \(\mu\text{,}\) is unknown so the distance from the sample mean to \(\mu\) is also unknown. On the other hand, the sampling distribution of the sample mean follows a normal distribution. Based on our earlier discussion about areas under the normal curve, there is a 95% chance that the value observed is within 1.96 standard deviations from the mean. In the context of our problem, there is a 95% chance that the sample mean weight is within 1.96 standard errors from the population mean weight. As shown earlier, the sample mean calculated in our example was about 2.88 standard errors above the population mean, well within the reasonable range.
Think about this result. If we were to take a different random sample of 100 almonds, the sample mean will likely be different, but you still have a 95% chance that the new sample mean will be within 1.96 standard errors from the population mean.
We can finally construct an interval estimate that takes advantage of this configuration. We center our interval at the sample mean observed and then extend to each side the magnitude equivalent to 1.96 standard errors. The lower and upper bounds of this interval are:
The functions mean() and length() find the sample mean weight and sample size, respectively, from the sample of almondsβ weights in almonds_sample_100. The number 1.96 corresponds to the number of standard errors needed to get a 95% area under the normal distribution and the population standard deviation sigma of 0.139 was found in SubsectionΒ 8.1.2. FigureΒ 8.1.6 shows this interval as a horizontal blue line. Observe how the population mean \(\mu\) is part of this interval.
Since 1.96 standard errors were used on the construction of this interval, we call this a 95% confidence interval. A confidence interval can be viewed as an interval estimator of the population mean. Compare an interval estimator with the sample mean that is a point estimator. The latter estimates the parameter with a single number, the former provides an entire interval to account for the location of the parameter. An apt analogy involves fishing. Imagine that there is a single fish swimming in murky water. The fish is not visible but its movement produces ripples on the surface that can provide some limited information about the fishβs location. To capture the fish, one could use a spear or a net. Because the information is limited, throwing the spear at the ripples may capture the fish but likely will miss it.
Throwing a net around the ripples, on the other hand, may give a much higher likelihood of capturing the fish. Using the sample mean only to estimate the population mean is like throwing a spear at the ripples in the hopes of capturing the fish. Constructing a confidence interval that may include the population mean is like throwing a net to surround the ripples. Keep this analogy in mind, as we will revisit it in later sections.
Recall that due to the Central Limit Theorem, the sampling distribution of the sample mean was approximately normal with mean equal to the population mean \(\mu\) and standard deviation given by the standard error \(SE(\overline{X}) = \sigma/\sqrt{n}\text{.}\) We can standardize this for any sample mean \(\overline{x}\) such that
In the construction of the interval in FigureΒ 8.1.6 we have assumed the population standard deviation, \(\sigma\text{,}\) was known, and therefore we have used it to find the confidence interval. Nevertheless, in real-life applications, the population standard deviation is also unknown. Instead, we use the sample standard deviation, \(s\text{,}\) from the sample we have, as an estimator of the population standard deviation \(\sigma\text{.}\) Our estimated standard error is given by
When using the sample standard deviation to estimate the standard error, we are introducing additional uncertainty in our model. For example, if we try to standardize this value, we get
\begin{equation*}
t = \frac{\overline{x} - \mu}{s/\sqrt{n}}.
\end{equation*}
Because we are using the sample standard deviation in this equation and since the sample standard deviation changes from sample to sample, the additional uncertainty makes the values \(t\) no longer normal. Instead they follow a new distribution called the \(t\) distribution.
The \(t\) distribution is similar to the standard normal; its density curve is also bell-shaped, and it is symmetric around zero, but the tails of the \(t\) distribution are a little thicker than those of the standard normal. In addition, the \(t\) distribution requires one additional parameter, the degrees of freedom. For sample mean problems, the degrees of freedom needed are exactly \(n - 1\text{,}\) the size of the sample minus one. FigureΒ 8.1.7 shows the density curves of
Observe how the dashed red \(t\) density curve (\(t\) with 10 degrees of freedom) gets closer to the standard normal density curve, or \(z\)-curve, in solid black, than the dotted blue \(t\) curve (\(t\) with 2 degrees of freedom). The greater the number of degrees of freedom, the closer the \(t\) density curve is from the \(z\) curve. This change makes our calculations slightly different. Please see SubsectionΒ A.2.2 for calculations of probabilities for \(t\) density curves with different degrees of freedom.
Using that knowledge, the calculation for our specific example shows that 95% of the sample means are within 1.98 standard errors from the population mean weight. The number of standard errors needed is not that different from before, 1.98 versus 1.96, because the degrees of freedom are fairly large.
Using this information, we can construct the 95% confidence interval based entirely on our sample information and using the sample mean and sample standard deviation. We calculate those values again for almonds_sample_100:
Observe that the sample standard deviation is \(s = 0.137\) which is not that different from the population standard deviation of \(\sigma = 0.139\text{.}\) We again center the confidence interval at the observed sample mean but now extend the interval by 1.98 standard errors to each side. The lower and upper bounds of this confidence interval are:
The confidence interval computed here, using the sample standard deviation and a \(t\) distribution, is almost the same as the one attained using the population standard deviation and the standard normal distribution, the difference is about 0.005 units for the upper and lower bound. This happens because with a sample size of 100, the \(t\)-curve and \(z\)-curve are almost identical and also because the sample standard deviation was very similar to the population standard deviation. This does not have to be always the case and occasionally we can observe greater differences; but, in general, the results are fairly similar.
More importantly, the confidence interval constructed here contains the population mean of \(\mu = 3.64\text{,}\) which is the result we needed. Recall that a confidence interval is an interval estimate of the parameter of interest, the population mean weight of almonds. We can summarize the results so far:
Using the sample mean observed and the standard error of the sampling distribution, we can construct 95% confidence intervals for the population mean. The formula for these intervals (where \(n\) is the sample size used) is given by
When the population standard deviation is unknown (which is almost always the case), the sample standard deviation is used to estimate the standard error. This produces additional variability and the standardized values follow a \(t\) distribution with \(n - 1\) degrees of freedom. The formula for 95% confidence intervals when the sample size is \(n = 100\) is given by
The method to construct 95% confidence intervals guarantees that in the long-run for 95% of the possible samples, the intervals determined will include the population mean. It also guarantees that 5% of the possible samples will lead to intervals that do not include the population mean.
As we have constructed intervals with a 95% level of confidence, we can construct intervals with any level of confidence. The only change in the equations will be the number of standard errors needed.
We have used the sample almonds_sample_100, constructed a 95% confidence interval for the population mean weight of almonds, and showed that the interval contained this population mean. This result is not surprising as we expect intervals such as this to include the population mean for 95% of the possible random samples. We repeat this interval construction for many random samples. FigureΒ 8.1.8 presents the results for one hundred 95% confidence intervals.
Note that each interval was built using a different random sample. The red vertical line is drawn at the location of the population mean weight, \(\mu = 3.64\text{.}\) The horizontal lines represent the one hundred 95% confidence intervals found. The gray confidence intervals cross the red vertical line so they contain the population mean. The black confidence intervals do not.
This result motivates the meaning of a 95% confidence interval: If you could construct intervals using the procedure described earlier for every possible random sample, then 95% of these intervals will include the population mean and 5% of them will not.
Of course, in most situations, it would be impractical or impossible to take every possible random sample. Still, for a large number of random samples, this result is approximately correct. In FigureΒ 8.1.8, for example, 5 out of 100 confidence intervals do not include the population mean, and 95% do. It wonβt always match up perfectly like this, but the proportions should match pretty close to the confidence level chosen.
The term "95% confidence" invites us to think we are talking about probabilities or chances. Indeed we are, but in a subtle way. Before a random sample has been procured, there is a 95% chance that when a confidence interval is constructed using the prospective random sample, this interval will contain the population mean. The moment a random sample has been attained, the interval constructed either contains the population mean or it does not; with certainty, there is no longer a chance involved. This is true even if we do not know what the population mean is. So the 95% confidence refers to the method or process to be used on a prospective sample. We are confident that if we follow the process to construct the interval, 95% of the time the random sample attained will lead us to produce an interval that contains the population mean.
On the other hand, it would be improper to say that... "there is a 95% chance that the confidence interval contains the population mean." Looking at FigureΒ 8.1.8, each of the confidence intervals either does or does not contain \(\mu\text{.}\) Once the confidence interval is determined, either the population mean is included or not.
In the literature, this explanation has been encapsulated in a short-hand version: we are 95% confident that the interval contains the population parameter. For example, in SubsectionΒ 8.1.5 the 95% confidence interval for the population mean weight of almonds was (3.653, 3.707), and we would say: βWe are 95% confident that the population mean weight of almonds is between 3.653 and 3.707 grams.β
It is perfectly acceptable to use the short-hand statement, but always remember that the 95% confidence refers to the process, or method, and can be thought of as a chance or probability only before the random sample has been acquired. To further ensure that the probability-type of language is not misused, quotation marks are sometimes put around "95% confident" to emphasize that it is a short-hand version of the more accurate explanation.
Subsubsection8.1.5.2Understanding the width of a confidence interval
A confidence interval is an estimator of a population parameter. In the case of the almondsβ bowl we constructed a confidence interval for the population mean. The equation to construct a 95% confidence interval was
Observe that the confidence interval is centered at the sample mean and it extends to each side \(1.96 \cdot \sigma / \sqrt{n}\text{.}\) This quantity is exactly half the width of your confidence interval, and it is called the margin of error. The value of the population standard deviation, \(\sigma\text{,}\) is beyond our control, as it is determined by the distribution of the experiment or phenomenon studied. The sample mean, \(\overline{x}\text{,}\) is a result that depends on your random sample exclusively. On the other hand, the number 1.96 and the sample size, \(n\text{,}\) are values that can be changed by the researcher or practitioner. They play an important role on the width of the confidence interval. We study each of them separately.
We mentioned earlier that the number 1.96 relates to a 95% confidence process but we did not show how to determine this value. The level of confidence is a decision of the practitioner. If you want to be more confident, say 98% or 99% confident, you just need to adjust the appropriate number of standard errors needed. We show how to determine this number, and use FigureΒ 8.1.9 to illustrate this process.
We need the exact number of standard deviations that produces the shaded area. Since the center of a standard normal density curve is zero, as shown in FigureΒ 8.1.9, and the normal curve is symmetric, the number of standard deviations can be represented by \(-q\) and \(q\text{,}\) the same magnitude but one positive and the other negative.
In R, the function qnorm() finds the value of \(q\) when the area under this curve to the left of this value \(q\) is given. In our example the area to the left of \(-q\) is \(\alpha/2 = 0.05/2 = 0.025\text{,}\) so
or 1.96 standard deviation below the mean. Similarly, the total area under the curve to the left of \(q\) is the total shaded area, 0.95, plus the small white area on the left tail, 0.025, and \(0.95 + 0.025 = 0.975\text{,}\) so
That is the reason we use 1.96 standard deviation when calculating 95% confidence intervals. What if we want to retrieve a 90% confidence interval? We follow the same procedure:
If we want to determine a 90% confidence interval, we need to use 1.645 standard errors in our calculations. We can update the R code to calculate the lower and upper bounds of a 90% confidence interval:
When you want to calculate an 80%, 90%, or 95% confidence interval, you need to construct your interval using 1.282, 1.645, or 1.960 standard errors, respectively. The more confident you want to be, the larger the number of standard errors you need to use, and the wider your confidence interval becomes. But a confidence interval is an estimator of the population mean, the narrower it is, the more useful it is for practical reasons. So there is a trade-off between the width of a confidence interval and the confidence you want to have.
As we studied changes to the confidence level, we can determine how big is the random sample used. The margin of error for a 95% confidence interval is
If the sample size increases, the margin of error decreases proportional to the square root of the sample size. For example, if we secure a random sample of size 25, \(1/\sqrt{25} = 0.2\text{,}\) and if we draw a sample of size 100, \(1/\sqrt{100} = 0.1\text{.}\) By choosing a larger sample size, four times larger, we produce a confidence interval that is half the width. This result is worth considering.
A confidence interval is an estimator of the parameter of interest, such as the population mean weight of almonds. Ideally, we would like to build a confidence interval with a high level of confidence, for example, 95% confidence. But we also want an interval that is narrow enough to provide useful information. For example, assume we get the following 95% confidence intervals for the population mean weight of almonds:
The first interval does not seem useful at all, the second works better, and the third is tremendously accurate, as we are 95% confident that the population mean is within 0.006 grams. Obviously, we always prefer narrower intervals, but there are trade-offs we need to consider. We always prefer high levels of confidence, but the more confident we want to be the wider the interval will be. In addition, the larger the random sample used, the narrower the confidence interval will be. Using a large sample is always a preferred choice, but the trade-offs are often external; collecting large samples could be expensive and time-consuming. The construction of confidence intervals needs to take into account all these considerations.
We have concluded the theory-based approach to construct confidence intervals. In the next section we explore a completely different approach to construct confidence intervals and in later sections we will make comparisons of these methods.