0% found this document useful (0 votes)
45 views7 pages

Lecture Notes Confidence Intervals

Uploaded by

ltfyle01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views7 pages

Lecture Notes Confidence Intervals

Uploaded by

ltfyle01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Confidence Intervals

In statistics, we often want to estimate a population parameter based on a sample. One common
parameter of interest is the population mean. Confidence intervals provide a range of values within
which we believe the true population parameter lies. The confidence interval gives a range of values
that is likely to contain the true population mean. For example, a 95% confidence interval means that we
are 95% confident that the interval contains the true mean.

The confidence interval for the population mean ( ) when the


population standard deviation is known is given by:
μ

σ
x̄ ± Z ×
√n

where:
is the sample mean.

Z is the critical value from the standard normal distribution based on the desired confidence level.
σis the population standard deviation.
nis the sample size.
Confidence Level Z (Standard Normal)
90% 1.645
95% 1.960
99% 2.576
Example 1: Population Standard Deviation Known
Problem: Suppose you want to estimate the average time your students spend on weekly homework
assignments. You collect a sample of 25 students and find that the sample mean time spent on
homework is 4.2 hours. Assuming the population standard deviation is 1.2 hours, find the 95%
confidence interval for the average time spent on homework.
Given Data: - Sample mean ( ): 4.2 hours - Population standard deviation ( ): 1.2 hours - Sample size (
x̄ σ

n): 25 - Confidence level: 95%


Calculate Margin of Error:
σ
E = Z ×
√n

Using the Z-value for a 95% confidence level (approximately 1.96):


1.2
E = 1.96 × = 0.47, hours
√ 25

Confidence Interval:
Conf idence Interval = (x̄ − E, x̄ + E)

Conf idence Interval = (4.2 − 0.47, 4.2 + 0.47) = (3.73, 4.67)

So, at a 95% confidence level, the average time spent on homework is estimated to be between 3.73
and 4.67 hours.
Solving the same problem using R-Programming:
# Given data
sample_mean <- 4.2
confidence_level <- 0.95
population_std_dev <- 1.2
sample_size <- 25

# Calculate margin of error


