Biostatistics: Standard Error, Quantiles, Probability Distributions, and Boxplots

Foundations of Descriptive Statistics and Spread

  • Tabular Data Import and Processing in R:

    • Importing external data tables into R serves as the primary foundational step for computational biostatistics.
    • Once imported, structured dataframes allow column-wise extraction of variables for descriptive and inferential analysis.
  • Graphical Data Representation via Histograms:

    • Histograms depict the empirical distribution of continuous or discrete numerical variables by segmenting data into intervals (classes or bins).
    • Display modes can be customized via parameters to represent either absolute frequencies (raw counts) or relative frequencies (proportions of the total sample).
    • Additional customizable graphic parameters include custom axis labels, axis limits, and color palettes.
  • Measures of Central Tendency:

    • Arithmetic Mean (xˉ\bar{x}): Represents the mathematical average of all observed values. It is calculated by summing all individual data points and dividing by the total sample size nn. It is highly sensitive to extreme outliers, which pull the mean disproportionately toward the extreme values.
    • Median: Represents the middle value of an ordered dataset. Exactly half (50%50\%) of the observations are smaller than or equal to the median, and the other half (50%50\%) are greater than or equal to it. The median is robust against extreme outliers and skewed distributions.
  • Residuals and Degrees of Freedom:

    • Residual (rir_i): The individual deviation or distance of an observed data point xix_i from the sample mean xˉ\bar{x}:     ri=xi−xˉr_i = x_i - \bar{x}
    • A data point positioned above the mean yields a positive residual, whereas a data point below the mean yields a negative residual.
    • Degrees of Freedom (dfdf): When calculating sample variance, the sum of squared residuals is divided by n−1n - 1 rather than nn. One degree of freedom is lost because the sample mean xˉ\bar{x} is already fixed as an intermediate parameter estimate from the sample data.
  • Sample Variance and Standard Deviation:

    • Sample Variance (s2s^2): Quantifies the dispersion of data points around the mean by squaring each residual, summing them across all observations, and dividing by the remaining degrees of freedom:     s2=∑i=1n(xi−xˉ)2n−1s^2 = \frac{\sum_{i=1}^n (x_i - \bar{x})^2}{n - 1}
    • Squaring prevents positive and negative residuals from canceling each other out to zero and places greater weight on larger deviations.
    • Sample Standard Deviation (ss): The positive square root of the sample variance:     s=s2s = \sqrt{s^2}
    • Calculating the square root converts the measure of dispersion back into the original units of measurement of the underlying data (identical to the unit of the arithmetic mean).

Standard Error of the Mean (SEM)

  • Conceptual Definition and Purpose:

    • The sample mean xˉ\bar{x} is an empirical estimate of the unknown true population mean μ\mu.
    • The Standard Error of the Mean (SEM\text{SEM}), also termed standard error, measures the statistical precision and accuracy of the sample mean as an estimator of the population parameter.
    • Unlike variance (s2s^2) or standard deviation (ss), which describe the biological dispersion or spread of individual data points within a sample, SEM\text{SEM} is purely an error metric of estimation precision.
  • Mathematical Formulation:

    • The standard error is calculated by dividing the sample standard deviation ss by the square root of the total sample size nn:     SEM=sn\text{SEM} = \frac{s}{\sqrt{n}}
  • Confidence Probability for Normal Distributions:

    • When sample data originate from a normally distributed population, the true population mean μ\mu lies within the interval of plus or minus one standard error around the sample mean with an exact probability of approximately 68%68\%:     P(xˉ−1 SEM≤μ≤xˉ+1 SEM)≈0.68P(\bar{x} - 1\,\text{SEM} \le \mu \le \bar{x} + 1\,\text{SEM}) \approx 0.68
  • Mathematical Dynamics and Influencing Factors:

    • Effect of Data Spread (ss): As individual data points cluster closer to the mean (smaller standard deviation ss), the numerator decreases, resulting in a smaller SEM\text{SEM} and a more precise estimation.
    • Effect of Sample Size (nn): As the sample size nn increases, the denominator n\sqrt{n} grows, reducing SEM\text{SEM} and narrowing the error band.
  • Concrete Numerical Examples:

    • Baseline Scenario: Sample size n=100n = 100, standard deviation s=10s = 10:     SEM=10100=1010=1\text{SEM} = \frac{10}{\sqrt{100}} = \frac{10}{10} = 1
    • Reduced Dispersion Scenario: Sample size n=100n = 100, standard deviation reduced to s=5s = 5:     SEM=5100=510=0.5\text{SEM} = \frac{5}{\sqrt{100}} = \frac{5}{10} = 0.5     Halving the standard deviation halves the standard error from 11 to 0.50.5.
    • Reduced Sample Size Scenario: Sample size reduced to n=25n = 25, standard deviation maintained at s=10s = 10:     SEM=1025=105=2\text{SEM} = \frac{10}{\sqrt{25}} = \frac{10}{5} = 2     Reducing the number of observations by a factor of four doubles the estimation error from 11 to 22.
  • Comparative Applications in Biology (Tree Height Comparison):

    • Consider a comparative study measuring tree heights in meters (m\text{m}) across oak, beech, and giant sequoia (mammoth tree) populations.
    • If the confidence intervals defined by xˉ±1 SEM\bar{x} \pm 1\,\text{SEM} overlap between oak and beech samples, the observed difference between their mean heights is within the margin of estimation error, indicating that their heights do not significantly differ.
    • If giant sequoias yield a mean height whose xˉ±1 SEM\bar{x} \pm 1\,\text{SEM} interval exhibits zero overlap with the error intervals of oaks and beeches, giant sequoias are concluded to be significantly taller than the other two species.
  • Implementation in R:

    • R does not provide a dedicated single built-in function for computing SEM\text{SEM}.
    • Calculation requires composing base functions: sd() calculates sample standard deviation ss, length() determines sample size nn, and sqrt() computes the square root.
    • Sequential procedural execution:
    • s <- sd(circumference)
    • n <- length(circumference)
    • sem <- s / sqrt(n)
    • Direct nested single-line implementation:
    • sd(circumference) / sqrt(length(circumference))

