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:

  1. Setting the Hypothesis: Formulate clear null (H0H_0) and alternative (H1H_1) hypotheses.

  2. Summarisation and Visualisation: Generate descriptive statistics and visual representations of the data.

  3. Assessment of Assumptions: Evaluate the requirements necessary for the chosen test's validity.

  4. Implementation: Execute the statistical procedure using appropriate software tools.

  5. 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 n30n \ge 30), 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 (mmmm) from the Guanapo River are tested against a hypothesized mean of 20mm20\,mm.

  • Null Hypothesis (H0H_0): The mean body length is equal to 20mm20\,mm (μ=20\mu = 20).

  • Alternative Hypothesis (H1H_1): The mean body length is not equal to 20mm20\,mm (μ20\mu \neq 20).

Assumptions for the One-Sample t-Test
  1. 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.

  2. 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 (W=0.94938,p=0.1764W = 0.94938, p = 0.1764), 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 (t28=3.55,p=0.0014t_{28} = -3.55, p = 0.0014) indicates that the mean body length (xˉ=18.29mm\bar{x} = 18.29\,mm) differs significantly from 20mm20\,mm. Standard reporting should include the mean, the p-value, and ideally the test statistic and degrees of freedom (dfdf).

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 (H0H_0): The mean body length does not differ between the two groups.

  • Alternative Hypothesis (H1H_1): The mean body length differs between the two groups.

Assumptions for Student’s t-Test
  1. Normality: Parent distributions are normal. If sample sizes are large (e.g., Aripo River n=39n=39; Guanapo River n=29n=29), the test is robust to deviations from normality.

  2. Independence: Samples are independent of one another.

  3. 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 (p=0.188p = 0.188) indicates equal variance between rivers.

  • Normality Sensitivity: Shapiro-Wilk tests can be overly strict with large samples (n40n \approx 40), 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 (xˉ=18.29mm\bar{x} = 18.29\,mm) vs. Aripo river (xˉ=20.33mm\bar{x} = 20.33\,mm), result: p=0.0003p = 0.0003.

  • Mann-Whitney U Test: The non-parametric alternative used when normality cannot be assumed. It tests for differences in medians. Example Median Result: Guanapo (18.8mm18.8\,mm) vs. Aripo (20.1mm20.1\,mm), result: p=0.0006p = 0.0006.

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 (xdiff=xafterxbeforex_{diff} = x_{after} - x_{before}). 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 (313.5nmol/l313.5\,nmol/l) vs. Evening (197.4nmol/l197.4\,nmol/l), result: p=5.3×105p = 5.3 \times 10^{-5}.

  • Wilcoxon Signed-Rank Test (Paired): The non-parametric version for paired data that violates normality. Result: Morning median (320.5nmol/l320.5\,nmol/l) vs. Evening median (188.9nmol/l188.9\,nmol/l), result: p=0.00017p = 0.00017.

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 (H0H_0): The mean feeding rates at all sites (e.g., Exposed, Partial, Sheltered) are the same.

  • Alternative Hypothesis (H1H_1): 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):

  1. Residuals Plot: Points should be uniformly distributed above and below the horizontal line; the red smoother line should be flat.

  2. Q-Q Plot: Residuals should lie on the diagonal blue line for normality.

  3. Location-Scale Graph: Checks if the variance of residuals remains constant; the red line should be horizontal.

  4. Cook’s Distance: Identifies influential points. A rule of thumb is that values > 1.0 or exceeding 4/n4/n 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 (p=4.13×1033p = 4.13 \times 10^{-33}).

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
  1. Shape: Parent distributions must have the same shape.

  2. Independence: Observations must be independent.

  3. 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: p=0.0011p = 0.0011.

  • 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 (p=0.160p = 0.160), but significant differences between "high" and "none" (p=0.00077p = 0.00077) or "low" and "none" (p=0.0490p = 0.0490).