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 (): Represents the mathematical average of all observed values. It is calculated by summing all individual data points and dividing by the total sample size . 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 () of the observations are smaller than or equal to the median, and the other half () are greater than or equal to it. The median is robust against extreme outliers and skewed distributions.
Residuals and Degrees of Freedom:
- Residual (): The individual deviation or distance of an observed data point from the sample mean :
- 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 (): When calculating sample variance, the sum of squared residuals is divided by rather than . One degree of freedom is lost because the sample mean is already fixed as an intermediate parameter estimate from the sample data.
Sample Variance and Standard Deviation:
- Sample Variance (): 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:
- Squaring prevents positive and negative residuals from canceling each other out to zero and places greater weight on larger deviations.
- Sample Standard Deviation (): The positive square root of the sample variance:
- 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 is an empirical estimate of the unknown true population mean .
- The Standard Error of the Mean (), also termed standard error, measures the statistical precision and accuracy of the sample mean as an estimator of the population parameter.
- Unlike variance () or standard deviation (), which describe the biological dispersion or spread of individual data points within a sample, is purely an error metric of estimation precision.
Mathematical Formulation:
- The standard error is calculated by dividing the sample standard deviation by the square root of the total sample size :
Confidence Probability for Normal Distributions:
- When sample data originate from a normally distributed population, the true population mean lies within the interval of plus or minus one standard error around the sample mean with an exact probability of approximately :
Mathematical Dynamics and Influencing Factors:
- Effect of Data Spread (): As individual data points cluster closer to the mean (smaller standard deviation ), the numerator decreases, resulting in a smaller and a more precise estimation.
- Effect of Sample Size (): As the sample size increases, the denominator grows, reducing and narrowing the error band.
Concrete Numerical Examples:
- Baseline Scenario: Sample size , standard deviation :
- Reduced Dispersion Scenario: Sample size , standard deviation reduced to : Halving the standard deviation halves the standard error from to .
- Reduced Sample Size Scenario: Sample size reduced to , standard deviation maintained at : Reducing the number of observations by a factor of four doubles the estimation error from to .
Comparative Applications in Biology (Tree Height Comparison):
- Consider a comparative study measuring tree heights in meters () across oak, beech, and giant sequoia (mammoth tree) populations.
- If the confidence intervals defined by 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 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 .
- Calculation requires composing base functions:
sd()calculates sample standard deviation ,length()determines sample size , andsqrt()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 -quantile divides a distribution such that a proportion of the observations is smaller than or equal to that cut point, while the remaining proportion is larger.
- Quantiles express cut points on a continuous scale between and , whereas percentiles express identical positions on a percentage scale between and .
- Mathematical equivalence: A -quantile corresponds directly to the percentile. For example, the quantile is the percentile.
Key Benchmark Percentiles:
- Percentile ( Quantile): Corresponds to the minimum value; no observations are smaller.
- Percentile ( Quantile): Designated as the lower quartile (); exactly of all data points are smaller, and are larger.
- Percentile ( Quantile): Designated as the median (); exactly of all values are smaller, and are larger.
- Percentile ( Quantile): Designated as the upper quartile (); exactly of all values are smaller, and are larger.
- Percentile ( Quantile): Corresponds to the maximum value; no observations are larger.
- Quartiles: Divide the total ordered observations into four equal segments: , , , and .
Biological Utility:
- Identifying morphological extremes: Determining the threshold below which the smallest of ash trees fall, with exceeding it.
- Trimming extreme values: Identifying and trimming the lower and upper 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 and . - Example command:
quantile(ash_circumference, probs = 0.1) - Output interpretation: If the console returns
10% 29, it denotes that of the surveyed ash trees have a trunk circumference of less than , and have a circumference exceeding . The reported unit of measurement () 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 bymedian(data)due to distinct interpolation algorithms used by R for quantile estimation.
- Quantiles are calculated using the
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:
- For instance, the probability that an ash tree possesses a trunk circumference of exactly is zero; it invariably measures slightly above or below (e.g., or ).
- 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 :
- As approaches positive infinity (), the cumulative probability approaches . The total integrated area under any continuous density curve is always .
- Interval Probability Computation: The probability that a random variable falls within an interval between lower bound and upper bound () is obtained by subtracting the cumulative probability at from that at :
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 or slower corresponds to the cumulative integral up to , which equals ():
- To calculate the probability that a cheetah runs between and , subtract the cumulative probability at from that at : This results in an interval probability of ().
- For a narrow velocity increment between and , the corresponding integrated area under the curve is ().
- Virtually all individual cheetahs () exhibit peak sprint speeds bounded between and .
Discrete Cumulative Calculations:
- For discrete variables restricted to integers, cumulative probability intervals require discrete summation cutoffs.
- To determine the probability of observing between and flower heads inclusive () on a plant, evaluate the cumulative difference:
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 (expected value locating the central peak) and the population standard deviation (governing curve width and dispersion):
- Increasing translates the curve horizontally along the x-axis. Increasing flattens and broadens the curve while maintaining a total integrated area of .
- Empirical Rule ( Rule):
- Approximately of all data values lie within one standard deviation of the mean:
- Approximately of all data values lie within two standard deviations of the mean:
- Distinction between and : The interval defines the dispersion where approximately of individual biological measurements reside. By contrast, defines the precision interval within which the true population mean is expected to reside with 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 , with each outcome occurring with probability . All other outcomes have probability .
Poisson Distribution:
- Application: Models discrete count data () starting from zero () with no negative values possible.
- Biological Example: The number of flower heads () counted per individual plant.
- Single Parameter (): Fully parameterized by a single value, (lambda), which simultaneously represents both the expected mean and the variance of the distribution:
- Coupled Mean and Variance: Because variance equals , distributions with higher mean counts automatically display greater spread.
- Mathematical Formula: where is the factorial of ().
- Asymmetry: For lower values of (such as flower heads), the distribution is right-skewed. Numerous plants have counts below the mean, while a smaller number have counts above , 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 across a fixed, known total number of independent binary trials .
- Binary Trial Criteria: Each trial yields one of two mutually exclusive outcomes: success with constant probability , or failure with counter-probability .
- Examples:
- Coin tossing: Heads versus tails.
- Board games ("Mensch ärgere dich nicht"): Rolling a six () versus not rolling a six ().
- Plant recruitment: Seedling established versus dead/unestablished.
- Distinction from Poisson Distribution: The total trial count is strictly known, creating a fixed upper boundary (). Sowing seeds means that at most can germinate, making it a model for proportional or ratio data.
- Mathematical Properties:
- Mean (Expected Value):
- Variance:
- Mole Survival Flooding Case Study:
- Tracking the survival of moles following spring flooding, where each mole has an independent survival probability .
- Under low survival probability (), very few moles survive, and variance is low.
- Under intermediate survival probability (), an average of out of moles survive (), and the variance is maximized because is at its peak:
- Under certain survival (), all moles survive (), and the variance is zero (no dispersion):
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:
- Mode (Modalwert): The specific value of 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: 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: 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 degrees counterclockwise.
Structural Components of a Boxplot:
- Center Bar: A prominent horizontal bar representing the sample median (). It represents the median, not the arithmetic mean.
- Box Edges (Hinges): The lower and upper edges of the central box represent the lower quartile (, percentile) and upper quartile (, percentile), respectively.
- Interquartile Range (IQR): The distance spanned by the box (), containing the central of all observed data points.
- Whiskers: Lines extending from the box edges to the most extreme empirical data point that lies within times the box width () from the quartile hinges.
- Outliers: Any individual observation located beyond 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 dataframeBä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 theBäumedataset: Eichen_Daten <- subset(Bäume, Art == "Eiche")- The double equals operator
==evaluates logical equality, selecting rows where the entry in columnArtmatches"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)).
- The