Quantiles, Percentiles, and Quartiles

  • Theoretical Concepts and Terminology:

    • Quantiles are statistical cut points that partition ordered numerical data into defined intervals.
    • A pp-quantile divides a distribution such that a proportion pp of the observations is smaller than or equal to that cut point, while the remaining proportion 1−p1 - p is larger.
    • Quantiles express cut points on a continuous scale between 00 and 11, whereas percentiles express identical positions on a percentage scale between 0%0\% and 100%100\%.
    • Mathematical equivalence: A pp-quantile corresponds directly to the (100×p) %(100 \times p)\,\% percentile. For example, the 0.250.25 quantile is the 25%25\% percentile.
  • Key Benchmark Percentiles:

    • 0%0\% Percentile (0.00.0 Quantile): Corresponds to the minimum value; no observations are smaller.
    • 25%25\% Percentile (0.250.25 Quantile): Designated as the lower quartile (Q1Q_1); exactly 25%25\% of all data points are smaller, and 75%75\% are larger.
    • 50%50\% Percentile (0.500.50 Quantile): Designated as the median (Q2Q_2); exactly 50%50\% of all values are smaller, and 50%50\% are larger.
    • 75%75\% Percentile (0.750.75 Quantile): Designated as the upper quartile (Q3Q_3); exactly 75%75\% of all values are smaller, and 25%25\% are larger.
    • 100%100\% Percentile (1.01.0 Quantile): Corresponds to the maximum value; no observations are larger.
    • Quartiles: Divide the total ordered observations into four equal segments: 0–25%0\text{--}25\%, 25–50%25\text{--}50\%, 50–75%50\text{--}75\%, and 75–100%75\text{--}100\%.
  • Biological Utility:

    • Identifying morphological extremes: Determining the threshold below which the smallest 10%10\% of ash trees fall, with 90%90\% exceeding it.
    • Trimming extreme values: Identifying and trimming the lower 5%5\% and upper 5%5\% tails of trunk circumference distributions prior to downstream parametric tests.
  • Execution and Interpretation in R:

    • Quantiles are calculated using the quantile() function, which requires two primary parameters: the numerical data vector and the target probability quantile (probs) specified as a decimal between 00 and 11.
    • Example command: quantile(ash_circumference, probs = 0.1)
    • Output interpretation: If the console returns 10% 29, it denotes that 10%10\% of the surveyed ash trees have a trunk circumference of less than 29 cm29\,\text{cm}, and 90%90\% have a circumference exceeding 29 cm29\,\text{cm}. The reported unit of measurement (cm\text{cm}) is identical to the unit of the input vector.
    • Algorithmic Discrepancy Note: The numerical value produced by quantile(data, probs = 0.5) can deviate slightly from the value produced by median(data) due to distinct interpolation algorithms used by R for quantile estimation.

