Module 10: Hypothesis Tests for Two Samples
Supporting Lectures:
EGN3443 Module 10 - Hypothesis Testing for 2 Samples
1. Independent Samples t-Test
Definition
An independent samples t-test compares the means of two separate, unrelated groups to determine if there is a statistically significant difference between them.
Key Characteristics
-
Used when two distinct groups are compared
-
Groups are not related or paired
-
Assumes normal distribution and approximately equal variances
Calculation Steps
-
State null and alternative hypotheses
-
Calculate t-statistic: t = (x̄₁ - x̄₂) / √[(s₁²/n₁) + (s₂²/n₂)] Where:
-
x̄₁, x̄₂ are sample means
-
s₁, s₂ are sample standard deviations
-
n₁, n₂ are sample sizes
Example Calculation
Group 1: x̄₁ = 10, s₁ = 2, n₁ = 30
Group 2: x̄₂ = 8, s₂ = 3, n₂ = 25
t = (10 - 8) / √[(2²/30) + (3²/25)]
Web References
Scenarios
An independent samples t-test is appropriate in the following scenarios:
- Comparing two treatment groups in a randomized controlled trial (e.g., comparing the mean blood pressure reduction between patients receiving a new medication versus a placebo)
- Comparing performance between two different groups that are naturally distinct (e.g., comparing mean test scores between students from two different schools)
- Comparing a product/process change with two independent samples (e.g., comparing the tensile strength of metal parts produced by two different manufacturing methods)
- Testing the effect of a binary categorical variable on a continuous outcome (e.g., comparing mean salary between male and female employees in a company)
- Comparing before-and-after measurements on completely different subjects (e.g., comparing customer satisfaction scores before and after a service change, using different customers in each period)
- Testing for differences between experimental conditions with different participants assigned to each condition (e.g., comparing reaction times between two interface designs with different users testing each design)
- Comparing naturally occurring groups on some measured variable (e.g., comparing the mean height of plants grown in two different soil types)
- Comparing two different methods or tools using independent samples (e.g., comparing the accuracy of two different diagnostic tests on separate groups of patients)
- Market research comparisons between distinct consumer segments (e.g., comparing average spending between urban and rural customers)
- Ecological studies comparing different populations or locations (e.g., comparing mean pollution levels between two different cities)
- Comparing intervention effects between separate groups (e.g., comparing the mean weight loss between two different diet programs with different participants in each program)
- Educational research comparing teaching methods with different classes (e.g., comparing test scores between students taught with traditional methods versus those taught with a new approach)
For all these scenarios, the key requirements are:
- The dependent variable must be continuous (or approximately continuous)
- The observations in each group must be independent of each other
- The two groups being compared must be independent of each other
- The data should be approximately normally distributed or the sample size should be sufficiently large
2. Paired Samples t-Test
Definition
A paired samples t-test compares the means of two related groups, typically measurements taken from the same subjects before and after an intervention.
Key Characteristics
-
Measurements are paired or matched
-
Differences between pairs are analyzed
-
Assumes normal distribution of differences
Calculation Steps
State null and alternative hypotheses
H₀: μd = 0 (no difference in population means)
H₁: μd ≠ 0 (significant difference exists)
-
Calculate differences between pairs
-
Calculate mean difference (d̄)
-
Calculate standard deviation of differences (sd)
-
Compute t-statistic: t = d̄ / (sd / √n) Where:
Example Calculation
Before Treatment: [10, 12, 15, 18, 20]
After Treatment: [9, 11, 14, 17, 19]
Differences: [1, 1, 1, 1, 1]
Mean Difference: 1
Web References
Scenarios
A paired samples t-test (also called dependent samples t-test or paired t-test) is appropriate in the following scenarios:
- Before-and-after measurements on the same subjects (e.g., comparing patients' blood pressure before and after receiving a treatment)
- Repeated measurements on the same subject under different conditions (e.g., measuring a person's reaction time when tired versus when well-rested)
- Matched pairs designs where subjects are deliberately matched on important characteristics (e.g., comparing treatment outcomes between pairs of twins, or patients matched by age, gender, and disease severity)
- Crossover studies where each subject receives both treatments in sequence (e.g., comparing the effectiveness of two medications where each participant tries both drugs with a washout period between)
- Testing the same samples under two different conditions (e.g., testing the same material samples with two different testing methods)
- Performance comparisons using the same individuals (e.g., comparing students' scores on two different types of assessments)
- Product comparisons where the same evaluators rate both products (e.g., having the same group of testers rate two different user interfaces)
- Longitudinal studies with two time points for the same participants (e.g., measuring cognitive ability at the beginning and end of an educational program)
- Split-plot agricultural experiments where measurements are taken from adjacent plots of land (e.g., comparing crop yields from two different fertilizers applied to adjacent sections of the same fields)
- Comparing measurements taken from symmetrical body parts (e.g., comparing strength between dominant and non-dominant hands in the same individuals)
- Software or algorithm comparison using the same datasets (e.g., comparing the accuracy of two different machine learning algorithms tested on the same datasets)
- Taste tests where the same participants evaluate multiple products (e.g., comparing consumer ratings of two different food products tasted by the same panel)
For all these scenarios, the key requirements are:
- The dependent variable must be continuous (or approximately continuous)
- The paired observations should have a natural connection or dependency
- The differences between pairs should be approximately normally distributed
- The sample must consist of matched or paired data points
The paired t-test is particularly valuable when there's high variability between subjects but relatively consistent differences within pairs, as the pairing helps to eliminate between-subject variability and increase statistical power.
3. F-Test for Comparing Variances
Definition
An F-test determines whether two population variances are significantly different by comparing their sample variances.
Key Characteristics
Calculation Steps
-
State null and alternative hypotheses
-
Calculate F-statistic: F = larger sample variance / smaller sample variance
Example Calculation
Group 1 Variance: s₁² = 25
Group 2 Variance: s₂² = 16
F = 25 / 16 = 1.5625
Web References
Scenarios
An F-test for comparing variances is appropriate in the following scenarios:
- Testing homogeneity of variance before performing a t-test or ANOVA (e.g., checking if the variability in test scores is similar across different teaching methods)
- Comparing precision between two measurement methods (e.g., determining if one laboratory technique produces more consistent results than another)
- Quality control comparisons between manufacturing processes (e.g., comparing the consistency of parts produced by two different machines)
- Assessing variability in biological systems (e.g., comparing the genetic diversity between two populations)
- Comparing variability in performance between groups (e.g., determining if experienced workers have more consistent output than novices)
- Instrument validation studies comparing the precision of two different instruments (e.g., comparing the variance in repeated measurements from two different sensors)
- Comparing treatment consistency in pharmaceutical research (e.g., determining if one drug formulation produces more variable effects than another)
- Comparing risk or volatility in financial investments (e.g., comparing the variance in returns between two different investment strategies)
- Testing if experimental conditions affect variability rather than just the mean (e.g., determining if a treatment not only changes the average response but also makes responses more consistent)
- Comparing environmental variability between sites (e.g., comparing temperature fluctuations between two different ecosystems)
- Assessing consistency in human performance under different conditions (e.g., comparing the variability in reaction times between two different interface designs)
- Testing if one group is more heterogeneous than another (e.g., comparing if student performance is more variable in one classroom compared to another)
For all these scenarios, the key requirements are:
- The data in both groups should be approximately normally distributed
- The observations in each group should be independent
- The samples should be random samples from their respective populations
It's important to note that F-tests for comparing variances are relatively sensitive to departures from normality. If the normality assumption is violated, alternative tests like Levene's test or Brown-Forsythe test may be more appropriate for comparing variances.
4. Tests for Comparing Proportions
Definition
Tests for comparing proportions determine if there's a significant difference between the proportions of two populations or groups.
Key Techniques
Calculation Steps
-
State null and alternative hypotheses
-
Calculate pooled proportion
-
Compute z-statistic: z = (p₁ - p₂) / √[p(1-p)(1/n₁ + 1/n₂)]
Example Calculation
Group 1: 30 successes out of 100
Group 2: 45 successes out of 150
Pooled proportion calculation
Web References
Two-Proportion Z-Test Appropriate Scenarios:
- Comparing vaccination rates between two different demographic groups (e.g., comparing COVID-19 vaccination rates between urban and rural populations)
- Comparing success rates of two different treatments or interventions (e.g., comparing the recovery rates of patients receiving two different surgical procedures)
- A/B testing in marketing (e.g., comparing conversion rates between two different webpage designs)
- Comparing defect rates between two manufacturing processes (e.g., determining if one assembly line produces fewer defective products than another)
- Comparing response rates between two survey methods (e.g., determining if online surveys yield higher response rates than mail surveys)
- Comparing pass/fail rates between two different educational approaches (e.g., comparing the proportion of students passing an exam under traditional vs. flipped classroom teaching)
- Comparing adoption rates of two different products or technologies (e.g., comparing the percentage of businesses adopting cloud storage vs. on-premise solutions)
- Comparing click-through rates in digital marketing (e.g., comparing the proportion of users who click on two different ad designs)
- Comparing infection rates between two populations (e.g., comparing the proportion of infections between vaccinated and unvaccinated groups)
- Comparing germination rates in agricultural experiments (e.g., comparing the percentage of seeds that germinate under two different conditions)
Chi-Squared Test of Independence Appropriate Scenarios:
- Testing for associations between categorical variables (e.g., determining if educational level is associated with voting preference)
- Comparing distributions across multiple categories (e.g., determining if the distribution of product preferences differs between age groups)
- Testing for differences in frequency distributions (e.g., comparing if the distribution of blood types differs between two populations)
- Market segmentation analysis (e.g., determining if product preferences are independent of demographic factors)
- Comparing categorical outcomes across groups (e.g., comparing diagnostic outcomes between different hospitals)
- Analyzing survey responses with multiple categorical options (e.g., determining if response patterns to a multiple-choice question differ between groups)
- Testing for changes in categorical distributions over time (e.g., comparing if the distribution of transportation methods changed before and after a policy change)
- Analyzing contingency tables with multiple rows and columns (e.g., examining the relationship between educational background and career choice)
- Comparing product preferences across demographic groups (e.g., determining if beverage preferences differ by age group)
- Analyzing patterns in categorical data (e.g., determining if housing preferences are independent of income level)
Both Tests Are Appropriate When:
- Comparing binary outcomes between two groups (e.g., comparing the proportion of "yes" responses between two survey groups)
- Testing if the proportion of a characteristic differs between two populations (e.g., comparing the percentage of left-handed people in two different countries)
- Comparing event rates between two groups (e.g., comparing accident rates between two different manufacturing facilities)
- Testing for differences in binary classifications (e.g., comparing the proportion of positive test results between two laboratories)
- Analyzing 2×2 contingency tables (e.g., comparing smokers vs. non-smokers in two different regions)
For all these scenarios, the key requirements are:
- Data must be counts or frequencies (categorical data)
- The observations should be independent
- For the z-test, sample sizes should be sufficiently large (np ≥ 5 and n(1-p) ≥ 5 for both groups)
- For the chi-squared test, expected frequencies should generally be ≥ 5 in each cell
Note that for 2×2 tables, the two-proportion z-test and chi-squared test of independence are mathematically equivalent (the chi-squared statistic is the square of the z-statistic).
5. Non-Parametric Alternatives
Definition
Non-parametric tests are used when data does not meet parametric test assumptions (normality, equal variance).
Key Non-Parametric Tests
-
Mann-Whitney U test (alternative to independent t-test)
-
Wilcoxon signed-rank test (alternative to paired t-test)
-
Kruskal-Wallis test (alternative to one-way ANOVA)
Characteristics
Web References
Mann-Whitney U Test / Wilcoxon Rank-Sum Test (Alternative to Independent t-test)
- Comparing ordinal data between two groups (e.g., comparing customer satisfaction ratings between two service providers)
- Analyzing data with outliers that would skew parametric tests (e.g., comparing income distributions between two regions when some extreme values exist)
- Small sample sizes where normality cannot be verified (e.g., comparing performance metrics between two small teams)
- Comparing data from clearly non-normal distributions (e.g., comparing response times that follow a skewed distribution)
- Comparing ranked data between independent groups (e.g., comparing athletic performance rankings between two training programs)
- When transformations fail to normalize the data (e.g., comparing biological measurements that remain non-normal after attempted transformations)
- Comparing scores on assessment tools with ceiling or floor effects (e.g., comparing scores on a questionnaire where many respondents hit the maximum score)
- When comparing medians is more appropriate than comparing means (e.g., comparing home prices between two neighborhoods)
Wilcoxon Signed-Rank Test (Alternative to Paired t-test)
- Before-and-after measurements when differences are not normally distributed (e.g., comparing pain scores before and after treatment)
- Paired comparisons with outliers (e.g., comparing reaction times to two stimuli when some responses are extremely slow)
- Small sample paired data (e.g., comparing biomarker levels in a small group of patients before and after intervention)
- Ordinal paired measurements (e.g., comparing subjects' preference ratings for two products)
- Ranking performance under two different conditions with the same subjects (e.g., comparing athletes' performance rankings under two different training regimens)
- When the magnitude of differences varies widely among pairs (e.g., comparing blood pressure changes where some patients show dramatic changes while others show minimal changes)
- Cross-over trials with non-normal outcome distributions (e.g., comparing the effects of two treatments in patients who receive both treatments in sequence)
Sign Test (Simplest Alternative to Paired t-test)
- When only the direction of difference matters, not the magnitude (e.g., determining if one product is consistently preferred over another)
- Extremely skewed distributions where even ranks might be inappropriate (e.g., comparing datasets with extreme outliers)
- Paired comparisons where only "greater than," "less than," or "equal to" information is available (e.g., comparing whether performance improved, deteriorated, or stayed the same after training)
- When the exact values cannot be measured but the relative ordering can (e.g., comparing taste preferences between two foods)
- Very simple before-after comparisons (e.g., comparing if a treatment leads to improvement or deterioration)
Fisher's Exact Test (Alternative to Chi-Square Test for Small Samples)
- Small sample comparisons of categorical data where expected cell counts are low (e.g., comparing rare disease occurrences between two small groups)
- 2×2 contingency tables with fewer than 5 expected observations in any cell (e.g., comparing adverse event occurrences between two small treatment groups)
- Precise probability calculations for contingency tables (e.g., determining exact probability of observed distribution in genetic studies with small samples)
- Testing association in small samples (e.g., comparing genetic mutations in small cohorts)
McNemar's Test (Alternative for Paired Nominal Data)
- Before-and-after comparisons with binary outcomes (e.g., comparing presence/absence of symptoms before and after treatment)
- Matched-pairs designs with binary outcomes (e.g., comparing diagnostic test results in pairs of siblings)
- Crossover studies with binary outcomes (e.g., comparing presence/absence of side effects under two different treatments)
- Comparing binary responses from the same subjects under different conditions (e.g., comparing agreement/disagreement to statements before and after an informational intervention)
Key Considerations for All Non-parametric Tests:
- Non-parametric tests generally have lower statistical power than their parametric counterparts when parametric assumptions are met
- They are appropriate when data transformations cannot achieve normality
- They are often preferred when sample sizes are too small to reliably assess normality
- They are robust against outliers and skewed distributions
- They are suitable for ordinal data or when the measurement scale is questionable
In general, non-parametric tests are appropriate whenever the assumptions of the corresponding parametric test cannot be met, particularly the assumption of normally distributed data or when dealing with ordinal data.
Conclusion
Understanding these hypothesis tests provides powerful tools for comparing groups and making statistical inferences across various research and practical scenarios.