The Problem
Example: I need to calculate the minimum sample size needed to ensure that I am 98% confident that my estimate is no more than 8 percentage points away from the true population proportion. Such a need frequently arises in surveys, such as in this example:
A political scientist wishes to know the proportion of American voters who support the president’s agenda. She needs to ensure that her estimate is within 8 percentage points of the true value with 98% confidence.
With this information, calculate the minimum necessary sample size she will need.
Information given:
To summarize the above, the values of import are:
Summary statistics from the problem
\( E \)
| = |
0.08 |
\( \alpha \)
| = |
0.02 |
\( Z(\alpha/2) \)
| = |
2.33 |
Calculate these values yourself then hover your mouse over the grey spaces to see if you calculated them correctly.
Your Answer
You got the correct answer of n = 213. Congratulations!
Unfortunately, your answer was not correct. Either try again or click on “Show Solution” below to see how to obtain the correct answer.
Assistance
Hide Solution
$$ \begin{align}
n &= \left\lceil 0.25\ \left( \frac{ Z(\alpha/2) }{ E } \right)^2 \right\rceil \\[3em]
&= \left\lceil 0.25\ \left( \frac{ 2.33 }{ 0.08 } \right)^2 \right\rceil \\[1em]
&= \left\lceil 0.25\ \left( 29.125 \right)^2 \right\rceil \\[1em]
&= \left\lceil 0.25\ \left( 848.265625 \right) \right\rceil \\[1em]
&= \left\lceil\ 212.066406\ \right\rceil \\[1em]
&= 213 \end{align}
$$
And so, the minumum sample size needed is n = 213. If your sample size is at least 213, then you are guaranteed to be within 0.08 of the population proportion with 98% confidence.
Hide the R Code
Because the calculations are so straight forward, R does not have a built-in function to calculate the minimum necessary sample size. The following code echoes the above calculations to provide that sample size.
Copy and paste the following code into your R script window, then run it from there.
E = 0.08
alpha = 0.02
zvalue = abs(qnorm(alpha/2))
n = ceiling(0.250 * (zvalue/E)^2)
n
In the R output, the minimum sample size is the number output after running the final line. Note that R will give you calculations that are more accurate and more precise than doing the calculations by hand. The main source of error enters when calculating the z-value using the table. The rounding is significant.
Hide the Excel Code
Because the calculations are so straight forward, Excel does not have a built-in function to calculate the minimum necessary sample size (there are add-ins that include it, however). The following code echoes the above calculations to provide that sample size.
Copy and paste the following code into your Excel window, making sure the value sample
ends up in A1
after pasting.
How to calculate the test statistic in Excel.
E |
0.08 |
alpha |
0.02 |
|
|
Z(alpha/2) |
=ABS(NORM.S.INV(B2/2)) |
|
|
n: |
=CEILING(0.250*(B4/B1)^2,1) |
The minimum sample size is given in cell B6. Again, when you paste this code into Excel, make sure that you start the pasting in cell A1. To help with that, you may want to also copy this notice. It seems to help.