Theoretical Distributions: Probability Density and Cumulative Functions

  • Frequency Distributions vs. Probability Distributions:

    • Frequency Distribution: Pertains strictly to an empirical sample; documents the observed count or relative frequency of individual values or binned classes within a collected dataset.
    • Probability Distribution: Pertains to the underlying theoretical population; mathematically defines how probabilities are distributed across all possible outcomes of a random variable.
  • Probability Density Function (PDF) of Continuous Variables:

    • The probability density function serves as a mathematical tool for continuous variables.
    • In a continuous distribution, an infinite number of values can occur, which means the exact probability of observing any single specific real number is zero:     P(X=c)=0P(X = c) = 0
    • For instance, the probability that an ash tree possesses a trunk circumference of exactly 30.0000… cm30.0000\dots\,\text{cm} is zero; it invariably measures slightly above or below (e.g., 30.05 cm30.05\,\text{cm} or 30.005 cm30.005\,\text{cm}).
    • Relative density heights indicate which outcomes are more probable relative to others, but absolute probabilities can only be obtained by integrating the area under the curve across an interval.
  • Cumulative Distribution Function (CDF):

    • The cumulative probability represents the integral of the probability density function from negative infinity up to a designated threshold xx:     F(x)=P(X≤x)=∫−∞xf(t) dtF(x) = P(X \le x) = \int_{-\infty}^x f(t)\,dt
    • As xx approaches positive infinity (x→∞x \rightarrow \infty), the cumulative probability approaches 11. The total integrated area under any continuous density curve is always 11.
    • Interval Probability Computation: The probability that a random variable falls within an interval between lower bound aa and upper bound bb (a<ba < b) is obtained by subtracting the cumulative probability at aa from that at bb:     P(a≤X≤b)=F(b)−F(a)=∫abf(x) dxP(a \le X \le b) = F(b) - F(a) = \int_a^b f(x)\,dx
  • Cheetah Sprint Speed Case Study:

    • Consider the maximum hunting sprint speeds of cheetahs modeled along a continuous velocity distribution.
    • The probability that a sampled cheetah exhibits a top speed of 70 km/h70\,\text{km/h} or slower corresponds to the cumulative integral up to 70 km/h70\,\text{km/h}, which equals 0.160.16 (16%16\%):     P(X≤70 km/h)=0.16P(X \le 70\,\text{km/h}) = 0.16
    • To calculate the probability that a cheetah runs between 70 km/h70\,\text{km/h} and 80 km/h80\,\text{km/h}, subtract the cumulative probability at 70 km/h70\,\text{km/h} from that at 80 km/h80\,\text{km/h}:     P(70 km/h≤X≤80 km/h)=F(80)−F(70)=0.50−0.16=0.34P(70\,\text{km/h} \le X \le 80\,\text{km/h}) = F(80) - F(70) = 0.50 - 0.16 = 0.34     This results in an interval probability of 34%34\% (0.340.34).
    • For a narrow velocity increment between 60 km/h60\,\text{km/h} and 61 km/h61\,\text{km/h}, the corresponding integrated area under the curve is 0.0060.006 (0.6%0.6\%).
    • Virtually all individual cheetahs (P≈1P \approx 1) exhibit peak sprint speeds bounded between 40 km/h40\,\text{km/h} and 120 km/h120\,\text{km/h}.
  • Discrete Cumulative Calculations:

    • For discrete variables restricted to integers, cumulative probability intervals require discrete summation cutoffs.
    • To determine the probability of observing between 44 and 66 flower heads inclusive (X∈{4,5,6}X \in \{4, 5, 6\}) on a plant, evaluate the cumulative difference:     P(4≤X≤6)=P(X≤6)−P(X≤3)P(4 \le X \le 6) = P(X \le 6) - P(X \le 3)

