Hey there! Earlier, we touched on margin of error without explaining it completely. Well, we're going to right that wrong in this video by explaining margin of error more. We'll even include an example of how to calculate it. As a data analyst, it's important for you to figure out sample size and variables like confidence level and margin of error before running any kind of test or survey. It's the best way to make sure your results are objective, and it gives you a better chance of getting statistically significant results. But if you already know the sample size, like when you're given survey results to analyze, you can calculate the margin of error yourself. Then you'll have a better idea of how much of a difference there is between your sample and your population. We'll start at the beginning with a more complete definition. Margin of error is the maximum that the sample results are expected to differ from those of the actual population. Let's think about an example of margin of error. It would be great to survey or test an entire population, but it's usually impossible or impractical to do this. So instead, we take a sample of the larger population. Based on the sample size, the resulting margin of error will tell us how different the results might be compared to the results if we had surveyed the entire population. Margin of error helps you understand how reliable the data from your hypothesis testing is. The closer to zero the margin of error, the closer your results from your sample would match results from the overall population. For example, let's say you completed a nationwide survey using a sample of the population. You asked people who work five-day workweeks whether they like the idea of a four-day workweek. So your survey tells you that 60% prefer a four-day workweek. The margin of error was 10%, which tells us that between 50 and 70% like the idea. So if we were to survey all five-day workers nationwide, between 50 and 70% would agree with our results. Keep in mind that our range is between 50 and 70%. That's because the margin of error is counted in both directions from the survey results of 60%. If you set up a 95% confidence level for your survey, there'll be a 95% chance that the entire population's responses will fall between 50 and 70% saying, yes, they want a four-day workweek. Since your margin of error overlaps with that 50% mark, you can't say for sure that the public likes the idea of a four-day workweek. In that case, you'd have to say your survey was inconclusive. Now, if you wanted a lower margin of error, say 5%, with a range between 55 and 65%, you could increase the sample size. But if you've already been given the sample size, you can calculate the margin of error yourself. Then you can decide yourself how much of a chance your results have of being statistically significant based on your margin of error. In general, the more people you include in your survey, the more likely your sample is representative of the entire population. Decreasing the confidence level would also have the same effect, but that would also make it less likely that your survey is accurate. So to calculate margin of error, you need three things: population size, sample size, and confidence level. And just like with sample size, you can find lots of calculators online by searching "margin of error calculator." But we'll show you in a spreadsheet, just like we did when we calculated sample size. Lets say you're running a study on the effectiveness of a new drug. You have a sample size of 500 participants whose condition affects 1% of the world's population. That's about 80 million people, which is the population for your study. Since it's a drug study, you need to have a confidence level of 99%. You also need a low margin of error. Let's calculate it. We'll put the numbers for population, confidence level, and sample size, in the appropriate spreadsheet cells. And our result is a margin of error of close to 6%, plus or minus. When the drug study is complete, you'd apply the margin of error to your results to determine how reliable your results might be. Calculators like this one in the spreadsheet are just one of the many tools you can use to ensure data integrity. And it's also good to remember that checking for data integrity and aligning the data with your objectives will put you in good shape to complete your analysis. Knowing about sample size, statistical power, margin of error, and other topics we've covered will help your analysis run smoothly. That's a lot of new concepts to take in. If you'd like to review them at any time, you can find them all in the glossary, or feel free to rewatch the video! Soon you'll explore the ins and outs of clean data. The data adventure keeps moving! I'm so glad you're moving along with it. You got this!