ModernDive

Glossary

A reference of statistics and data-science terms used throughout the book. Terms are listed alphabetically. Where a topic is treated in more depth in a chapter, a link is provided.


Aesthetic mapping

The link between a variable in your data and a visual property of a plot — for example, mapping the wind_speed variable to the x-axis position. Specified inside the aes() function in ggplot2. Distinct from a setting, where a visual property is fixed without reference to data (e.g., geom_point(alpha = 0.2)). See The grammar of graphics.

Alternative hypothesis

Written \(H_a\) or \(H_1\). The claim a hypothesis test is gathering evidence for — typically that an effect, difference, or relationship exists. Always paired with a null hypothesis (\(H_0\)). Can be two-sided (\(H_a: \theta \neq \theta_0\)) or one-sided (\(H_a: \theta > \theta_0\) or \(H_a: \theta < \theta_0\)); the direction must be chosen before looking at the data. See 9  Hypothesis Testing.

Barplot

A plot for visualizing the distribution of a categorical variable using rectangular bars whose heights represent counts (geom_bar()) or pre-computed values (geom_col()). For two categorical variables, bars can be stacked, side-by-side (position = "dodge"), or faceted. See 5NG#5: Barplots.

Bootstrap distribution

The distribution of a statistic computed from many bootstrap samples (resamples with replacement) of a single observed sample. The act of constructing this distribution is called bootstrapping. Used to construct confidence intervals and standard errors without theoretical formulas. See 8  Estimation, Confidence Intervals, and Bootstrapping.

Bootstrap sample

A single resample drawn with replacement from an observed sample, of the same size as the original. Repeating this many times produces a bootstrap distribution that approximates the sampling distribution. See Bootstrap samples: revisiting the almond activity.

Boxplot

A plot summarizing a numerical variable’s distribution using its five-number summary: minimum, first quartile, median, third quartile, and maximum. Points beyond the whiskers (typically \(1.5 \times IQR\) from the box edges) are flagged as potential outliers. Side-by-side boxplots compare distributions across categories. See 5NG#4: Boxplots.

Categorical variable

A variable whose values fall into discrete groups or categories — e.g., carrier, origin, condition. Contrast with a quantitative variable. See 1  Getting Started with Data in R.

Central Limit Theorem (CLT)

The fundamental theorem that, as the sample size \(n\) grows, the sampling distribution of the sample mean becomes approximately normal — regardless of the shape of the underlying population. It is the theoretical justification for using normal-based inference even when the population isn’t normal. See The Central Limit Theorem.

Confidence interval

A range of plausible values for an unknown population parameter, constructed from sample data. A 95% confidence interval is built so that, in the long run, 95% of intervals constructed this way would contain the true parameter. Contrast with a point estimate (a single number). See 8  Estimation, Confidence Intervals, and Bootstrapping.

Confounding variable

A variable that influences both the explanatory variable and the response variable, creating an apparent association that may not reflect a direct causal relationship. The risk of confounding is the main reason “correlation does not imply causation” — especially with observational data. See Correlation is not necessarily causation.

Correlation coefficient

A unitless number \(r\) between \(-1\) and \(+1\) that quantifies the strength and direction of a linear relationship between two numerical variables. Values near \(\pm 1\) indicate a strong linear relationship; values near \(0\) indicate a weak or no linear relationship (note: a strong non-linear relationship can still produce \(r \approx 0\)). Computed in R with cor() or moderndive::get_correlation(). See Exploratory data analysis.

Data frame

The standard rectangular data structure in R: rows are observations, columns are variables. ModernDive uses the tibble flavor of data frames provided by the tidyverse.

Distribution

The pattern of values a variable takes and how often each value (or range of values) occurs. Shape descriptors include symmetric, right-skewed, left-skewed, bimodal, and uniform. Visualized with a histogram for numerical variables or a barplot for categorical variables. Distinguish three closely-related distributions in inference: the data distribution (one sample), the population distribution (all units), and the sampling distribution (a statistic across many samples). See 5NG#3: Histograms.

dplyr verb

One of the data-transformation functions in the dplyr package: filter(), select(), mutate(), arrange(), summarize(), group_by(), and the *_join() family. Each verb takes a data frame and returns a transformed data frame. See 3  Data Wrangling.

Estimator

A procedure (formula or method) for producing an estimate of a population parameter from sample data. The estimator is a random quantity that varies from sample to sample; an estimate is the specific numerical value the estimator produces on one observed sample. An estimator is unbiased if its expected value equals the true parameter, and biased otherwise. The sample mean \(\bar{x}\) is an unbiased estimator of the population mean \(\mu\). See 8  Estimation, Confidence Intervals, and Bootstrapping.

