# Sample size and confidence interval

We want to produce a $0.90$ confidence interval for the proportion of vegetarian recipes at one cookbook. We will use simple random sampling without replacement to select a sample of $2311$ recipes in the book. We want the interval length is at most $0.06$. Find the minimum sample size so we can build the interval.

We have that confidence interval for proportion is $$\overline{Y}-z_\frac{\alpha}{2}\sqrt{(1-f)\frac{\hat{P}(1-\hat{P})}{n-1}}\leq\mu\leq \overline{Y}+z_\frac{\alpha}{2}\sqrt{(1-f)\frac{\hat{P}(1-\hat{P})}{n-1}}$$

where $f=\frac{n}{N}$, $n$ is the size of the sample and $N=2311$ is the size of population, but since we don't know the values of $\hat{P}$, I did a conservative confidence interval, replacing $$\hat{P}(1-\hat{P})\Rightarrow \frac{1}{4}$$ so the interval is $$\overline{Y}-z_\frac{\alpha}{2}\sqrt{\frac{(1-f)}{4(n-1)}}\leq\mu\leq \overline{Y}+z_\frac{\alpha}{2}\sqrt{\frac{(1-f)}{4(n-1)}}$$ then the length is $$2z_\frac{\alpha}{2}\sqrt{\frac{(1-f)}{4(n-1)}}=0.06$$ $$2z_\frac{\alpha}{2}\sqrt{\frac{(1-\frac{n}{N})}{4(n-1)}}=0.06$$ $$2*1.64\sqrt{\frac{(1-\frac{n}{N})}{4(n-1)}}=0.06$$

but I could not solve this equation, and also not sure if this is indeed the correct reasoning.

Given the type of confidence interval specified in your first inequality, your logic seems fine. (I might have used 1.645 in stead of 1.64, but that's a quibble.)

Set $N = 3211$ and square both sides of the equation to get a fairly messy (but certainly solvable) linear equation in $n$. Solve for $n$. The result will not be an integer; round up to the next larger integer.

If you have software available, you could easily search for the integer you need. Sometimes this is called a "grid search'. In R, the computation is as follows:

 n = 1:2311
mess = 2*1.64*sqrt((1-n/2311)/(4*(n-1)))
min(n[mess <.06])
## 566
2*1.64*sqrt((1-566/2311)/(4*(566-1)))  # to check
## 0.0599538

• Really it is working on R. As you suggest I solve by hand? Commented Sep 11, 2015 at 14:57
• If I were your instructor in a course at this level, I would be happy with a solution from R. But I am not, and you should check on what is required. (There is artistic value, at the very least, in algebraic derivations carefully done in illuminated calligraphy with quill pens on cured animal hides.) Commented Sep 14, 2015 at 20:25