# Sample size and conservative confidence interval

We want to produce a $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.

• The solution to the equation is found by squaring both sides and then multiplying by $4(n-1)$, giving a linear equation for $n$ which is readily solved, resulting in $n=545$. However, since $\alpha=0.10$ in this question you should revisit your calculation of $Z_{\alpha/2}$: I believe it should be around $1.282$, not $1.64$.
– whuber
Sep 11, 2015 at 20:39
• I'm surprised that this recipe, which I'd never seen before, gets so close to my answer of $546$. Do you have a reference for it? Sep 11, 2015 at 22:30
• This will work but only if the proportion of vegetarian recipes is close enough to 0.5. If it deviates a lot from that value (e.g 0.01) then the normal approximation to the binomial distribution will be a poor approximation.
– user83346
Sep 14, 2015 at 5:29

This is a surprisingly hard question if I have interpreted it correctly and an exact answer is required. I apologise in advance if what follows is largely incomprehensible.

Let me check the facts first. There are $N=2311$ recipes, some unknown number $V$ of which are vegetarian. You will sample $n$ recipes without replacement and want to know the smallest $n$ you can use such that there's a $90\%$ confidence interval of width at most $0.06N$ for $V$. Each CI will be a pair of integers, $(a,b)$, such that $b-a\le\lfloor 0.06N\rfloor=138$. Yes?

OK, let $P(N,V,n,v)=\binom{V}{v}\binom{N-V}{n-v}/\binom{N}{n}$ be the probability that $n$ samples yield $v$ veggie recipes: call that an $(n,v)$ outcome. Let $I(N,V,n,v)$ be $1$ if the CI from an $(n,v)$ outcome contains $V$; or $0$ otherwise. Let $C(N,V,n)=\sum_v P(N,V,n,v) \times I(N,V,n,v)$, the "coverage" of $V$, or the probability that the CI from an $(n,\cdot)$ outcome contains $V$. For $90\%$ confidence, we need $C(N,V,n)\ge 0.9$ for all $V\in{0,1,2,\ldots,N}$. So, what's the smallest $n$ such that it's possible to construct CIs meeting that coverage threshold?

We will try each $n=1,2,3,\ldots$ in turn until we find one that works. To check a given $n$, we use a greedy algorithm. Initially, there are no CIs and the coverage is $0$ for all $V$. Set the CI $(0,\ldots,138)$ for $(n,0)$. This gives $100\%$ coverage for $V=0$, but lesser coverage for larger $V$. Find the smallest $V$ with coverage less than $90\%$: start the CI for $(n,1)$ at that point. Repeat, starting CIs for $(n,2), (n,3)$, etc at those $V$ that are not yet $90\%$ covered. You'll either make it right to the end, $V=N$, or run out of CIs. If you make it, $n$ is good; otherwise $n$ is bad.

This algorithm finds the minimal number of samples, $n=546$.

It's quite a thing to see what coverage you get out of this algorithm; see below. • Sorry, I know this isn't really what you were after. Perhaps you are looking to do a Normal approximation using centred confidence intervals? Good luck. Sep 11, 2015 at 19:45
• A general reference for survey sampling is "Model Assisted Survey Sampling" by Sarndal, Swensson and Wretman. Specifically, this question is dealt with in Section 2.11; its treatment is very general, but it advocates the same approach begun by the original poster and finished by @whuber. And just a note: in survey design, it is typical to make the conservative assumption that $\hat{P}=0.5$, unless some prior information about the proportion is known. Sep 14, 2015 at 4:23