Expected value

The long-run average of a random variable, written \(E(X)\) or \(\mu_X\). For the sample mean drawn from a population with mean \(\mu\), \(E(\bar{X}) = \mu\) — i.e., the sample mean is centered on the true population mean. The expected value formalizes “where the center of the sampling distribution sits.” See The Central Limit Theorem.

Exploratory data analysis (EDA)

The preliminary, pre-modeling inspection of a dataset to understand variable types, distributions, missing values, outliers, and pairwise relationships. Three common steps: (1) looking at the raw data values, (2) computing summary statistics, (3) creating data visualizations. EDA is the prerequisite for every chapter from Ch 5 onward. See Exploratory data analysis.

Faceting

Splitting a single plot into a grid of small, side-by-side panels — one per level of a categorical variable. Implemented in ggplot2 with facet_wrap() (one variable) or facet_grid() (two variables). Useful for comparing the same kind of plot across subgroups. See Facets.

Fitted value

The value of the response variable predicted by a regression model at a given combination of explanatory-variable values, written \(\widehat{y}\). For simple linear regression, \(\widehat{y} = b_0 + b_1 \cdot x\). The vertical distance from an observed \(y\) to its fitted \(\widehat{y}\) is the residual. See Observed/fitted values and residuals.

Geometric object (geom)

The visual mark used to represent data in a ggplot2 plot — geom_point() for points, geom_line() for lines, geom_bar() for bars, etc. The third component of the grammar of graphics. See The grammar of graphics.

Grammar of graphics

A theoretical framework that builds plots from layered components: data, aesthetic mappings, geometric objects, and (optionally) facets, scales, and coordinate systems. Implemented in R by the ggplot2 package. See The grammar of graphics.

Histogram

A plot showing the distribution of a single numerical variable by cutting its range into bins of equal width and drawing a bar whose height is the count of observations in that bin. Bin width matters: too narrow and the plot is noisy; too wide and meaningful shape disappears. See 5NG#3: Histograms.

Hypothesis test

A formal procedure for using sample data to evaluate competing claims (the null hypothesis vs. an alternative hypothesis) about a population. Typically yields a p-value used to decide whether to reject \(H_0\). See 9  Hypothesis Testing.

Interaction effect

A modeling situation in which the effect of one explanatory variable on the response depends on the value of another — i.e., the slopes differ across groups rather than being parallel. Specified in lm() with the * operator (e.g., y ~ x1 * x2). Contrast with a parallel-slopes model, which assumes the same slope across groups. See Model with interactions.

Least squares

The estimation method that finds regression coefficients by minimizing the sum of squared residuals — i.e., the line (or hyperplane, in multiple regression) that makes the squared vertical distances to the data as small as possible. The resulting coefficients are called least-squares estimators. See 5  Simple Linear Regression.

LINE conditions

The four assumptions for inference on a regression model: Linearity of the relationship, Independence of observations, Normality of residuals, and Equality (homoscedasticity) of residual variance — sometimes referred to as equal variance or homoscedasticity. Diagnostic plots are used to assess each. See 10  Inference for Regression.

Linear regression

A model expressing a numerical outcome variable as a linear combination of one or more predictor variables, fit by minimizing the sum of squared residuals. Simple linear regression has one predictor; multiple linear regression has more than one. Implemented in R by lm(). See 5  Simple Linear Regression.

Log transformation

Replacing a numerical variable \(x\) with \(\log(x)\) (commonly \(\log_{10}\)) — useful when the variable is heavily right-skewed (e.g., income, house prices, population) because log compresses the right tail and turns multiplicative relationships into additive ones. Often improves linear-regression assumptions when the original variable spans several orders of magnitude. See 11  Tell Your Story with Data.

Margin of error

Half the width of a (symmetric) confidence interval; equivalently, the maximum distance between the point estimate and either endpoint of the interval. Common in poll reporting (“\(52\% \pm 3\%\)”). See 8  Estimation, Confidence Intervals, and Bootstrapping.

Multiple regression

A linear regression model with two or more explanatory variables. Each coefficient is a partial slope — the effect of its variable holding the other predictors constant. The natural extension of simple linear regression for situations where multiple factors plausibly influence the response. See 6  Multiple Regression.

Normal distribution

