Skip to main content

3. Statistical Methods and Data Analysis

Learning Objectives

  • Choose the correct statistical test (t-test, ANOVA, regression) based on the research question and number of groups
  • Compute and interpret a t-statistic and p-value for comparing two group means
  • Explain what a 95% confidence interval communicates about a population parameter
  • Interpret regression coefficients in the context of biological data
  • Identify when a chi-square test is appropriate instead of a t-test or ANOVA
  • Avoid common misuses of statistical tests on biological datasets

Quick Answer

Statistical methods and data analysis form the practical toolkit biostatisticians use to turn raw measurements into defensible conclusions. Given a biological dataset — gene expression levels, drug trial outcomes, crop yields — the analyst must pick the right method: a t-test to compare two group means, ANOVA for three or more groups, regression to model relationships between variables, or a chi-square test for categorical data. Each method answers a specific question and comes with assumptions that must hold for the result to be trustworthy. Mastering test selection matters because using the wrong test — or misreading its output — is one of the most common ways published biological research goes wrong.

Choosing the Right Test

The single most important skill in applied biostatistics isn't running the test — modern software does that in one line of code — it's choosing the correct test for the data and question at hand. The choice depends mainly on two things: how many groups you're comparing, and what type of data you have (continuous vs. categorical).

Why It Matters

Picking the wrong test doesn't just give an imprecise answer — it can give a wrong answer with false confidence. Running three separate t-tests to compare four treatment groups, for instance, inflates the chance of a false positive well beyond 5%, which is why ANOVA exists specifically to handle that case correctly.

The t-test: Comparing Two Means

A t-test asks: is the difference between two group means larger than what random sampling variation would typically produce? It's the workhorse of comparing a treatment group to a control group.

from scipy import stats

group1 = [22, 25, 27, 30, 31] # control
group2 = [29, 30, 32, 34, 36] # treatment

t_stat, p_value = stats.ttest_ind(group1, group2)
print("T-Statistic:", t_stat)
print("P-Value:", p_value)

The t-statistic measures how many standard errors apart the two means are; the p-value converts that into a probability. If p < 0.05, the difference is considered statistically significant.

Example: Comparing systolic blood pressure between patients on a new medication and patients on placebo uses an independent (unpaired) t-test, because the two groups consist of different people. Comparing the same patients' blood pressure before and after treatment uses a paired t-test, because the two measurements are linked to the same individual — paired tests are more sensitive because they control for individual-level variability.

Common Misunderstanding: Students often apply an independent t-test to before/after data on the same subjects. This ignores that each subject's "before" and "after" values are correlated, wasting statistical power and sometimes producing a misleading p-value. Always match the test to the data structure.

ANOVA: Comparing Three or More Groups

ANOVA (Analysis of Variance) tests whether at least one group mean differs significantly from the others, across three or more groups, using a single test.

Worked example: A researcher compares crop yield across four fertilizer types. Running six pairwise t-tests (for 4 groups) would push the overall false-positive risk to roughly 1 − (0.95)⁶ ≈ 26% — far above the intended 5%. A one-way ANOVA tests all four groups simultaneously, controlling the overall false-positive rate at 5%. If ANOVA's p-value is significant, follow-up post-hoc tests (like Tukey's HSD) identify which specific groups differ.

Real-World Example: A drug trial testing three dosage levels (low, medium, high) against a control uses one-way ANOVA to check whether dosage level affects outcome overall, before drilling into which specific dosage differs from control.

Common Misunderstanding: A significant ANOVA result doesn't tell you which groups differ from each other — only that at least one does. Post-hoc tests are required to pinpoint the specific pairwise differences.

Confidence Intervals

A confidence interval quantifies the uncertainty around an estimate.

import numpy as np
import scipy.stats as stats

data = [12, 15, 14, 10, 13, 12, 16]
mean = np.mean(data)
std_dev = np.std(data, ddof=1)
n = len(data)
z_score = stats.norm.ppf(0.975) # for 95% confidence

margin_of_error = z_score * (std_dev / np.sqrt(n))
confidence_interval = (mean - margin_of_error, mean + margin_of_error)
print("Confidence Interval:", confidence_interval)

