Skip to content

Statistics & Data Analysis Overview

Purpose: Map your research question to the right statistical test and FoodSpec function.
Audience: Users planning analyses; researchers choosing between tests.
Time to read: 5–10 minutes.
Prerequisites: Basic familiarity with statistical concepts (p-values, confidence intervals).


This page summarizes the statistical tools available in FoodSpec and where to use them. Use it as a quick map from common questions to recommended methods, functions, and workflows.

For notation and symbols, see the Glossary.

Questions → Approaches

Question Recommended approach Functions Example workflow
Are two groups different (e.g., reference vs suspect)? Two-sample or paired t-test run_ttest Batch QC
Do ≥3 groups differ (e.g., oil types, heating stages)? One-way ANOVA (+ Tukey) run_anova, run_tukey_hsd Oil authentication, Heating
Are multivariate features different across groups? MANOVA (if statsmodels installed) run_manova Multivariate oil/microbial features
Which groups differ pairwise? Post-hoc comparisons run_tukey_hsd Oil authentication
How large is the difference? Effect sizes compute_cohens_d, compute_anova_effect_sizes Any comparative study
Are two variables associated? Correlation (Pearson/Spearman) compute_correlations, compute_correlation_matrix Heating ratios vs time/quality
Is there a lagged relationship? Cross-correlation for sequences compute_cross_correlation Time-resolved heating/processing
Is my design sufficient? Design checks summarize_group_sizes, check_minimum_samples All workflows

How to explore

  • Theory chapters: see the stats section in the nav (hypothesis testing, ANOVA/MANOVA, correlations, design).
  • API reference: Statistics.
  • Workflows: each workflow page includes a “Statistical analysis” section with code snippets and interpretation.
  • Protocols: reproducibility checklist and benchmarking framework explain how to report and compare results.

When Results Cannot Be Trusted

⚠️ Red flags invalidating statistical conclusions:

  1. Test chosen without examining assumptions
  2. Parametric tests (t-test, ANOVA) require normality and equal variances
  3. Applying parametric tests to non-normal data inflates Type I error
  4. Fix: Check Q-Q plots or Shapiro-Wilk test; use nonparametric alternatives if violated

  5. P-value without checking actual difference magnitude

  6. Significance (p < 0.05) ≠ practical importance
  7. Large sample sizes can detect tiny, irrelevant differences; small samples miss real effects
  8. Fix: Report effect sizes (Cohen's d, R²) alongside p-values; discuss practical relevance

  9. Cherry-picked post-hoc comparisons (report only 3 out of 20 comparisons)

  10. Selective reporting inflates false positive rates
  11. P-value interpretation assumes pre-specified hypotheses, not post-hoc hunting
  12. Fix: Declare comparisons of interest before analysis; apply multiple-testing correction

  13. No correction for multiple tests (testing 200 peaks, reporting p < 0.05 without adjustment)

  14. 200 independent tests expect ~10 false positives at α=0.05
  15. Uncorrected p-values are misleading
  16. Fix: Use Bonferroni, Benjamini–Hochberg FDR, or permutation tests; report adjusted p-values

  17. Outliers removed without justification

  18. Removing extreme values to "improve" results is data fabrication
  19. Real spectroscopy and natural products have variability; removing it hides real uncertainty
  20. Fix: Identify outliers a priori based on QC criteria; document and report removals

  21. Comparing groups of very different sizes (n=100 vs n=3)

  22. Statistical power dominated by smallest group
  23. Heterogeneous variance assumptions violated
  24. Fix: Aim for similar group sizes; if imbalanced, use Welch's test, rank tests, or permutation tests

  25. Independence assumption violated (20 technical replicates of 1 sample ≠ 20 independent samples)

  26. Repeated measurements of same unit are autocorrelated, not independent
  27. Tests assuming independence produce inflated significance
  28. Fix: Analyze distinct samples as replicates; document which measurements are paired or nested

  29. Batch confounding (treatment A all from Day 1, B all from Day 2)

  30. Systematic drift (instrument, temperature, operator) accumulates with batch, not treatment
  31. Impossible to disentangle batch from treatment effects
  32. Fix: Randomize sample order; use batch-aware analysis (include batch in model or GroupKFold CV)

Next Steps


Notes

  • Ensure preprocessing and wavenumber alignment are consistent before running tests.
  • Check assumptions (normality, variance, independence) and consider nonparametric options when violated.
  • Report p-values and effect sizes; discuss practical (food science) relevance alongside statistical significance.