Parametric Probability Distributions

  • Normal (Gaussian) Distribution:

    • Properties: A continuous, symmetric, unimodal distribution forming the classical Gaussian bell curve. As empirical sample sizes increase (e.g., repeatedly sampling cheetah speeds), sample frequency histograms converge toward the continuous normal distribution.
    • Parameters: Described by two parameters: the population mean μ\mu (expected value locating the central peak) and the population standard deviation σ\sigma (governing curve width and dispersion):     f(x)=1σ2πe−12(x−μσ)2f(x) = \frac{1}{\sigma \sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x - \mu}{\sigma}\right)^2}
    • Increasing μ\mu translates the curve horizontally along the x-axis. Increasing σ\sigma flattens and broadens the curve while maintaining a total integrated area of 11.
    • Empirical Rule (68−9568-95 Rule):
    • Approximately 68%68\% of all data values lie within one standard deviation of the mean:       P(μ−1σ≤X≤μ+1σ)≈0.68P(\mu - 1\sigma \le X \le \mu + 1\sigma) \approx 0.68
    • Approximately 95%95\% of all data values lie within two standard deviations of the mean:       P(μ−2σ≤X≤μ+2σ)≈0.95P(\mu - 2\sigma \le X \le \mu + 2\sigma) \approx 0.95
    • Distinction between σ\sigma and SEM\text{SEM}: The interval μ±1σ\mu \pm 1\sigma defines the dispersion where approximately 68%68\% of individual biological measurements reside. By contrast, xˉ±1 SEM\bar{x} \pm 1\,\text{SEM} defines the precision interval within which the true population mean μ\mu is expected to reside with 68%68\% probability.
  • Discrete Uniform Distribution:

    • Characterized by a finite set of discrete outcomes, each possessing equal probability.
    • Classical die example: Rolling a standard six-sided die yields outcomes in the set 1,2,3,4,5,6{1, 2, 3, 4, 5, 6}, with each outcome occurring with probability P=16P = \frac{1}{6}. All other outcomes have probability 00.
  • Poisson Distribution:

    • Application: Models discrete count data (count data\text{count data}) starting from zero (0,1,2,…0, 1, 2, \dots) with no negative values possible.
    • Biological Example: The number of flower heads (Blu¨tenko¨pfchen\text{Blütenköpfchen}) counted per individual plant.
    • Single Parameter (λ\lambda): Fully parameterized by a single value, λ\lambda (lambda), which simultaneously represents both the expected mean and the variance of the distribution:     E(X)=λ\text{E}(X) = \lambdaVar(X)=λ\text{Var}(X) = \lambda
    • Coupled Mean and Variance: Because variance equals λ\lambda, distributions with higher mean counts automatically display greater spread.
    • Mathematical Formula:P(X=x)=λxe−λx!P(X = x) = \frac{\lambda^x e^{-\lambda}}{x!}     where x!x! is the factorial of xx (x!=x×(x−1)×(x−2)×⋯×1x! = x \times (x - 1) \times (x - 2) \times \dots \times 1).
    • Asymmetry: For lower values of λ\lambda (such as λ=2.5\lambda = 2.5 flower heads), the distribution is right-skewed. Numerous plants have counts below the mean, while a smaller number have counts above 2.52.5, pulling the mean toward the right tail.
    • Unbounded Capacity: Lacks a predetermined mathematical upper limit; an individual plant can theoretically produce an unconstrained number of flower heads.
  • Binomial Distribution:

    • Application: Models the number of successes kk across a fixed, known total number of independent binary trials nn.
    • Binary Trial Criteria: Each trial yields one of two mutually exclusive outcomes: success with constant probability pp, or failure with counter-probability q=1−pq = 1 - p.
    • Examples:
    • Coin tossing: Heads versus tails.
    • Board games ("Mensch ärgere dich nicht"): Rolling a six (p=16p = \frac{1}{6}) versus not rolling a six (q=56q = \frac{5}{6}).
    • Plant recruitment: Seedling established versus dead/unestablished.
    • Distinction from Poisson Distribution: The total trial count nn is strictly known, creating a fixed upper boundary (0≤k≤n0 \le k \le n). Sowing 100100 seeds means that at most 100100 can germinate, making it a model for proportional or ratio data.
    • Mathematical Properties:
    • Mean (Expected Value):μ=n×p\mu = n \times p
    • Variance:σ2=n×p×(1−p)=n×p×q\sigma^2 = n \times p \times (1 - p) = n \times p \times q
    • Mole Survival Flooding Case Study:
    • Tracking the survival of n=100n = 100 moles following spring flooding, where each mole has an independent survival probability pp.
    • Under low survival probability (p≈0.1p \approx 0.1), very few moles survive, and variance is low.
    • Under intermediate survival probability (p=0.5p = 0.5), an average of 5050 out of 100100 moles survive (μ=100×0.5=50\mu = 100 \times 0.5 = 50), and the variance is maximized because p(1−p)=0.5×0.5=0.25p(1 - p) = 0.5 \times 0.5 = 0.25 is at its peak:       σ2=100×0.5×0.5=25\sigma^2 = 100 \times 0.5 \times 0.5 = 25
    • Under certain survival (p=1.0p = 1.0), all 100100 moles survive (μ=100\mu = 100), and the variance is zero (no dispersion):       σ2=100×1.0×0.0=0\sigma^2 = 100 \times 1.0 \times 0.0 = 0