This computes a 95% CI: a range within which the true population mean is expected to fall, given the observed sample's mean and variability. A narrower interval (from a larger sample or less variable data) reflects a more precise estimate.

Regression: Modeling Relationships

Regression models how one variable changes as another changes — useful whenever a biological outcome depends on a measurable input.

import numpy as np
import statsmodels.api as sm

X = np.array([1, 2, 3, 4, 5]) # e.g., drug dose
y = np.array([2, 3, 5, 7, 11]) # e.g., response measure

X = sm.add_constant(X)
model = sm.OLS(y, X)
results = model.fit()
print(results.summary())

The fitted equation Y = β₀ + β₁X gives β₀ (the predicted response at zero dose) and β₁ (how much the response changes per unit increase in dose). Multiple regression extends this to several predictors at once — e.g., predicting blood pressure from age, weight, and exercise frequency simultaneously, which lets researchers isolate each predictor's effect while holding the others constant.

Common Misunderstanding: A statistically significant regression coefficient does not imply causation. A drug dose might correlate with a response for reasons unrelated to the drug itself (e.g., patients on higher doses were also monitored more closely) — only a properly randomized, controlled experiment supports causal claims.

Key Terms

TermDefinitionRelated Concept
t-testA test comparing the means of two groupsIndependent/Paired t-test
ANOVAA test comparing means across three or more groups simultaneouslyPost-hoc Test
Post-hoc TestA follow-up test after a significant ANOVA to identify which specific groups differANOVA, Tukey's HSD
Confidence IntervalA range of plausible values for a population parameter at a stated confidence levelStandard Error
Regression CoefficientThe estimated change in the outcome variable per unit change in a predictorLinear Regression
Chi-square TestA test for association between categorical variables based on observed vs. expected frequenciesCategorical Data
Multiple Comparisons ProblemThe inflated risk of false positives when running many statistical tests on the same dataANOVA
Statistical PowerThe probability a test correctly detects a real effect when one existsSample Size

Common Mistakes

Misconception: Running several t-tests is just as valid as ANOVA when comparing more than two groups. Why it's wrong: Each individual t-test carries a 5% false-positive risk; running multiple tests on the same data compounds this risk well above 5% overall (the multiple comparisons problem). Correct understanding: Use ANOVA to test all groups at once at a controlled error rate, then apply post-hoc tests only if the ANOVA result is significant.

Misconception: A significant regression coefficient proves that the predictor causes the outcome. Why it's wrong: Regression measures association, not causation. Confounding variables can produce a statistically significant relationship even when no direct causal link exists. Correct understanding: Causal claims require controlled, randomized experimental design — regression on observational data can only establish association.

Misconception: A 95% confidence interval means there's a 95% chance the true value lies within this specific interval. Why it's wrong: The true population parameter is a fixed (though unknown) number — it either is or isn't in the interval. The 95% refers to the long-run success rate of the method across many repeated samples. Correct understanding: "95% confidence" describes the reliability of the interval-construction procedure, not a probability statement about this one calculated interval.

Comparison and Connections

TestData typeGroupsExample use
t-testContinuous2Compare drug vs. placebo means
ANOVAContinuous3+Compare 4 fertilizer treatments
RegressionContinuous predictor/outcomeN/A (relationship)Predict blood pressure from age and weight
Chi-squareCategorical2+ categoriesTest if genotype frequencies match expected Mendelian ratios
Paired t-testIndependent t-test
Same subjects measured twice (before/after)Different, unrelated subjects in each group
Controls for individual variabilityDoes not control for individual differences
More statistical power for matched dataAppropriate when groups are truly separate

Practice Questions

Recall

  1. What is the difference between a t-test and ANOVA? Look for: t-test compares means of exactly two groups; ANOVA compares means across three or more groups in a single test.

  2. What does a 95% confidence interval represent? Look for: a range of values that would contain the true population parameter in about 95% of repeated samples using the same method.

Understanding

  1. Explain why running multiple t-tests instead of one ANOVA is statistically problematic. Look for: each test has its own false-positive risk, and running many compounds the overall chance of a false positive (multiple comparisons problem), inflating error rates beyond the intended 5%.

  2. Why doesn't a significant regression result prove causation? Look for: regression detects statistical association, which can arise from confounding variables or reverse causation, not just direct cause-and-effect; causal claims need controlled experimental design.

