Comprehensive Guide to University Statistics: One-Sample, Two-Sample, Paired, ANOVA, and Kruskal-Wallis Tests
Principles and Implementation of One-Sample Data Analysis
One-sample tests are employed when an analysis involves a single sample of continuous data. The primary objective is to determine if the sample originated from a parent distribution with a specific, hypothesized mean (or median). This process focuses on assessing whether the sample statistic is "close enough" to the hypothesized population value.
Core Objectives and Five Essential Tasks
For every statistical test performed, five specific tasks must be addressed, regardless of the order in which they are carried out:
Setting the Hypothesis: Formulate clear null () and alternative () hypotheses.
Summarisation and Visualisation: Generate descriptive statistics and visual representations of the data.
Assessment of Assumptions: Evaluate the requirements necessary for the chosen test's validity.
Implementation: Execute the statistical procedure using appropriate software tools.
Interpretation and Reporting: Decipher the output and present results in a formal context.
Test Selection Criteria
One-Sample t-Test: Appropriate when the data are normally distributed. It is robust for larger sample sizes (typically ), even if the underlying population distribution is not normal.
One-Sample Wilcoxon Signed-Rank Test: Utilised when data are non-normal but symmetric, or when sample sizes are small.
Practical Example: Male Guppy Body Lengths
Measurements of male guppy body lengths () from the Guanapo River are tested against a hypothesized mean of .
Null Hypothesis (): The mean body length is equal to ().
Alternative Hypothesis (): The mean body length is not equal to ().
Assumptions for the One-Sample t-Test
Normality: The parent population from which the sample is drawn must be normally distributed. This is checked via histograms (looking for symmetry and uni-modality), Quantile-Quantile (Q-Q) plots, and the Shapiro-Wilk test.
Independence: Each data point must be independent of others. This is an experimental design issue (e.g., avoiding repeated measurements from the same individual) and cannot be tested statistically after data collection.
Evaluation of Normality
Shapiro-Wilk Test: Calculates the probability of obtaining the observed sample if the distribution were normal. For guppy data (), p > 0.05 suggests insufficient evidence to reject the null hypothesis of normality.
Q-Q Plots: Diagonal lines representing hypothesized normal distributions. Points should fall close to this line.
Uniform Distributions: Show a pronounced "S-shaped" pattern (snaking) because they are more condensed than normal distributions.
t-Distributions: More spread out than normal distributions, also showing an S-shaped pattern in the opposite direction of uniform plots.
Skewed Distributions (e.g., Exponential): Points curve away from the diagonal line at both ends. Right-skew curves above the line; left-skew curves below it.
Reporting Results
A one-sample t-test () indicates that the mean body length () differs significantly from . Standard reporting should include the mean, the p-value, and ideally the test statistic and degrees of freedom ().
Comparative Analysis of Two-Sample Data
Student's t-test for two samples determines if two distinct samples of continuous data originated from the same parent distribution by comparing their means.
Hypotheses and Requirements
Null Hypothesis (): The mean body length does not differ between the two groups.
Alternative Hypothesis (): The mean body length differs between the two groups.
Assumptions for Student’s t-Test
Normality: Parent distributions are normal. If sample sizes are large (e.g., Aripo River ; Guanapo River ), the test is robust to deviations from normality.
Independence: Samples are independent of one another.
Homogeneity of Variance (Equal Variance): Parent distributions should have the same spread.
Variance and Normality Testing
Equality of Variance: Tested using Bartlett’s test if data are normal, or Levene’s test if data are non-normal.
Example Result: Levene’s test () indicates equal variance between rivers.
Normality Sensitivity: Shapiro-Wilk tests can be overly strict with large samples (), failing sets that are nearly normal. Conversely, they may pass non-normal sets if the sample is small.
Implementation: Student's t-Test vs. Mann-Whitney U Test
Student’s t-Test: Used when variance is equal and data are normal (or robustly handled). Example: mean body length in the Guanapo river () vs. Aripo river (), result: .
Mann-Whitney U Test: The non-parametric alternative used when normality cannot be assumed. It tests for differences in medians. Example Median Result: Guanapo () vs. Aripo (), result: .
Paired Data Analysis
Paired t-tests are used for samples that can be linked by a connecting factor, such as measurements taken from the same individual before and after a treatment (e.g., cortisol levels in the morning vs. evening).
Data Transformation and Visualisation
For paired data, the analysis often focuses on the difference between paired points (). Visualisation techniques include:
Jittered Boxplots: Displaying actual data points with a small amount of variation to prevent overlap.
Individual Change Plots: Connecting individual patient data points between time intervals to show trajectories.
Statistical Implementation
Paired t-test: Assumes the underlying population of differences is normally distributed. Result: Morning () vs. Evening (), result: .
Wilcoxon Signed-Rank Test (Paired): The non-parametric version for paired data that violates normality. Result: Morning median () vs. Evening median (), result: .
Analysis of Variance (ANOVA)
ANOVA is a generalisation of the two-sample Student's t-test, used to compare the means of three or more groups of continuous response data.
One-Way ANOVA Hypotheses
Null Hypothesis (): The mean feeding rates at all sites (e.g., Exposed, Partial, Sheltered) are the same.
Alternative Hypothesis (): The mean feeding rates are not all equal.
Residuals and Assumptions in ANOVA
Instead of checking every group for normality, it is efficient to check the residuals of the combined data set. Residuals are the differences between each individual data point and its respective group mean.
Diagnostic Plots (GGResidPanel):
Residuals Plot: Points should be uniformly distributed above and below the horizontal line; the red smoother line should be flat.
Q-Q Plot: Residuals should lie on the diagonal blue line for normality.
Location-Scale Graph: Checks if the variance of residuals remains constant; the red line should be horizontal.
Cook’s Distance: Identifies influential points. A rule of thumb is that values > 1.0 or exceeding may unduly influence the model.
Interpretation and Post-Hoc Testing
ANOVA reveals if any difference exists but does not specify which groups differ. If the ANOVA is significant (p < 0.05), a post-hoc test is required.
Tukey’s Range Test (HSD): Performs pairwise comparisons while adjusting for multiple tests to prevent p-hacking or data-dredging (the practice of performing numerous tests until a significant result is found).
Example Output: Comparison of sites reveals a significant difference in feeding rates between oystercatchers at different locations ().
Kruskal-Wallis Test: Non-Normal Multi-Sample Data
The Kruskal-Wallis one-way ANOVA is the non-parametric analogue of ANOVA, used when the assumption of normality is violated. It is an extension of the Mann-Whitney test for multiple groups.
Assumptions and Characteristics
Shape: Parent distributions must have the same shape.
Independence: Observations must be independent.
Variance: Parent distributions must have equal variance (homoscedasticity), checked via Levene's test.
Implementation and Interpretation
Kruskal-Wallis Rank Sum Test: Identifies if the medians of several groups (e.g., spider monkey aggression based on familiarity) are equal. Result: .
Dunn’s Test (Post-Hoc): The equivalent of Tukey’s test for non-normal data. It includes corrections for multiple comparisons, such as the "Holm" method.
Reporting Dunn’s Test Results
In aggression studies between monkeys, Dunn’s test might show no significant difference between "high" and "low" familiarity (), but significant differences between "high" and "none" () or "low" and "none" ().