How To Calculate Confidence Interval (With Examples)

By Chris Kolmar - May. 25, 2021
Articles In Guide

Find a Job You Really Want In

Assuming you’re searching for an apartment in a new city, and you happen to find a local survey that had randomly sampled a hundred apartment advertisements and determined with 95% accuracy that the price range for one-bedroom apartments in the area is $845-$1155.

In this example, the confidence level, which is usually represented as a percentage, is 95%. This means that if you repeated this survey yourself and randomly sampled apartment advertisements meeting the same parameters, your results should fall within that range of 95% all the time.

The confidence interval is not the same as the confidence level. In the example, the confidence interval would be $845 and $1155.

What Is a Confidence Interval?

In statistics, confidence intervals usually go hand-in-hand with a confidence level and margin of error. Basically, the confidence interval tells you how confident you can be that a statistic from poll or survey results would be reflected within that same range if the entire population were surveyed.

Pretty nifty, right? Statistical data is important, but it can be skewed depending on how it’s presented, especially when it comes to comparing costs over time when inflation needs to be factored into the equation.

Confidence levels and intervals are used because there’s no way to be 100% sure that the results for an entire population will match the data represented in the sample. There will always be deviations and margins of error.

But for the sake of statistical data, we can still make a fairly accurate guess about where the majority of the population would fall on the graph if we were to hypothetically expand the experiment to include every single individual. That range where we’re feeling pretty confident is our confidence interval.

How to Calculate the Confidence Interval Using T-Distribution

Let’s say you’re still browsing apartments and want to construct your own 95% confidence interval. You randomly sample twenty apartment listings and determine that the average monthly rent is $1,000. Assuming a standard deviation of $250, here’s the step-by-step method to break down the confidence intervals with 95% certainty.

Because this sample size is under thirty, we can solve it using the T-distribution method.

  1. Start by calculating our degrees of freedom by simply subtracting “one” from our sample size. In this case, our sample size is 20, which means our degrees of freedom will be 19.

  2. Next, we’ll calculate the total alpha value. This is the small section of the graph above and below our 95% range of confidence, and we can find it by changing our confidence level to a decimal and subtracting from one. In this example, 95% becomes .95, which is .05 after we subtract.

  3. Divide the alpha value by “two” so we can separate the amount of uncertainty on the low end of the graph from the amount on the high end of the graph. In this example, .05 / 2 is .025.

  4. Using the T-distribution table, find the value for 19 degrees of freedom and an alpha value of .025. In this example, that number is 2.093.

  5. Now that we’ve found the T-value, we need to calculate the standard error. To do this, we’ll divide the standard deviation by the square root of our sample size. In this example, $250 will be divided by the square root of 20, which gives us 55.9016994375.

  6. Multiply the standard error we found in the step above by the T-value we found in Step four (55.9016994375 x 2.093 = 117.0022569227).

  7. Take the mean ($1,000) and subtract the number found in Step six (117.0022569227). This is our low confidence interval number. Since we’re dealing with monetary values, we can round two decimal points for the cents.

  8. Now take the mean and add the number found in Step six. This is our high confidence interval number.

  9. Our confidence interval in this example is $883.00 and $1,117.00

How to Calculate the Confidence Interval Using T-Distribution With Raw Data

The formula we’ll be using is x̄ ± t* σ / (√n). For our values, x̄ is the mean, t is the t-score, σ is the standard deviation of the sample, and n is the number of items in the sample.

For this example, we’re going to calculate a 98% confidence interval for the following data: 40, 42, 49, 57, 61, 47, 66, 78, 90, 86, 81, 80.

  1. To find the mean (x̄), add all of the numbers together and divide by 12 since there are a total of twelve numbers in this sample. Our mean is 64.75.

  2. To find the standard deviation in this sample (σ), add all of the numbers, then square them (777 x 777 = 603,729). Divide by the total number (n = 12) to get 50,310.75.

  3. Hold onto that result from Step two because we’re not done with the standard deviation yet, so you’ll need that number in a minute.

    Take the original set of numbers again and square each one, then add them up. (40 x 40) + (42 x 42) + (49 x 49) + (57 x 57) + (61 x 61) + (47 x 47) + (66 x 66) + (78 x 78) + 90 x 90) + (86 x 86) + (81 x 81) + (80 x 80) = 53,841

  4. Subtract the results from Steps two and three (53,841 – 50,310.75 = 3,530.25).

  5. Subtract 1 from n (12 – 1 = 11). Then, divide your answer from Step four by this integer to get the variance (3,530.25 / 11 = 320.9318181818182).

  6. Take the square root of the variance to find the final standard deviation (√320.9318181818182 = 17.915).

  7. We now have our x̄, n, and s factors. To find the t-score, we first need to find the degrees of freedom. Start by subtracting 1 from our n value (12 – 1 = 11).

  8. Then, convert our confidence level to a decimal and subtract from 1, then divide by 2 (1 – .98 = .02 / 2 = .01). In the t-distribution chart, look up the number that intersects with an alpha level of .01 and 11 degrees of freedom (2.718).

  9. We now have all the values we need to plug into the formula: 64.75 ± 2.718* 17.915 / (√12).

  10. Our 98% confidence interval for this raw data is 50.69 and 78.81.

How to Calculate the Confidence Interval Using Z-Distribution

This method, also referred to as the normal distribution method, is used if you know the standard deviation but don’t know your population mean. The formula we’ll be using is x̄ ± z (σ / (√n)). For our values, x̄ is the mean, z is the z-score, σ is the standard deviation of the sample, and n is the number of items in the sample.