Application

  1. A researcher wants to compare average bacterial growth across 5 different antibiotic concentrations. Which test should be used, and why? Look for: one-way ANOVA, since there are more than two groups and the outcome is continuous; follow with post-hoc tests to identify which concentrations differ.

  2. Given a regression equation Y = 2 + 1.5X where X is fertilizer amount (kg) and Y is crop yield (tons), predict the yield when 4 kg of fertilizer is applied. Look for: Y = 2 + 1.5(4) = 8 tons.

Analysis

  1. A study reports a significant ANOVA result (p = 0.01) comparing four drug doses but doesn't run any post-hoc tests, and concludes "all doses differ from each other." Evaluate this conclusion. Look for: the significant ANOVA only shows at least one group differs from the others; it does not identify which pairs differ — post-hoc tests are required before concluding anything about specific pairwise differences.

  2. Compare using a paired t-test versus an independent t-test to analyze cholesterol levels measured in the same 30 patients before and after a diet intervention. Which is correct and why does it matter? Look for: paired t-test is correct because the same individuals are measured twice, so measurements are correlated; using an independent t-test ignores this correlation, reducing statistical power and potentially misrepresenting significance.

FAQ

Q: How do I know if my data meets the assumptions for a t-test or ANOVA? Both assume roughly normally distributed data (especially important for small samples) and, for ANOVA, similar variances across groups. Histograms or normality tests (like Shapiro-Wilk) and variance tests (like Levene's) are used to check these assumptions; non-parametric alternatives (Mann-Whitney U, Kruskal-Wallis) exist when assumptions are violated.

Q: What's the difference between R² and a p-value in regression? The p-value tells you whether a predictor's relationship with the outcome is statistically distinguishable from zero. R² tells you how much of the variation in the outcome is explained by the model overall — a predictor can be significant with a very low R², meaning it matters statistically but explains little of the outcome's total variability.

Q: When should I use a chi-square test instead of a t-test? Use chi-square when your data is categorical (counts in categories, like genotype or disease status) rather than continuous numeric measurements — for example, testing whether observed offspring genotype counts match the 3:1 ratio predicted by Mendelian inheritance.

Q: Why does sample size matter so much in these tests? Larger samples produce narrower confidence intervals and more statistical power (better ability to detect a real effect), but they can also make trivially small differences statistically significant — sample size affects precision, not the actual biological importance of a finding.

Q: Can I use these same tests on gene expression data? Yes, with caution — RNA-seq and microarray data often involve thousands of simultaneous tests (one per gene), which massively compounds the multiple comparisons problem. Specialized corrections (like false discovery rate control) and dedicated tools (DESeq2, edgeR) are used instead of naive t-tests per gene.

Quick Revision

  • Test choice depends on group count and data type: t-test (2 groups), ANOVA (3+ groups), regression (relationships), chi-square (categorical data).
  • t-test types: independent (different subjects) vs. paired (same subjects measured twice).
  • Running multiple t-tests instead of ANOVA inflates the false-positive rate (multiple comparisons problem).
  • A significant ANOVA only shows some group differs — post-hoc tests (e.g., Tukey's HSD) identify which specific groups differ.
  • Confidence intervals describe the reliability of the estimation method across repeated sampling, not a probability about one fixed interval.
  • Regression coefficients quantify association, not causation, unless data comes from a controlled, randomized experiment.
  • R² measures variance explained by the model; a p-value measures whether a predictor's effect is distinguishable from zero.
  • Chi-square tests compare observed vs. expected frequencies for categorical data (e.g., Mendelian ratios).
  • Genomic data with thousands of simultaneous tests requires multiple-testing corrections (false discovery rate), not naive per-test p-values.
  • R, Python, SPSS, SAS, and MATLAB are the standard software platforms for running these analyses.

Prerequisites: Introduction to Biostatistics, Probability and Statistics in Biology

Related Topics: Experimental Design, Bioinformatics Data Analysis

Next Topics: Bioinformatics Data Analysis, Applications in Biotechnology