A symmetric, bell-shaped probability distribution fully described by two parameters: mean \(\mu\) and standard deviation \(\sigma\). About 68% of values lie within \(\pm 1\sigma\), about 95% within \(\pm 2\sigma\). The Central Limit Theorem says the sampling distribution of \(\bar{X}\) is approximately normal for large \(n\), which makes the normal distribution the workhorse of theory-based inference. The standard normal has \(\mu = 0\), \(\sigma = 1\). See 8  Estimation, Confidence Intervals, and Bootstrapping.

Null distribution

The sampling distribution of a test statistic under the assumption that the null hypothesis is true. Permutation tests construct it empirically by repeatedly shuffling the data. See 9  Hypothesis Testing.

Null hypothesis

Written \(H_0\). The claim of “no effect, no difference, no relationship” that a hypothesis test attempts to reject. The starting assumption against which evidence is weighed. See 9  Hypothesis Testing.

Outlier

An observation whose value is unusually extreme relative to the rest of the data. In a boxplot, points beyond the whiskers (\(1.5 \times IQR\) from the quartiles) are flagged as potential outliers. Outliers can pull the mean (and least-squares regression line) toward themselves; the median and the IQR are robust to outliers. See 5NG#4: Boxplots.

Partial slope

In a multiple regression, the coefficient on a single predictor — interpreted as “the expected change in the response for a one-unit increase in this predictor, holding all other predictors constant.” Partial slopes are typically smaller in magnitude than the corresponding marginal slopes from one-predictor models when predictors are correlated. See 6  Multiple Regression.

Permutation test

A simulation-based hypothesis test that constructs the null distribution by repeatedly shuffling labels in the data, breaking any real association. See 9  Hypothesis Testing.

Pipe operator (|>)

The base-R forward pipe: x |> f() is equivalent to f(x). Used to chain a sequence of transformations into a readable left-to-right pipeline. See The pipe operator: |>.

Point estimate

A single-number guess at an unknown population parameter, computed from sample data — e.g., the sample mean \(\bar{x}\) as an estimate of the population mean \(\mu\). Contrast with an interval estimate (confidence interval). See 8  Estimation, Confidence Intervals, and Bootstrapping.

Population parameter

A numerical summary of an entire population (e.g., the true mean weight \(\mu\) of all almonds in a bowl). Usually unknown; the goal of inference is to estimate it from sample data. Contrast with a sample statistic. See 7  Sampling.

p-value

The probability — assuming the null hypothesis is true — of observing a test statistic at least as extreme as the one obtained from the sample. Small p-values are evidence against \(H_0\). Not the probability that \(H_0\) is true. See 9  Hypothesis Testing.

Quantitative variable

A variable whose values are numerical and meaningful to do arithmetic with — e.g., wind_speed, dep_delay, price. Contrast with a categorical variable. See 1  Getting Started with Data in R.

Random sample

A sample obtained by simple random sampling: every member of the population has the same chance of being selected, and members are selected independently. Random samples are what make sampling distributions and the standard inferential formulas valid. See Sampling framework.

Random variable

A variable whose value is determined by the outcome of a random process. The sample mean \(\bar{X}\) is a random variable — different samples produce different values; the sampling distribution describes how those values are distributed. See Random variables.

Reference level

In a regression with a categorical predictor, the “baseline” category whose mean is absorbed into the intercept. Coefficients for the other categories represent differences from this reference level. By default, R uses the alphabetically first level; change it with factor(x, levels = ...) or forcats::fct_relevel(). See Model with interactions.

Regression coefficient

A number estimated by a regression model that tells you how the response variable relates to a predictor. The intercept \(b_0\) is the predicted response when all predictors equal zero; the slope \(b_1\) is the predicted change in the response for a one-unit increase in the predictor. In R, read coefficients with get_regression_table() or coef(). See Simple linear regression.

Residual

The vertical distance between an observed data point and the value predicted by a regression model: \(e_i = y_i - \hat{y}_i\). Residuals being small (in aggregate) means the model fits well. See 5  Simple Linear Regression.

Sample mean

The arithmetic mean of the values in a sample, written \(\bar{x}\) for one observed sample and \(\bar{X}\) for the random variable. The sample mean is the point estimate for the population mean \(\mu\) and is an unbiased estimator: \(E(\bar{X}) = \mu\). See Second activity: chocolate-covered almonds.

Sample proportion

The proportion of “successes” in a sample, written \(\widehat{p}\). The sample proportion is the point estimate for the population proportion \(p\) and is an unbiased estimator: \(E(\widehat{P}) = p\). See First activity: red balls.

Sample statistic

