Which of these 2 formulas is the right one for estimating sample size for proportions? I've seen two formulas for estimating a sample size proportion, the first one:
s = 1.96^2 * p * (1-p) / MOE^2

Where:


*

*1.96 is the Z score for getting a 95% confidence interval.

*p is the estimated proportion (0.5 if unknown)

*MOE is the margin of error (0.05)


This formula is independent from the total population. There's also another one that reads:
S = N * s / (N + s - 1)
Where:


*

*N is the population.

*s is the sample size estimated with the previous formula.


My question is, which of these would you use and when? (the second one seems more complete since it takes into account the population size).
 A: I think it depends on the population you want to make inferences about. The latter one just corrects for a finite or small population size.
I think often people assume infinite populations since they want to make inferences about a population that goes beyond the group they have sampled from. 
So if you want to make some test on the exam pass rate of this year in faculty X and you know that only N exams were taken and you are only interested in this year in your faculty a correction is appropriate (e.g. because your sample size can obviously not be larger than your population size). If you want to make a general statement about pass rates of e.g. boys in general an infinite population size would have to be assumed. 
As you can see S approaches s as N increases
p = 0.5
MOE = 0.05

s = 1.96^2 * p * (1-p) / MOE^2

df = data.frame()
for(N in seq(10,10^6,10)){
    S = N * s / (N + s - 1)
    d1 = data.frame(N, S)
    df = rbind(d1,df)
}

plot(df$N, df$S-s) 


A: I would use the first one, assuming that the population is very large (in theory, infinite). However, I believe you misunderstand one of the concepts. MOE (margin of error) is not 1-confidence level (so in your example, not necessarily 0.05). It is the error that you allow for you proportion estimation, so it could be 0.01, 0.02, or whatever you want. it is not related to the confidence level (at least not directly). You choose each of them separately. You want your proportion estimate to be accurate within some percentage (say +- 0.02), and you want to claim this with a confidence of 95%. 
