[SOUND] Going through the last few lessons on confidence interval, we have seen a few things that have unfolded, and they all have to do with the margin of error. To be precise and accurate, we like to have a small margin of error. So let's review the components on margin of error. A close examination of the margin of error, whether you're estimating for mean or population proportion is partly controlled by the sample size. So far we have looked at examples where you were told the study was done on a sample of a given size. Then based on the given information we calculated the margin of error and the confidence interval. We can do this in another way. We can say what we desire to have as the maximum margin of error and based on that, solve for the sample size. Let me show you how to do this starting with the margin of error and sample size calculations for the mean estimation followed by the population proportion and first of all, by now you intuitively know that the larger the sample size the better. But the sample size selection is an economic decision, it takes longer and more effort to get a larger sample size. It really depends on the cost of getting it wrong with a smaller sample size versus the cost of getting a bigger sample. If you were in charge of quality control on production line filing boxes of cereals then when the production line is a little off then missing this problem will increase your cost of production a little. If you're putting too much in the box or may result getting fine by not putting enough. But imagine that you're producing drugs. If your mix of ingredients are incorrect the mistake can result in catastrophic consequences. So just death resulting from wrong dosages. So how do you select the right sample size? You can make this decision by stating the margin of error which is acceptable and then work backwards to find the sample size. Which means, sample size is square of z times the standard deviation, divided by the acceptable margin of error. Let's go back to an example we used in an earlier lesson, which was about the manager wanting to advertise a 15 minute oil change to his customers. Now the manager wants to know how big a sample he needs to collect for a 95% confidence interval if he bases his margin of error to be 30 seconds, or half a minute. To answer this, he will use this formula, z of alpha over 2 for 95% confidence interval is 1.96. E is half a minute. But we also need to know the standard deviation, which we also don't have. So, in this case, we first will do a small study to find this value. We did a 100 observation study and found a sample standard deviation of three and a half minutes. Now we can calculate the sample size required for the level of accuracy desired. Based on this, the sample size needed for our half a minute margin of error would be 188.23. We need an integer value, so always round up. So, in this case, the minimum sample size needed to provide the level of precision and accuracy the manager wants is 189 observations. So now let's practice. The manager of the cereal company wants to create a confidence interval for the average weight of its cereal boxes within .15 ounces. The process is known to have a standard deviation of .5 ounces. What would be the required sample size for a 99% confidence interval? Z score for 99% confidence level is 2.575 standard deviation is 0.5 ounces. And acceptable margin of error is 0.15 ounces so the sample size is therefore 74. Just like we did for mean confidence interval, we can compute the sample size required to have a proportion confidence interval to be of a specified width using the formula showing on the slide. P is a preliminary estimate of the population proportion. We either get this by doing a small study first to get a sense of this value, or we can just use 0.5. P of 0.5 will result in the largest sample size of any value of P. Which means using p of 0.5 will give us the most conservative estimate of the required sample size. Z of alpha/2 is the multiplier for the desired level of confidence and E is the desired margin of error. We want to know what percent of the population thin global warming is real. We would like to be within plus or minus 1%. If you were developing a 95% confidence interval what sample size would you need? We use the equation to find the required sample size. Since we have new idea what it maybe, I will use P of 50%, z a/2 for 95% confidence level is 1.96 and the desired margin of air is 1% or 0.01. Putting this values in the formula will yield 9,604 as the required sample size. Wow, this is really big. Let's be real. I may not want to survey this many people. Then what options do I have? First, I can reduce my precision. Let's say I will accept margin of error of 4%. What will happen? What would be the new sample size, please calculate it for me. The new sample size is 601 observation instead of 9604. Quite a bit of drop. Once again, if you want precision, then you need to have larger sample size. And it's worth it if the cost of being wrong is high enough to justify the cost of more sampling. Another option is to take a small sample first and find the sample information. And then based on that, calculate the needed sample size. Going back to our original statement where we wanted to be within 1% of the true population proportion. But this time, we survey 100 adults and found that 15% of them didn't believe in global warming. You may think your P is 0.15. Not so fast. 0.15 is based on a sample. First we need to see what the 95% confidence interval will be based on this sample proportion. Then this give us the interval estimation between 8% to 22%. To be right you need to use the value in this interval, which is closest to 0.5. This will ensure that your sample size will be large enough. So in this case, we will use p of 0.22. Then using the equation for sample size we find out that we need to sample 6592, which is still pretty large, but much smaller than our initial sample of 9604, which was calculated by just assuming p of 50%. So this is also an acceptable way of reevaluating our sample size. As you sample along and get some information, you can update the 0.5 you used as a starting point. So remember that if the proportion is either close to 0 or 1 that means most individuals having the same trait or opinion, then there is very little natural variability, and the margin of error is smaller than if the population is near 50% they're split. At 50% when they're split even, the need to have a larger sample size in order to make a fair estimate for the population. Whether you are doing a sample study so you can make an inference about population mean or proportion, there are three things that impact the margin of error. First is the sample size. When the sample size increases, margin of error decreases. Then it's about the level of confidence desire. The higher this level the larger the multiplier of the z alpha over 2, increasing the margin of error. Third is the natural variability, the standard deviation that you have observed within your sample. In this lesson, we learned how to calculate the sample size which will give us both the precision and the accuracy we desire.