A numerical summary computed from a sample, used to estimate a population parameter (e.g., \(\bar{x}\) estimating \(\mu\), \(\hat{p}\) estimating \(p\)). Sample statistics vary from sample to sample — that variability is what sampling distributions describe. See 7  Sampling.

Sampling distribution

The distribution of a sample statistic across all possible samples of a given size from the same population. The key concept underlying all of statistical inference: it tells you how much your point estimate would vary if you took a different sample. See 7  Sampling.

Sampling variation

The natural fluctuation of a sample statistic from one random sample to another. Sampling variation shrinks as \(n\) grows — that’s why bigger samples produce narrower confidence intervals and more precise estimates. Its size is summarized by the standard error. See Sampling variation: standard deviation and standard error.

Scatterplot

A plot of two numerical variables that uses a point for each observation at coordinates \((x, y)\). The starting visualization for examining the relationship between two numerical variables — including checking whether a linear regression is appropriate. Add a fitted line with geom_smooth(method = "lm"). See 5NG#1: Scatterplots.

Significance level (\(\alpha\))

The pre-chosen threshold for rejecting the null hypothesis in a hypothesis test — typically \(\alpha = 0.05\). By construction, \(\alpha\) equals the probability of a Type I error (rejecting \(H_0\) when it’s actually true). Common alternatives include \(\alpha = 0.01\) (stricter) and \(\alpha = 0.10\) (more permissive); the choice should be made before seeing the data. See How do we choose alpha?.

Simple random sampling

A sampling method in which every member of the population has an equal chance of being selected, and selections are independent. The textbook ideal for collecting data — many inferential formulas assume the sample was collected this way. See Sampling framework.

Skewness

The asymmetry of a distribution. A distribution is right-skewed (positive skew) if its right tail is long (mean > median); left-skewed (negative skew) if its left tail is long (mean < median); and symmetric if neither. Income, house prices, and most counts tend to be right-skewed. A log transformation often reduces right skew. See 5NG#3: Histograms.

Standard error

The standard deviation of a sampling distribution; quantifies how much a sample statistic typically varies from sample to sample. Smaller standard error = more precise estimates. See 7  Sampling.

Statistical model

A mathematical description of how a response variable depends on one or more explanatory variables, plus a description of the random variation around that dependence. Most models in this book are linear regression models; the modeling framework spans Chapters 5, 6, 10, and 11. See 5  Simple Linear Regression.

Statistically significant

A test result is statistically significant when its \(p\)-value is at or below the chosen significance level \(\alpha\) — i.e., the data are inconsistent enough with \(H_0\) that we reject the null. Note: statistical significance is not the same as practical significance — a tiny effect can be statistically significant if \(n\) is large enough. See 9  Hypothesis Testing.

Summary statistic

A single number that summarizes many values — e.g., the mean, median, standard deviation, minimum, maximum, or a quantile. Computed in R with summarize() plus summary functions like mean(), sd(), n(). See summarize variables.

t-distribution

A family of symmetric, bell-shaped distributions parameterized by degrees of freedom. With small samples, the \(t\)-distribution has heavier tails than the standard normal; as the sample size grows, \(t\) converges to the standard normal. Used in theory-based inference (confidence intervals and tests) when the population standard deviation is unknown — i.e., almost always. See The t distribution.

Test statistic

A numerical summary of the sample (e.g., \(\bar{x}\), \(\widehat{p}_1 - \widehat{p}_2\), the regression slope \(b_1\), or a standardized \(t\)- or \(z\)-score) used to evaluate a hypothesis test. Its observed value is compared to the null distribution to compute a \(p\)-value. See 9  Hypothesis Testing.

Tidy data

A standard data layout: each variable is a column, each observation is a row, each type of observational unit is its own table. Tidy data is the input format expected by the tidyverse packages. Data not in this form is often called wide (variables spread across columns) or long (one column for variable names and one for values); pivot_longer() and pivot_wider() convert between them. See Tidy data.

Tidyverse

A collection of R packages designed with a shared philosophy and consistent interface for data science: ggplot2, dplyr, tidyr, readr, purrr, tibble, stringr, and forcats. Loaded together via library(tidyverse). See tidyverse package.

Type I error

Rejecting the null hypothesis when it is actually true — a “false positive.” The probability of a Type I error is set by the significance level \(\alpha\) (commonly 0.05). See 9  Hypothesis Testing.

Type II error

Failing to reject the null hypothesis when it is actually false — a “false negative.” The probability is denoted \(\beta\); statistical power is \(1 - \beta\). See 9  Hypothesis Testing.