Path: blob/master/Data Science using Python/Common Hypothesis Tests.ipynb
3074 views
Common Hypothesis Tests:
Hypothesis Testing:
Definition: Hypothesis testing is a statistical method used to make inferences about a population based on sample data.
Purpose: It helps determine whether there is enough evidence to reject a null hypothesis in favor of an alternative hypothesis.
Steps:
Formulate hypotheses: Null hypothesis (H0) assumes no effect or no difference, while the alternative hypothesis (H1) assumes an effect or difference.
Select a significance level (α): This represents the probability of rejecting the null hypothesis when it's actually true.
Collect and analyze data: Use sample data to compute a test statistic.
Make a decision: Compare the test statistic to a critical value or p-value to determine whether to reject the null hypothesis.
Draw conclusions: Based on the decision, either reject or fail to reject the null hypothesis and interpret the results accordingly.
In hypothesis testing, the p-value represents the probability of observing a test statistic as extreme as, or more extreme than, the one actually observed under the assumption that the null hypothesis is true. In other words, it indicates the probability of obtaining the observed data if the null hypothesis is correct.
The significance of the p-value lies in its role in decision-making during hypothesis testing:
Comparing with significance level (α): Typically, a significance level (α) is chosen before conducting the test. Common values for α are 0.05 or 0.01. If the p-value is less than or equal to the significance level (p ≤ α), then we reject the null hypothesis. This implies that the observed data is considered statistically significant, suggesting that the null hypothesis is unlikely to be true.
Interpretation: If the p-value is very small (e.g., p < 0.05), it suggests strong evidence against the null hypothesis, indicating that the observed effect is unlikely to be due to random chance alone. If the p-value is larger than the chosen significance level (e.g., p > 0.05), it suggests that the observed effect could plausibly occur due to random variability, and we fail to reject the null hypothesis.
Decision-making: When the p-value is less than the significance level, we typically reject the null hypothesis in favor of the alternative hypothesis, concluding that there is sufficient evidence to support the claim or hypothesis being tested. When the p-value is greater than the significance level, we fail to reject the null hypothesis, indicating that there is not enough evidence to support the alternative hypothesis.
T-Test:
Purpose: Used to determine if there is a significant difference between the means of two groups. Types: Independent t-test (for comparing means of two independent groups) and paired t-test (for comparing means of two related groups).
T-Test Implementation
We'll have two groups, 'control' and 'treatment', with their respective data.
The data represents the scores of participants in a control group and a treatment group
Chi-Square Test:
The Chi-Square Test determines if there's a significant association between categorical variables by comparing observed and expected frequencies. It assesses whether the observed distribution differs from what would be expected by chance alone. Calculating a test statistic, typically Chi-Square (χ²), and comparing it to critical values or obtaining a p-value helps make the decision. If the statistic exceeds critical values or has a p-value below a chosen significance level (e.g., α = 0.05), the null hypothesis is rejected, suggesting a significant association. Otherwise, the null hypothesis is not rejected, indicating no significant association.
Example:
We'll have two categorical variables, 'gender' and 'smoking status', with their respective counts.
The data represents the counts of individuals categorized by gender and smoking status.
ANOVA (Analysis of Variance) Test
It is a statistical method used to compare the means of three or more samples to determine if they are significantly different from each other. It partitions the total variance observed in a data set into different components attributed to different sources of variation. ANOVA is typically used when you have one categorical independent variable (with three or more groups) and one continuous dependent variable.
Comparision of different Hypothesis tests
Hypothesis Test | Type of Data | Research Question | Example |
---|---|---|---|
T-Test (Independent/Separate Samples) | Continuous (Numerical) | Comparing means of two independent groups | Comparing the average test scores of two different classes |
T-Test (Paired Samples) | Continuous (Numerical) | Comparing means of two related groups | Comparing pre-test and post-test scores of the same group |
One-Way ANOVA | Continuous (Numerical) | Comparing means of three or more independent groups | Comparing the average weight loss across different diets |
Chi-Square Test | Categorical (Nominal/Ordinal) | Assessing association between two categorical variables | Investigating if there's a relationship between smoking status and lung cancer incidence |
Pearson's Correlation | Continuous (Numerical) | Assessing the strength and direction of linear relationship | Examining the correlation between hours spent studying and exam scores |
Mann-Whitney U Test | Continuous (Numerical) | Comparing distributions of two independent groups when assumptions of t-test are violated | Comparing the median income of two neighborhoods when data is not normally distributed |
Kruskal-Wallis Test | Continuous (Numerical) | Comparing distributions of three or more independent groups when assumptions of ANOVA are violated | Comparing the median reaction times across different age groups when data is not normally distributed |
Z-Test | Continuous (Numerical) | Comparing a sample mean to a known population mean | Testing if the average height of students in a class is significantly different from the national average height |