Table of contents
Welcome to week 4 !
Lesson 1 - Confidence Intervals
Confidence Intervals
Confidence intervals are a key concepts in statistics, mainly used to estimate a range within which a population parameter is most likely to fall based on sample data.
A 95% confidence level means, if the same population were sampled multiple times and intervals were calculated each time, approximately 95% of those intervals would contain the desired population parameter.
Components of a Confidence Level :
Point estimating : The sample proportion that fits as the best estimation of the population parameter
Margin of errors : The range of values around estimated range. It reflects uncertainty due to sampling variability.
Interval of values : lower and upper limit contains population parameter.
Question : If the sample size n increases, what will happen to the margin of error? The margin of error will decrease.
[As the percentage confidence level increases, the range of values (width of the confidence interval) also increases. This is because higher confidence levels require capturing a larger proportion of the probability distribution, leading to wider intervals.]
Confidence Intervals - Calculation Steps
Assumption 1. Simple random variable
Assumption 2. Sample size > 30 or population is approximately normal
Confidence Intervals - Example
Calculate a 95% confidence interval for the avg height of adult in New York, where the population is 6,000 adults.
Given, sample mean, x^ = 170cm, σ = 25cm and z(1 - α/2) = 1.96, sample size = 49. What's the margin of error?
Answer : 7
Confidence Interval : 170cm ± margin of error
So, the confidence interval is between 170cm - 7 = 163cm to 170cm + 7 = 177cm.
163cm < μ < 177cm : We are 95% confident that the true average height is between 163cm and 177cm.
Difference Between Confidence and Probability
A : The confidence interval contains the true population parameter approximately 95% of the time (right)
B : There's a 95% probability that the population parameter falls within the confidence interval. (wrong)
μ, which is the population mean is unknown but fixed. μ has no probability distribution, it's not random. It's always the same value for a given population. μ could be in the interval or not. The sample mean on the other had, has a probability distribution. The sample mean changes based on the sample taken. The concept of confidence level is interconnected with sample mean, means it can change. Declaring that I'm 95% confident means repeating the sampling experiment many times and calculating the intervals for each sample estimate.
Confidence Intervals for Proportion
Lesson 2 - Hypothesis Testing
Defining Hypotheses
This is a test to check if what belief I have of the population is likely to be true or not.
Hypotheses in Hypothesis Testing:
Null Hypothesis
This represents a hypothesis that has no effect or no difference. This hypothesis tells there's no relationship between variables/ a parameter is equal to a certain value.
Example : H0, μ=50 (The population mean is 50)
Alternative Hypothesis (Ha or H1)
Alternative hypothesis represents a statement of an effect or difference. This hypothesis suggests that a parameter differs from a specific value/ There is a relationship between variables.
Example : H0, μ ≠ 50 (The population mean is not 50)
Type I and Type II errors
In hypothesis testing, two types of errors can occur : Type I and Type II errors
Type I error (False Positive)
Type I error occurs when a null hypothesis is true. But we incorrectly reject it
Consequence : Assuming that there is an effect or difference when there isn't any.
Probability of occurrence : Denoted by alpha, α which is the significance level of test. 0.05, 0.01, 0.1 are the commonly used value
Example : Concluding a new drug is effective but it's actually not
Type II Error (False Negative)
Type II occurs when the null hypothesis is false, but we fail to reject it
Consequence : Assuming that there's no effect or difference but there's actually one
Probability of occurrence : Denoted by β, the power of test (probability of successfully rejecting the null hypothesis when it's false) is 1-β. Concluding a new drug is not efficient when it actually is.
Summery: A type I error occurs when we incorrectly reject the null hypothesis when it is actually true, while a type II error occurs when we fail to reject the null hypothesis when it is actually false.
Type I Error: An innocent person is found guilty.
Type II Error: A guilty person is found not guilty.
Type I Error: A healthy person is diagnosed with a disease (False Positive).
Type II Error: A person with a disease is diagnosed as healthy (False Negative).
Right-Tailed, Left-Tailed, and Two-Tailed Tests
Right tailed Test :
Definition: A right-tailed test is used when the alternative hypothesis states that the population parameter is greater than the value specified in the null hypothesis.
Use Case: Testing if a new drug leads to an increase in patient recovery rates.
Example: Suppose the null hypothesis is that the mean test score is 50. A right-tailed test would be used to test if the mean test score is greater than 50.
Left-Tailed Test:
Definition: A left-tailed test is used when the alternative hypothesis states that the population parameter is less than the value specified in the null hypothesis
Use Case: Testing if a new teaching method decreases the time students need to complete a task.
Example: Suppose the null hypothesis is that the mean test score is 50. A left-tailed test would be used to test if the mean test score is less than 50.
Two-Tailed Test
Definition: A two-tailed test is used when the alternative hypothesis states that the population parameter is different from the value specified in the null hypothesis without specifying the direction of the difference.
Use Case: Testing if a new drug has an effect, whether it increases or decreases patient recovery rates.
Example: Suppose the null hypothesis is that the mean test score is 50. A two-tailed test would be used to test if the mean test score is different from 50 (either higher or lower).
p-Value
A p-value is the probability assuming null hypothesis is true, that the test statistics takes on a value extreme as or more extreme then the value observed. More likely, from the observed value to the direction of alternative hypothesis
Interpreting the P-Value
Small P-Value (≤ α):
indicates strong evidence against null hypothesis
leads to rejecting the null hypothesis, and accept the alternative hypothesis
suggests the observed data is less like to fall under null hypothesis
Large P-Value (> α\alphaα):
indicates weak evidence against the null hypothesis
leads to failing, to reject the null hypothesis
suggests that the observed data is sufficiently usual to fall under the null hypothesis
Example
Suppose you want to test if a new drug is effective in lowering blood pressure. You perform a hypothesis test with the following hypotheses:
Null Hypothesis (H0): The drug has no effect on blood pressure (mean difference = 0).
Alternative Hypothesis (Ha): The drug has an effect on blood pressure (mean difference ≠ 0).
After collecting and analyzing the sample data, you calculate a test statistic and find a p-value of 0.03.
If α=0.05 :
The p-value (0.03) is less than α\alphaα (0.05).
You reject the null hypothesis.
You conclude that there is significant evidence that the drug has an effect on blood pressure.
If α=0.01 :
The p-value (0.03) is greater than α(0.01)
You don't reject the null hypothesis.
You conclude that there is not enough evidence to say the drug has an effect on blood pressure at the 1% significance level.
Critical Value (k-Value)
Critical value is a point on the distribution of the test statistics which separate the region where the null hypothesis is rejected from the region where it's not rejected. It is determined based on the significance level (α\alpha) of the test.
Both k-value and p-value will lead to the same decision.
Interpreting Results
Steps to Performing Hypothesis Testing:
State the Hypotheses
Null Hypothesis (H0): This is the hypothesis that there is no effect or no difference. It is the hypothesis that you are trying to test against.
Alternative Hypothesis (Ha): This is the hypothesis that there is an effect or a difference. It represents what you want to prove.
Example: Testing if a new drug is effective.
H0: The drug has no effect (μ=0).
Ha: The drug has an effect (μ≠0).
Choose the Significance Level (α)
Definition: The significance level (α) is the probability of rejecting the null hypothesis when it is actually true. Common choices are 0.05, 0.01, or 0.10.
Example: Choose α=0.05
Compute the observed statistic (based on your sample)
Reach a conclusion:
- if p-value < significance level : reject null hypothesis