Shape Characteristics of Distributions: Skewness and Kurtosis

  • Symmetry and Modality:

    • Symmetric Distributions: The left and right halves around the central peak are mirror images (e.g., normal distribution). The arithmetic mean, median, and mode coincide at the exact same coordinate:     Mean=Median=Mode\text{Mean} = \text{Median} = \text{Mode}
    • Mode (Modalwert): The specific value of xx corresponding to the absolute maximum peak of the distribution (the outcome with the highest observed frequency or density).
  • Skewness (Asymmetry):

    • Right-Skewed (Positively Skewed) Distributions: The distribution possesses an elongated tail stretching toward larger positive values on the right. The mode remains at the main peak, the median is shifted slightly rightward, and the arithmetic mean is pulled furthest to the right by extreme values:     Mode<Median<Mean\text{Mode} < \text{Median} < \text{Mean}     This pattern is common in biological count data (e.g., Poisson-distributed flower head counts).
    • Left-Skewed (Negatively Skewed) Distributions: The elongated tail extends toward lower values on the left. The arithmetic mean is pulled furthest to the left:     Mean<Median<Mode\text{Mean} < \text{Median} < \text{Mode}     Left-skewed distributions occur infrequently in empirical biological systems.
  • Kurtosis (Wölbung):

    • Quantifies the degree to which data are concentrated around the central mean versus dispersed into the tails.
    • Leptokurtic (Steep-Peaked / Steilgipflig): Distributions exhibit a narrow, elevated central peak and heavier tails, indicating strong concentration around the mean.
    • Platykurtic (Flat-Peaked / Flachgipflig): Distributions exhibit a broad, flattened central peak and thinner tails, indicating wide dispersion across values.

Boxplots and Data Subsetting in R

  • Comparison between Boxplots and Histograms:

    • Histograms display detailed class frequencies across a single variable but require substantial horizontal plotting space, making visual multi-group comparisons difficult.
    • Boxplots provide a condensed five-number visual summary that aggregates data distribution, functioning like a sideways-tilted histogram rotated 9090 degrees counterclockwise.
  • Structural Components of a Boxplot:

    • Center Bar: A prominent horizontal bar representing the sample median (Q2Q_2). It represents the median, not the arithmetic mean.
    • Box Edges (Hinges): The lower and upper edges of the central box represent the lower quartile (Q1Q_1, 25%25\% percentile) and upper quartile (Q3Q_3, 75%75\% percentile), respectively.
    • Interquartile Range (IQR): The distance spanned by the box (Q3−Q1Q_3 - Q_1), containing the central 50%50\% of all observed data points.
    • Whiskers: Lines extending from the box edges to the most extreme empirical data point that lies within 1.51.5 times the box width (1.5×IQR1.5 \times \text{IQR}) from the quartile hinges.
    • Outliers: Any individual observation located beyond 1.5×IQR1.5 \times \text{IQR} from the quartile hinges is plotted as an individual point.
  • Multi-Group Comparative Plotting in R:

    • Multi-group boxplots allow comparative evaluation of medians, interquartile ranges, and tail skews across different biological categories.
    • Formula Syntax: Group-dependent plotting uses the tilde operator ~ to indicate that a continuous response variable depends on a categorical predictor:
    • boxplot(Höhe ~ Art, data = Bäume, xlab = "Species", ylab = "Height (m)", main = "Tree Heights by Species")
    • The tilde denotes that tree height (Höhe) is modeled as a function of species (Art), drawing from the dataframe Bäume.
    • By default, categorical factor levels are arranged alphabetically on the x-axis (e.g., Birch / Birken, Beech / Buchen, Oak / Eichen).
    • Biological interpretation: Visual comparison reveals that beech trees achieve the greatest median height, followed by oaks, with birches exhibiting the lowest median height.
  • Data Subsetting via subset() in R:

    • The subset() function extracts rows from a dataframe that satisfy specific logical criteria.
    • Extraction by Equality (==): To extract only oak trees from the Bäume dataset:
    • Eichen_Daten <- subset(Bäume, Art == "Eiche")
    • The double equals operator == evaluates logical equality, selecting rows where the entry in column Art matches "Eiche".
    • Extraction by Inequality (!=): To extract all species other than oaks (e.g., retaining both beeches and birches):
    • Nicht_Eichen <- subset(Bäume, Art != "Eiche")
    • The operator != evaluates logical inequality.
    • Subsetted dataframes retain original column identifiers, permitting subsequent descriptive calculations (e.g., mean(Eichen_Daten$Höhe)).