For this example problem, the goal is to construct a 95% confidence interval. Five samples in an experiment resulted in a mean temperature of 102.3°F in July with a population standard deviation of 1.3.

  1. Just like the t-distribution example above, we’ll calculate the alpha value by subtracting our confidence level in decimal form from “one” and then dividing that result by “two.” Subtracting .95 from 1 gives us .05, divided by 2 for a total of .025.

  2. Take the number we found in Step one and subtract it from 1 (1 – .025 = .975)

  3. Find .975 on the z-table in order to find the value for z in the equation. In this example, .975 will be in the middle of the table, and our z-score is 1.96.

  4. Take the z-score and multiply it by the standard deviation divided by the square root of the number of items in the sample. In this case, we will be dividing 1.3 by the square root of 5 and multiplying by our z-score of 1.96 for a total of 1.1395002412.

  5. Subtract your result from the mean in the sample problem in order to find the lower confidence interval (102.3 – 1.1395002412 = 101.1634997588).

  6. Add your result from Step four to the mean in order to find the higher confidence interval (102.3 + 1.1395002412 = 103.4395002414).

  7. We’ll round to a single decimal point to match the format presented in the example. Our 95% confidence interval for the month of July is 101.2°F – 103.5°F.

How to Calculate the Confidence Interval for a Proportion

For this example, 530 people applied for a job at a big company. Of those applicants, 113 were women. Find the 95% confidence interval of the true proportion of women who applied for this job.

Here is the formula we’ll be using: p̂ ± z (√(p̂ (1 – p̂)) / n).

  1. Our first task is to find the value of p̂. To do this, we need to divide the number of events by the number of trials, or in this case, the number of women divided by the total number of applicants (113 divided by 530 gives us .21 for our rounded p̂ value).

  2. To find the z-score, we’ll start by changing 95% to .95 and dividing by 2, which gives us .475. To look up on the z-table, this gives us 1.96 for a z-score value.

  3. Our formula now looks like: .21 ± 1.96 (√(.21 (1 – .21)) / 530).

  4. Working our way through, we have .21 ± .0347

  5. This gives us a confidence interval of .1753 and .24467, which rounds to 18% and 24% of women who applied to the job opening.

How to Calculate the Confidence Interval for a Proportion with Two Populations

If you love formulas, this one is going to be fun. If formulas make you break out in a cold sweat and have an anxiety attack, don’t panic, it looks worse than it actually is. Here is the formula we’ll be using:

(p̂1 – p̂2) – zα/2 (√(p̂1q̂1 / n1) + (p̂2q̂2 / n2)) lt; p̂1 – p̂2 lt; (p̂1 – p̂2) + zα/2 (√(p̂1q̂1 / n1) + (p̂2q̂2 / n2))

Before you start panicking, notice that the second part of the equation is the same as the first. Remember that confidence intervals involve ±, so the first part of the equation is subtracting while the last part is adding the exact same variables. You only have to find that number once.

Let’s break this down with an example. A study revealed that 65% of men support a new policy at work, but only 33% of women are in support. We’re going to find the 90% confidence interval for the data’s true difference in proportions. 100 men and 75 women took part in the survey.

  1. The best place to start is by figuring out the formula variables based on what we know:

    p̂1 = Population 1 (men) positive response = 65% or .65
    q̂1 = Population 1 (men) negative response = 35% or .35
    n1 = Population 1 (men) total surveyed = 100
    p̂2 = Population 2 (women) positive response = 33% or .33
    q̂2 = Population 2 (women) negative response = 67% or .67
    n2 = Population 2 (women) total surveyed = 75

  2. We need to find zα/2. Subtract our confidence level from 1 and divide by 2 as we’ve done before (1 – .90 / 2 = .0500). The closest z-value on the z-table is 0.13. We now have all of the variables we need and can plug them into the formula.

  3. Multiply p̂1 x q̂1 (.65 x .35 = .2275), then divide by n1 (.2275 / 100 = .002275). We’ll need this number later.

  4. Multiply p̂2 x q̂2 (.33 x .67 = .2211), then divide by n2 (.2211 / 75 = .002948).

  5. Add your answer from Step three to your answer from Step four (.002275 + .002948 = .005223).

  6. Take the square root of your answer from Step five (√.005223 = .0722703258606186).

  7. Multiply your answer from Step six by the zα/2 value we found in Step two (.0722703258606186 x .13 = .0093951423618804). We’ll need this number later.

  8. Subtract p̂2 from p̂1 (.65 – .33 = .32).

  9. To find the lower limit, subtract your answer in Step eight from your answer in Step seven (.32 – .0093951423618804 = .3106048576381196, which rounds to 31.1%).

  10. To find the upper limit, add your answer in Step eight with your answer in Step seven (.32 + .0093951423618804 = .3293951423618804, which rounds to 32.9%).

  11. Cue sigh of relief because you did it!

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

Articles In Guide
Never miss an opportunity that’s right for you.

Author

Chris Kolmar

Chris Kolmar is a co-founder of Zippia and the editor-in-chief of the Zippia career advice blog. He has hired over 50 people in his career, been hired five times, and wants to help you land your next job. His research has been featured on the New York Times, Thrillist, VOX, The Atlantic, and a host of local news. More recently, he's been quoted on USA Today, BusinessInsider, and CNBC.

Related posts

Topics: Definition, Guides