margin_of_error <- qnorm((1 + confidence_level) / 2) * (population_std_dev / sqrt

# Confidence interval
lower_bound <- sample_mean - margin_of_error
upper_bound <- sample_mean + margin_of_error

# Print results
cat("Confidence Interval:", lower_bound, "to", upper_bound, "\n")

Confidence Interval: 3.729609 to 4.670391


In R, when specifying confidence levels, you typically represent them as decimal values. So, for a 95%
confidence level, you would use 0.95 . The qnorm() and qt() functions expect probabilities, and
representing the confidence level as a decimal between 0 and 1 is the standard practice.
For example, when you see qnorm(0.95) , it means you are finding the Z-value corresponding to the
95th percentile of the standard normal distribution.
Similarly, qt(0.025, df = degrees_of_freedom) means you are finding the t-value for a two-tailed test
with a 95% confidence level and a given degrees of freedom.
Formula for Confidence Interval of One Population Mean (Unknown
Population Standard Deviation):
The studentized version of the sample mean involves dividing the difference between the sample mean
x̄and the population mean by the standard deviation of the sample scaled by the square root of the
μ s

sample size . This is expressed by the formula:


n

x̄ − μ
t =
s

√n

When the population standard deviation is unknown, we use the T-distribution for Confidence Interval,
σ

and the formula becomes:


s
x̄ ± t ×
√n

x̄ is the sample mean.


t is the critical value from the T-distribution based on the desired confidence level and degrees of
freedom.
s is the sample standard deviation.
n is the sample size.
Example 2: Population Standard Deviation Unknown
Problem: Now, imagine you are studying the heights of a population of students. You collect a sample
of 30 students and find that the sample mean height is 65 inches, with a sample standard deviation of 2
inches. Find the 95% confidence interval for the average height of the population.
Given Data:
Sample mean ( ): 65 inches

Sample standard deviation ( ): 2 inches


s

Sample size ( ): 30
n

Confidence level: 95%


Degrees of Freedom: $ df = n - 1 = 30 - 1 = 29 $
Calculate Margin of Error:
s
E = t ×
√n

Using the t-value for a 95% confidence level with 29 degrees of freedom (approximately 2.045):
2
E = 2.045 × = 0.748, inches
√ 30

Confidence Interval:
Conf idence Interval = (x̄ − E, x̄ + E)

Conf idence Interval = (65 − 0.748, 65 + 0.748) = (64.252, 65.748)

So, at a 95% confidence level, the average height of the population is estimated to be between 64.252
and 65.748 inches.
Solving the same problem using R-Programming:
# Given data
sample_mean <- 65
confidence_level <- 0.95
sample_std_dev <- 2
sample_size <- 30

# Degrees of freedom
df <- sample_size - 1

# Calculate margin of error


margin_of_error <- qt((1 + confidence_level) / 2, df) * (sample_std_dev / sqrt(sa

# Confidence interval
lower_bound <- sample_mean - margin_of_error
upper_bound <- sample_mean + margin_of_error

# Print results
cat("Confidence Interval:", lower_bound, "to", upper_bound, "\n")

Confidence Interval: 64.25319 to 65.74681

Sampling Size for Estimating μ


The sample size (n) needed for estimating the population mean with a certain level of precision
μ

depends on several factors, including the desired confidence level, the margin of error, and the
variability of the population. The formula for calculating the required sample size for estimating the
population mean is given by:
2 2
Z × σ
n = ( )
2
E

Where: is the required sample size.


n

Z is the Z-value corresponding to the desired confidence level.


σ is the population standard deviation.
E is the desired margin of error.
If the population standard deviation is unknown, the sample size formula becomes:
σ

2 2
t × s
n = ( )
2
E

Where: is the t-value from the t-distribution based on the desired confidence level and degrees of
t

freedom.
s is the sample standard deviation.
To use these formulas, you’ll need to decide on the desired confidence level (e.g., 90%, 95%, 99%),
specify the margin of error you can tolerate, and, if applicable, have information on the population
standard deviation or be willing to estimate it from a sample.
Example-3
Sample Size Problem
Problem: You want to estimate the average score of students in a class. The population standard
deviation is known to be , and you want the margin of error to be no more than points with a
5 2 95%

confidence level. What should be the sample size?


Given: - (Z-value for a confidence level) ≈
Z 95% 1.96

σ (population standard deviation) = 5

E (margin of error) =2

2 2
(1.96) × 5
n = ( )
2
2

Calculating this will give the required sample size.


So, the required sample size is approximately (rounded up to the nearest whole number).
25

Same problem solved using R-code:


# Given data
confidence_level <- 0.95
population_std_dev <- 5
margin_of_error <- 2

# Calculate required sample size


required_sample_size <- (qnorm((1 + confidence_level) / 2)^2 * population_std_dev

# Print result
cat("Required Sample Size:", ceiling(required_sample_size), "\n")

Required Sample Size: 25

Confidence Level vs Significance Level


Confidence Significance
Level Level Critical Value (Two-Tailed) Critical Value (One-Tailed)
90% 0.10 (t0.05,df ) )
(t0.10,df

95% 0.05 $(t_{0.025, df}) $ )


(t0.05,df

98% 0.02 $(t_{0.01, df}) $ )


(t0.02,df
Confidence Significance
Level Level Critical Value (Two-Tailed) Critical Value (One-Tailed)
99% 0.01 $(t_{0.005, df}) $ )
(t0.01,df

Confidence
Level 0% 50% 60% 70% 80% 90% 95% 98% 99% 99.8% 99.9%
Percentile t .50 t .75 t .80 t .85 t .90 t .95 t .975 t .99 t .995 t .999 t
.9995
One-Tail 0.50 0.25 0.20 0.15 0.10 0.05 0.025 0.01 0.005 0.001 0.0005
Two-Tails 1.00 0.50 0.40 0.30 0.20 0.10 0.05 0.02 0.01 0.002 0.001

You might also like