E-Library Logo
Statistics and Probability for Data Science
Statistics and Probability for Data Science
Statistics and Probability for Data Science illustration

Statistics and Probability for Data Science

Program: Post Graduate Diploma in Data Science
Program Level: Post Graduate
Language: English
Subject Syllabus

Subject Overview

An advanced, application-oriented study of probability, statistical inference and statistical modelling for data science. The subject integrates mathematical foundations, exploratory analysis, experimentation, predictive analytics, uncertainty quantification, statistical computing, responsible AI and evidence-based managerial decision-making.

Learning Goal

Students will be able to formulate statistical questions, select and justify appropriate methods, implement reproducible analyses, quantify uncertainty, evaluate assumptions, distinguish prediction from causation, communicate findings and govern statistical and AI-driven decisions responsibly.

Syllabus

1. Statistical Thinking, Data and Exploratory Analysis

Learning Objective: Understand populations, samples, variables, measurement scales, sampling and non-sampling errors; apply data quality checks, visualization, descriptive statistics, robust summaries and exploratory data analysis.

Category: foundation

2. Foundations of Probability

Learning Objective: Apply probability axioms, set operations, combinatorics, conditional probability, independence, Bayes’ theorem and total probability to uncertain events and data-science problems.

Category: foundation

3. Random Variables and Probability Distributions

Learning Objective: Work with discrete and continuous random variables, expectation, variance, moments, quantiles and major Bernoulli, binomial, Poisson, geometric, uniform, normal, exponential and related distributions.

Category: foundation

4. Joint Distributions and Dependence

Learning Objective: Analyse joint, marginal and conditional distributions; covariance, correlation, transformations, conditional expectation, mixtures and dependence, including the limitations of correlation-based reasoning.

Category: core

5. Sampling Theory and Asymptotic Foundations

Learning Objective: Examine probability and non-probability sampling, sampling distributions, standard errors, bias–variance trade-offs, the law of large numbers, central limit theorem and implications for scalable analytics.

Category: core

6. Statistical Estimation and Uncertainty

Learning Objective: Develop point and interval estimators using method of moments and maximum likelihood; assess consistency, efficiency, sufficiency, likelihood, confidence intervals and practical uncertainty communication.

Category: core

7. Hypothesis Testing and Statistical Decision-Making

Learning Objective: Conduct one- and two-sample tests, interpret p-values and effect sizes, manage Type I and II errors, power, sample size and multiple testing, and connect statistical evidence with managerial decisions.

Category: core

8. Regression and Generalized Linear Models

Learning Objective: Build, diagnose and interpret linear, polynomial and multiple regression models; address interactions, confounding, multicollinearity, heteroscedasticity and regularization; introduce logistic, count and other generalized linear models.

Category: application

9. Experimental Design, A/B Testing and Causal Inference

Learning Objective: Design randomized, factorial and blocking experiments; conduct ANOVA and online A/B tests; estimate treatment effects and critically evaluate confounding, selection bias, quasi-experiments and causal assumptions.

Category: application

10. Nonparametric, Robust and Resampling Methods

Learning Objective: Apply rank-based tests, distribution-free methods, robust estimation, permutation tests, bootstrap confidence intervals and cross-validation when classical assumptions are unsuitable.

Category: application

11. Bayesian Statistics and Probabilistic Modelling

Learning Objective: Construct prior, likelihood and posterior models; use conjugacy, credible intervals, posterior prediction, hierarchical models, Bayesian decision theory and computational methods such as MCMC and variational inference.

Category: advanced

12. Multivariate Statistical Analysis

Learning Objective: Analyse high-dimensional data using covariance structures, principal component analysis, factor analysis, clustering, discriminant analysis and dimensionality reduction while addressing scaling and interpretability.

Category: advanced

13. Time-Series and Forecasting Analytics

Learning Objective: Model trend, seasonality, stationarity and autocorrelation using decomposition, smoothing, ARIMA and forecast evaluation; introduce anomaly detection, intervention analysis and probabilistic forecasting.

Category: application

14. Statistical Learning and Model Evaluation

Learning Objective: Connect statistical inference with machine learning through loss functions, bias–variance trade-offs, feature selection, regularization, calibration, validation, performance metrics, explainability and uncertainty-aware AI evaluation.

Category: contemporary

15. Responsible Statistical Practice, Governance and Emerging Trends

Learning Objective: Implement reproducible statistical workflows using contemporary software; address missing data, privacy, fairness, transparency, data lineage, model risk, drift and regulatory governance; evaluate synthetic data, causal AI, automated experimentation and scalable probabilistic systems for digital transformation.

Category: strategic

Statistics and Probability for Data Science
Post Graduate Diploma in Data Science

Statistics and Probability for Data Science

Chapter 1
Statistical Thinking, Data and Exploratory Analysis

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

1. Statistical Thinking, Data and Exploratory Analysis

Introduction and Context

Statistics for data science begins before a model is fitted. It begins with deciding what is being measured, whose data are being studied, how observations were obtained, and whether the resulting evidence is sufficiently trustworthy for the intended decision. Statistical thinking is therefore more than calculating averages or producing charts. It is a disciplined way of reasoning under variability and uncertainty.

A data scientist may be asked to estimate customer churn, compare medical treatments, detect fraud, or forecast demand. In each case, the observed dataset is only a partial and imperfect representation of a broader phenomenon. Statistical thinking helps the analyst distinguish signal from noise, describe what has been observed, identify possible sources of bias, and avoid conclusions that the data cannot support.

Exploratory data analysis (EDA) occupies a central position in this process. It uses summaries, visualizations, and investigative questions to understand the structure and quality of data before formal statistical modelling. EDA is not a substitute for confirmatory analysis; rather, it reveals patterns, anomalies, assumptions, and questions that should guide subsequent analysis.

Learning Objectives

After studying this chapter, the learner should be able to:

  • distinguish populations, samples, parameters, and statistics;
  • identify variables and classify them by measurement scale and data type;
  • explain sampling methods and recognize sampling and non-sampling errors;
  • perform systematic data-quality checks;
  • select and interpret appropriate descriptive statistics and visualizations;
  • explain the value of robust summaries and exploratory data analysis;
  • evaluate an applied dataset while recognizing ethical, technical, and interpretive limitations.

Statistical Thinking: From Questions to Evidence

Statistical reasoning generally follows a chain: a substantive question is translated into measurable variables; observations are collected; data quality is assessed; patterns are described; and conclusions are communicated with appropriate uncertainty. Errors at an early stage cannot usually be repaired by sophisticated algorithms later. For example, a highly accurate classifier trained on a sample that excludes an important population group may produce systematically unfair decisions.

The analyst must continually ask four questions. What is the target population? What process generated the observations? Which features of the observations are stable and which may be random? What claims are justified by the design and quality of the data? These questions shift attention from computation alone to the data-generating process.

Population, Sample, Parameter and Statistic

A population is the complete set of units or outcomes relevant to a question. It might be all registered voters in a region, all transactions processed by a bank during a year, or all patients eligible for a clinical service. A sample is the subset actually observed. Studying an entire population is sometimes possible, but even a census may contain missing, inaccurate, or inconsistently recorded values.

A numerical characteristic of a population is a parameter, whereas a numerical characteristic calculated from a sample is a statistic. The population mean is commonly denoted by μ and the sample mean by x̄. Parameters are often unknown; statistics are used to estimate them. Sampling variability means that different samples from the same population may yield different statistics.

The distinction between a target population and an accessible population is important. A company may wish to understand all customers but analyse only users of its mobile application. The accessible population is narrower, and conclusions may not generalize unless the difference is understood and addressed.

Units, Observations and Variables

A statistical unit is the entity on which measurements are made: a person, household, product, web session, loan, or time interval. An observation is the collection of recorded values for one unit. A variable is a characteristic that can take different values across units, such as age, region, income, device type, or purchase amount.

Variables may be categorical or quantitative. Categorical variables assign observations to groups. Quantitative variables represent numerical amounts for which arithmetic comparisons are meaningful. A count, such as number of complaints, is discrete; a measurement such as response time is often treated as continuous, even when recorded to a finite precision. A date or text field may be technically encoded as numbers but should not automatically be analysed as a quantitative measurement.

The distinction between explanatory and response variables is contextual rather than intrinsic. In a study of advertising and sales, advertising expenditure may be treated as an explanatory variable and sales as a response. This terminology does not by itself establish causation.

Measurement Scales and Meaningful Operations

Measurement scale determines which comparisons and transformations are defensible.

Nominal measurement assigns labels without inherent order. Examples include blood group, browser type, and department. Frequencies, proportions, and the mode are appropriate summaries; arithmetic means of nominal codes are meaningless.

Ordinal measurement provides an order, but differences between adjacent categories are not necessarily equal. Satisfaction ratings such as poor, fair, good, and excellent are ordinal. Medians, percentiles, and rank-based comparisons are often appropriate, while treating category codes as precise measurements requires justification.

Interval measurement has ordered values with meaningful equal differences but no meaningful absolute zero. Temperature in Celsius is a standard example: 20°C is not twice as warm as 10°C. Addition and subtraction are meaningful, whereas ratio statements require care.

Ratio measurement has equal intervals and a meaningful zero, allowing statements such as “twice as much.” Duration, mass, distance, and revenue are common examples. The scale classification depends on the measurement system and the interpretation intended, not merely on the storage format.

Measurement validity concerns whether a variable adequately represents the concept of interest. Reliability concerns consistency of measurement. A survey may reliably record responses while still failing to measure the intended construct, such as using click frequency as an incomplete proxy for customer satisfaction.

Sampling: How Observations Enter the Dataset

Sampling is the process of selecting units from a population. Probability sampling gives each unit a known, non-zero probability of selection and supports principled generalization. In a simple random sample, units are selected randomly from a sampling frame. A systematic sample selects every kth unit after a random starting point. Stratified sampling divides the population into relevant subgroups and samples within each, often improving representation and precision. Cluster sampling selects groups such as schools or branches and observes units within selected groups; it may reduce cost but can increase sampling variability when cluster members are similar.

Non-probability methods include convenience sampling, purposive sampling, and voluntary-response sampling. They may be useful for exploratory work or hard-to-reach populations, but inclusion probabilities are unknown and selection bias may be substantial. A large convenience sample is not automatically representative.

Sampling error is the random difference between a sample result and the corresponding population value caused by observing only part of the population. It generally decreases as effective sample size increases, although not necessarily at a linear rate. Sampling bias is systematic distortion caused by the selection process, such as excluding people without internet access.

Non-Sampling Errors

Non-sampling errors arise from processes other than random sampling. They include:

  • coverage error, when the sampling frame omits or duplicates population units;
  • nonresponse error, when selected units do not respond and respondents differ systematically;
  • measurement error, caused by ambiguous questions, faulty instruments, or inaccurate reporting;
  • processing error, introduced during coding, data entry, merging, or transformation;
  • survivorship bias, when analysis includes only units that remain observable;
  • response or social-desirability bias, when participants alter answers because of pressure or perceived expectations.

Increasing sample size does not automatically solve these problems. A very large biased dataset can provide highly precise estimates of the wrong quantity.

Data Quality Before Data Analysis

Data quality is multidimensional. Accuracy concerns closeness to the true value; completeness concerns missing required values; consistency concerns agreement across fields and sources; validity concerns adherence to allowed formats or rules; uniqueness concerns duplicate records; and timeliness concerns whether data remain suitable for the decision.

A practical quality assessment begins with provenance: where did the data originate, what definitions were used, and what transformations have already occurred? The analyst should inspect the data dictionary, units, collection dates, key fields, coding conventions, and linkage procedures before computing summaries.

Typical checks include:

1. confirming row and column counts and identifying the observational unit;

2. checking data types, permitted ranges, and category labels;

3. quantifying missing values overall and by important subgroups;

4. searching for duplicate keys and impossible combinations;

5. inspecting distributions for extreme values, spikes, gaps, and suspicious rounding;

6. comparing related fields, such as order date and delivery date;

7. documenting every correction, exclusion, imputation, and transformation.

Missingness should not be treated as a purely technical inconvenience. A missing income value may reflect privacy concerns, and missing clinical measurements may occur because a patient is especially ill. Analysts should consider whether data are missing completely at random, missing at random conditional on observed information, or missing not at random. The appropriate response may involve investigation, sensitivity analysis, or a carefully justified imputation method rather than automatic deletion.

Outliers are observations that are unusually distant from the rest of a distribution. They may be errors, rare but valid events, or evidence of a different subgroup. An outlier should not be removed simply because it changes the mean. The analyst should verify its source, assess its substantive plausibility, and compare conclusions with and without it.

Describing Distributions

A distribution describes how values occur across a variable. Its centre, spread, shape, and unusual features should be considered together.

The arithmetic mean is the sum of values divided by the number of observations. It uses every value and is useful for approximately symmetric distributions without influential extremes. The median is the middle ordered value, or the average of the two middle values when the sample size is even. It is resistant to extreme observations and often better represents a skewed distribution. The mode is the most frequent value and is particularly useful for categorical data.

Measures of spread include the range, interquartile range (IQR), variance, and standard deviation. The range is simple but depends only on two observations. The IQR, Q3 − Q1, describes the central half of the data and is robust to extremes. Variance is the average squared deviation from the mean, with a sample estimate commonly using denominator n − 1. Standard deviation is the square root of variance and is expressed in the original units.

Percentiles locate values within an ordered distribution. The 90th percentile is a value at or below which approximately 90 percent of observations fall, subject to the chosen percentile convention. Quantiles support service-level monitoring, wage comparisons, and risk analysis more effectively than a mean alone in many settings.

Skewness describes asymmetry. In a right-skewed distribution, a relatively small number of large values pull the mean above the median. Income, transaction amounts, and waiting times often display this pattern. A histogram, density plot, box plot, or empirical cumulative distribution can reveal features that a single summary conceals.

Robust Summaries

A statistic is robust when it is relatively insensitive to deviations from assumptions or to a small number of extreme observations. The median and IQR are robust location and spread summaries. A trimmed mean removes a specified proportion of the smallest and largest observations before calculating the mean. A winsorized mean replaces extremes with less extreme boundary values. Robust methods are valuable when distributions are heavy-tailed, contaminated, or uncertain, but they do not make unusual observations irrelevant. They change the question from average total magnitude toward typical central behaviour.

Group summaries must be interpreted carefully. An overall mean can conceal major differences between regions, customer segments, or time periods. Conversely, subgroup comparisons may be unstable when groups are small. Aggregation can also produce misleading conclusions, a problem associated with ecological inference and, in some settings, Simpson’s paradox. Analysts should examine both overall and stratified results.

Exploratory Data Analysis as an Investigative Process

EDA is a cycle rather than a single chart. The analyst begins with the substantive question, inspects data structure and quality, examines one variable at a time, studies relationships, investigates anomalies, and records hypotheses for later testing.

For one categorical variable, frequency tables and bar charts are suitable. For one quantitative variable, histograms, density plots, box plots, and quantile summaries are useful. To compare a quantitative variable across categories, side-by-side box plots, violin plots, strip plots, or group-specific summaries may be used. For two quantitative variables, scatter plots reveal direction, form, clusters, and unusual points. Time-series plots reveal trend, seasonality, level shifts, and missing intervals. A correlation coefficient can summarize linear association but cannot detect every nonlinear relationship and does not establish causation.

Visualization is an analytical instrument, not decoration. Axes should be labelled, units stated, scales chosen honestly, and transformations disclosed. Truncated axes may exaggerate differences in bar charts; excessive aggregation may hide variation; and colour choices may be inaccessible to people with colour-vision deficiency. Interactive dashboards should preserve definitions and allow users to inspect denominators and filters.

A useful EDA record includes the question asked, data version, transformations, charts, notable findings, alternative explanations, and unresolved limitations. Reproducible scripts or notebooks are preferable to undocumented manual manipulation. Exploratory findings should be distinguished from confirmatory claims because repeatedly searching data for a pattern increases the chance of false discovery.

A Practical Workflow for Analysts

A defensible workflow can be organized as follows:

1. Frame the problem. Define the decision, target population, unit of analysis, time period, and estimand or quantity of interest.

2. Acquire and document data. Record sources, permissions, definitions, collection procedures, and known limitations.

3. Audit structure and quality. Check types, keys, missingness, duplicates, ranges, and consistency.

4. Prepare cautiously. Standardize formats, resolve or flag errors, and preserve raw data separately from analysis-ready data.

5. Describe marginal distributions. Use appropriate numerical summaries and visualizations for each variable.

6. Explore relationships. Compare relevant subgroups, examine time and geography, and investigate possible confounding.

7. Challenge initial impressions. Test sensitivity to outliers, definitions, exclusions, and alternative aggregations.

8. Communicate findings. State what is supported, what remains uncertain, and what further analysis is required.

This workflow is iterative. A plot may reveal that the unit of analysis was misunderstood; a missingness pattern may require revising the research question; or a suspected outlier may expose a data-entry rule.

Illustrative Case: Exploring Customer-Service Response Times

Background

A fictional online retailer, Northstar Commerce, wants to determine whether customers in different regions receive comparable support. The operations team provides a dataset containing ticket identifier, region, issue type, creation time, first-response time, resolution time, customer channel, and satisfaction rating for one quarter.

Situation and Problem

The initial report states that the average first-response time is 8.2 hours. Managers are concerned because complaints from one region appear to be increasing. The data science team must assess whether the average is informative and whether operational differences are real.

Analysis

The team first defines the observational unit as a support ticket and checks uniqueness of ticket identifiers. Twelve percent of tickets have no first-response time because they were closed automatically; these are not treated as zero-hour responses. Timestamps reveal that some records use local time and others use UTC, producing impossible negative durations after merging. The team corrects the time-zone conversion and documents the change.

A histogram and box plot show a strongly right-skewed response-time distribution. The mean of 8.2 hours is substantially higher than the median of 2.6 hours because a small number of tickets waited several days. The 90th percentile is 21.4 hours, which is more relevant to a service-level concern than the mean alone. Region-level box plots show that the apparently problematic region has a higher proportion of complex technical tickets and a larger share of weekend submissions.

The team compares regions within issue type and separates weekday from weekend tickets. The regional difference becomes smaller after these stratifications, suggesting that workload composition and timing contribute to the original gap. However, one region still has a higher upper tail, indicating a possible staffing problem for complex cases.

Approach and Solution

The team reports median, IQR, 90th percentile, and the proportion responded to within four hours, rather than relying only on the mean. It recommends a dashboard with definitions, denominators, time-zone rules, and filters for issue type and submission period. Operations schedules additional weekend coverage and investigates the long-delay tickets individually. Automatic closures are reported separately rather than merged with human-response times.

Outcome

The organization avoids an unjustified conclusion that one regional team is generally inefficient. It identifies a narrower operational issue: delayed responses among complex weekend tickets. The revised metrics support a more targeted staffing decision and create a reproducible basis for later service-level modelling.

Learning Points

The case demonstrates that data quality, distributional shape, robust summaries, subgroup analysis, and clear definitions are inseparable. A single average can conceal operationally important tail behaviour, while an unexamined data-processing error can create a false regional comparison.

Risks, Limitations and Common Mistakes

Several recurring mistakes weaken exploratory analysis. Analysts may confuse correlation with causation, interpret a sample as representative without examining selection, or report a mean for a heavily skewed distribution. They may delete outliers without investigation, code missing values as zero, compare groups with different denominators, or create charts before defining the unit of analysis.

Another risk is p-hacking or “HARKing”—presenting an exploratory pattern as if it had been predicted in advance. EDA can generate valuable hypotheses, but confirmatory analyses should disclose how hypotheses and variables were selected. Multiple comparisons, researcher degrees of freedom, and unstable small-group estimates should be acknowledged.

Data leakage is a technical and statistical problem in predictive work. A variable recorded after the outcome or influenced by the decision being predicted may produce impressive but unusable performance. Temporal ordering and the intended deployment context must therefore be considered during data preparation.

Ethical, Governance and Professional Considerations

Statistical analysis carries responsibilities beyond numerical correctness. Analysts should protect personal information through data minimization, access controls, de-identification where appropriate, and compliance with applicable privacy and sector regulations. Re-identification risk can remain even after direct identifiers are removed when multiple quasi-identifiers are combined.

Definitions and quality limitations should be communicated to decision-makers, especially when metrics affect employment, credit, healthcare, education, or public services. Fairness assessment may require subgroup-specific quality checks, missingness analysis, and examination of whether measurement processes disadvantage particular groups. Transparency does not mean publishing confidential records; it means making the data provenance, assumptions, transformations, and limitations understandable to authorized stakeholders.

Digital Tools and Emerging Practice

Modern data-science platforms support profiling, automated validation, visualization, notebook-based analysis, and data-lineage tracking. Great Expectations-style validation frameworks, SQL quality checks, version control, and reproducible pipelines can detect schema changes, duplicate records, and invalid ranges before analysis reaches production. Automated anomaly detection is useful for triage but cannot determine whether an unusual value is erroneous without contextual judgment.

AI-assisted coding and visualization can accelerate EDA, but generated transformations and interpretations require verification. An automated system may silently infer incorrect types, remove unusual observations, or produce a persuasive chart with a misleading denominator. Current practice is moving toward data contracts, observability, documented lineage, and continuous monitoring of data distributions. These developments strengthen, but do not replace, statistical reasoning.

Best Practices for Exploratory Analysis

A professional analyst should:

  • begin with the population, unit, decision, and measurement definitions;
  • preserve raw data and maintain a documented transformation trail;
  • inspect missingness, duplicates, ranges, distributions, and subgroup coverage;
  • use summaries suited to the scale and shape of each variable;
  • report robust and conventional summaries when extremes are plausible;
  • visualize denominators, uncertainty, and relevant subgroups;
  • investigate rather than automatically delete unusual observations;
  • separate exploratory findings from confirmatory conclusions;
  • assess whether the sample and measurement process support generalization;
  • make analyses reproducible and communicate limitations clearly.

Chapter Summary

Statistical thinking treats data as evidence generated by a measurement and sampling process. Populations, samples, parameters, statistics, variables, and measurement scales provide the conceptual vocabulary for describing that evidence. Sampling can introduce random variation and systematic selection bias, while non-sampling errors arise from coverage, nonresponse, measurement, processing, and survivorship processes.

Sound analysis begins with data-quality assessment and proceeds through descriptive summaries and exploratory visualizations. Means and standard deviations are useful in suitable distributions, while medians, IQRs, percentiles, trimmed means, and other robust summaries are valuable when data are skewed or contain influential extremes. EDA is an iterative investigation of distributions, relationships, anomalies, and subgroup differences. Its results guide later modelling but should not be presented as automatically confirmatory.

Professional practice requires reproducibility, transparent definitions, privacy protection, fairness awareness, and careful communication of uncertainty. The central lesson is that sophisticated computation cannot compensate for unclear questions, poor measurement, biased sampling, or unexamined data quality.

Key Terms

Population: The complete set of units relevant to a statistical question.

Sample: A subset of a population that is observed or analysed.

Parameter: A numerical characteristic of a population.

Statistic: A numerical characteristic calculated from a sample.

Variable: A characteristic that can take different values across observational units.

Observational unit: The entity on which measurements are recorded.

Nominal scale: A measurement scale consisting of unordered categories.

Ordinal scale: A scale with ordered categories but not necessarily equal intervals.

Interval scale: A scale with equal differences but no meaningful absolute zero.

Ratio scale: A scale with equal differences and a meaningful zero.

Sampling error: Random discrepancy caused by observing a sample rather than a whole population.

Sampling bias: Systematic distortion caused by the selection process.

Nonresponse error: Bias arising when selected units do not respond and differ from respondents.

Measurement error: Difference between a recorded value and the intended true or construct value.

Missingness: The absence of a value that was expected or potentially relevant.

Outlier: An observation unusually distant from the main pattern of a distribution.

Robust statistic: A statistic relatively resistant to extreme values or assumption violations.

Interquartile range: The difference between the third and first quartiles.

Exploratory data analysis: Systematic use of summaries and visualizations to investigate data structure and patterns.

Data provenance: Documentation of a dataset’s origin, collection, transformation, and use.

Review Questions

Short Answer Questions

1. Distinguish a population parameter from a sample statistic.

2. Why is the arithmetic mean inappropriate for some nominal variables?

3. Define sampling bias and give one example.

4. What information does the interquartile range provide?

5. Why should missing values not automatically be recoded as zero?

Long Answer Questions

1. Explain the four measurement scales and discuss the statistical operations appropriate for each.

2. Compare simple random, stratified, cluster, and convenience sampling, including their practical trade-offs.

3. Describe a systematic data-quality audit for a newly received dataset.

4. Explain how skewness and outliers influence the choice between mean, median, standard deviation, and IQR.

5. Discuss EDA as an iterative process and explain why exploratory findings should be distinguished from confirmatory conclusions.

Analytical / Application Questions

1. A delivery dataset has a mean delay of 14 minutes, a median of 5 minutes, and a few delays above 300 minutes. Which summaries and visualizations would you report, and why?

2. A survey of employee wellbeing is completed only by volunteers using an internal website. Identify likely errors and propose ways to improve the design or qualify the conclusions.

3. A regional response-time difference disappears after separating weekend from weekday tickets and simple from complex issues. Explain how this changes the interpretation and what further analysis is warranted.

22. Multiple Choice Questions with Answers

Question 1

A researcher wants to estimate the average income of all households in a city but surveys 1,000 selected households. The average income computed from those households is a:

A. Population parameter

B. Sample statistic

C. Sampling frame

D. Measurement scale

Correct Answer: B. Sample statistic

Question 2

Which measurement scale permits meaningful statements that one value is twice another?

A. Nominal

B. Ordinal

C. Interval

D. Ratio

Correct Answer: D. Ratio

Question 3

A large online survey is open to anyone who chooses to respond. Its main inferential risk is:

A. Guaranteed low sampling error

B. Voluntary-response selection bias

C. Automatic measurement validity

D. Excessive stratification

Correct Answer: B. Voluntary-response selection bias

Question 4

For a strongly right-skewed distribution with several very large observations, the most robust typical-value summary is usually the:

A. Median

B. Range

C. Arithmetic mean

D. Variance

Correct Answer: A. Median

Question 5

Which action is most appropriate when an extreme transaction value is discovered?

A. Delete it immediately

B. Replace it with the mean without documentation

C. Verify its source and assess whether it is valid

D. Convert it to a missing value automatically

Correct Answer: C. Verify its source and assess whether it is valid

Question 6

A dataset records missing income values mainly among respondents who decline sensitive questions. This pattern suggests that missingness:

A. Can safely be treated as zero

B. May be related to the unobserved value or response behaviour

C. Is always completely random

D. Is a form of ratio measurement

Correct Answer: B. May be related to the unobserved value or response behaviour

Question 7

Which visualization is most directly suited to examining the relationship between two quantitative variables?

A. Pie chart

B. Scatter plot

C. Single frequency table

D. Bar chart of one category

Correct Answer: B. Scatter plot

Question 8

In the Northstar Commerce case, why was the mean response time insufficient on its own?

A. The variable was nominal

B. All tickets had identical response times

C. The distribution was right-skewed and the upper tail mattered operationally

D. The sample contained no timestamps

Correct Answer: C. The distribution was right-skewed and the upper tail mattered operationally

Question 9

Which statement best describes sampling error?

A. It is always caused by inaccurate instruments

B. It is random discrepancy arising because only part of a population is observed

C. It disappears whenever a sample is large

D. It is identical to processing error

Correct Answer: B. It is random discrepancy arising because only part of a population is observed

Question 10

An analyst reports a regional difference in service time without accounting for the fact that regions receive different proportions of complex tickets. The principal concern is:

A. Confounding or compositional differences

B. Nominal coding of the ticket identifier

C. Use of a meaningful zero

D. Excessive data completeness

Correct Answer: A. Confounding or compositional differences

Statistics and Probability for Data Science
Chapter 1 of 15

Statistics and Probability for Data Science

Chapter 2
Foundations of Probability

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

2. Foundations of Probability

Introduction and Context

Data science is concerned with learning from incomplete, variable, and uncertain information. A predictive model may estimate whether a customer will default, whether a transaction is fraudulent, or whether a machine will fail, but such predictions are rarely certain. Probability provides the formal language for representing uncertainty, combining evidence, and making rational decisions under incomplete knowledge.

Probability is not merely a collection of formulas. It is a mathematical framework built from sets, logical operations, counting principles, and rules for updating beliefs when new information becomes available. These foundations support statistical inference, machine learning, simulation, risk analysis, experimental design, and Bayesian modelling. This chapter develops those foundations and illustrates how they operate in practical data-science settings.

Learning Objectives

By the end of this chapter, students should be able to:

1. Describe random experiments, sample spaces, events, and probability measures.

2. Apply the axioms of probability and the principal laws derived from them.

3. Use set operations and Venn-diagram reasoning to analyse events.

4. Solve counting problems using permutations, combinations, and the multiplication principle.

5. Compute conditional probabilities and distinguish dependence from independence.

6. Apply the law of total probability and Bayes’ theorem.

7. Interpret probabilistic results in classification, risk, quality-control, and decision-making contexts.

8. Identify common errors, modelling assumptions, and ethical issues in probabilistic analysis.

1. The Probabilistic View of Data

A random experiment is a process with a set of possible outcomes, although the particular outcome is not known in advance. Examples include selecting a record from a database, observing whether a payment is fraudulent, or measuring the lifetime of a component. The set of all possible outcomes is the sample space, denoted by \(S\) or \(\Omega\).

An event is a subset of the sample space. If a die is rolled, \(S=\{1,2,3,4,5,6\}\), and the event \(A=\{2,4,6\}\) represents obtaining an even number. Events can be combined using set operations. The union \(A\cup B\) means that at least one of the events occurs; the intersection \(A\cap B\) means that both occur; and the complement \(A^c\) means that \(A\) does not occur. Two events are mutually exclusive if \(A\cap B=\varnothing\).

The sample space must be defined carefully. For a fraud-detection problem, the outcomes might be simply {fraud, legitimate}, or they might include transaction amount, location, device type, and time. The appropriate sample space depends on the question being asked. Poor definition of the outcome space can produce logically incorrect probabilities even when the calculations appear correct.

2. Axioms and Laws of Probability

A probability function assigns a number \(P(A)\) to every event \(A\), satisfying three Kolmogorov axioms:

1. Non-negativity: \(P(A)\geq 0\).

2. Normalization: \(P(S)=1\).

3. Countable additivity: For mutually exclusive events \(A_1,A_2,\ldots\),

\[P\left(\bigcup_i A_i\right)=\sum_iP(A_i).\]

These axioms imply several useful results. For any event \(A\),

\[P(A^c)=1-P(A).\]

If \(A\) and \(B\) are mutually exclusive, then \(P(A\cup B)=P(A)+P(B)\). For arbitrary events,

\[P(A\cup B)=P(A)+P(B)-P(A\cap B).\]

The subtraction is necessary because the intersection is counted twice when the two probabilities are added.

If \(A\subseteq B\), then \(P(A)\leq P(B)\). The probability of an event always lies between zero and one. In a finite sample space with equally likely outcomes,

\[P(A)=\frac{|A|}{|S|},\]

where \(|A|\) denotes the number of outcomes in \(A\). Equal likelihood, however, should not be assumed automatically. In real data, outcomes may have different frequencies or unequal exposure.

Set reasoning in an example

Suppose 60% of users open an email, 25% click a link, and 15% do both. The probability that a user opens or clicks is

\[

P(O\cup C)=0.60+0.25-0.15=0.70.

\]

The probability of neither action is \(1-0.70=0.30\). The result demonstrates why union probabilities cannot generally be obtained by simple addition.

3. Counting Uncertainty: Combinatorics

Counting methods are useful when probabilities are based on equally likely arrangements. The multiplication principle states that if one task can be completed in \(m\) ways and a second in \(n\) ways, the combined task can be completed in \(mn\) ways.

A permutation counts ordered arrangements. The number of ways to arrange \(r\) objects selected from \(n\) distinct objects is

\[

P(n,r)=\frac{n!}{(n-r)!}.

\]

A combination counts selections where order does not matter:

\[

\binom{n}{r}=\frac{n!}{r!(n-r)!}.

\]

For example, selecting three analysts from ten for a committee gives \(\binom{10}{3}=120\) possible committees. Assigning those three analysts to the roles of chair, secretary, and reviewer gives \(P(10,3)=720\) possible ordered assignments.

Combinatorial reasoning is often used in sampling, feature selection, security analysis, and randomised algorithms. It must be applied with care when sampling is with replacement, when objects are indistinguishable, or when the outcomes are not equally likely.

4. Conditional Probability and the Updating of Uncertainty

The probability of an event may change when additional information is known. The conditional probability of \(A\) given \(B\), where \(P(B)>0\), is

\[

P(A\mid B)=\frac{P(A\cap B)}{P(B)}.

\]

This formula restricts attention to the cases in which \(B\) occurs and measures the proportion of those cases that also belong to \(A\). Rearranging gives the multiplication rule:

\[

P(A\cap B)=P(A\mid B)P(B)=P(B\mid A)P(A).

\]

Consider a population in which 4% of transactions are fraudulent. A screening system flags 90% of fraudulent transactions and incorrectly flags 5% of legitimate transactions. The probability of a flag is

\[

P(F)=P(F\mid D)P(D)+P(F\mid D^c)P(D^c)

\]

\[=(0.90)(0.04)+(0.05)(0.96)=0.084.

\]

Although the detector is effective, the probability that a flagged transaction is actually fraudulent is

\[

P(D\mid F)=\frac{(0.90)(0.04)}{0.084}\approx0.429.

\]

Thus, only about 42.9% of flagged transactions are fraudulent. This result illustrates the base-rate effect: the prevalence of an event substantially influences the meaning of a positive signal.

5. Independence and Dependence

Events \(A\) and \(B\) are independent if learning that one occurred does not change the probability of the other. Formally,

\[

P(A\cap B)=P(A)P(B).

\]

Equivalently, if the relevant probabilities exist, \(P(A\mid B)=P(A)\) and \(P(B\mid A)=P(B)\).

Independence is a mathematical assumption, not a synonym for “unrelated” in ordinary language. Two events can be associated through a common cause even when they appear separately recorded. For example, ice-cream sales and swimming incidents may both increase during hot weather; they are not necessarily causally related to each other, but they are statistically dependent through temperature.

Independence should also be distinguished from mutual exclusivity. If two events with positive probability are mutually exclusive, they cannot be independent, because their intersection has probability zero while the product of their probabilities is positive. In data science, assuming independence can simplify computation, as in the naive Bayes classifier, but the assumption may be inaccurate. The model can still perform well in some classification tasks, yet its probability estimates may require calibration.

6. Total Probability and Bayes’ Theorem

Suppose \(B_1,B_2,\ldots,B_k\) form a partition of the sample space: they are mutually exclusive and their union is the entire space. The law of total probability states that

\[

P(A)=\sum_{i=1}^{k}P(A\mid B_i)P(B_i).

\]

It decomposes an overall probability into contributions from distinct groups or causes.

Bayes’ theorem follows from the multiplication rule:

\[

P(B_j\mid A)=\frac{P(A\mid B_j)P(B_j)}{\sum_{i=1}^{k}P(A\mid B_i)P(B_i)}.

\]

In applied work, \(P(B_j)\) is the prior probability, \(P(A\mid B_j)\) is the likelihood of the evidence, and \(P(B_j\mid A)\) is the posterior probability after observing the evidence.

Bayesian reasoning is central to diagnosis, recommendation systems, anomaly detection, document classification, and adaptive experimentation. Its value lies not in replacing evidence with belief, but in providing a transparent rule for combining prior information with observed data. The prior must be justified, the likelihood model must be appropriate, and the sensitivity of conclusions to alternative assumptions should be examined.

7. A Structured Approach to Probability Problems

A reliable solution usually follows these stages:

1. Define the observational unit and sample space.

2. State the events using precise notation or plain language.

3. Determine whether the events are mutually exclusive, exhaustive, dependent, or independent.

4. Select the appropriate rule: complement, union, multiplication, total probability, or Bayes’ theorem.

5. Substitute values and retain sufficient precision.

6. Check that the result lies between zero and one and makes contextual sense.

7. Interpret the result in the language of the application.

Probability trees are particularly useful when events occur in stages. The probabilities along a branch are multiplied, while probabilities of alternative branches are added. Contingency tables provide an equivalent representation for observed categorical data and are useful for calculating conditional probabilities, sensitivity, specificity, and predictive values.

Applied Case: Prioritising Alerts in a Hospital Monitoring System

Background

An illustrative hospital analytics team uses a predictive system to identify patients at risk of a complication. The complication occurs in 2% of monitored patients. The system raises an alert for 95% of patients who develop the complication and for 8% of patients who do not.

Situation and analysis

Let \(C\) denote the complication and \(A\) an alert. Then

\[

P(A)=P(A\mid C)P(C)+P(A\mid C^c)P(C^c)

\]

\[=(0.95)(0.02)+(0.08)(0.98)=0.0974.

\]

The probability that an alerted patient truly develops the complication is

\[

P(C\mid A)=\frac{(0.95)(0.02)}{0.0974}\approx0.195.

\]

Only about 19.5% of alerts correspond to actual complications, despite high sensitivity. The low base rate and false-positive rate create a substantial workload.

Approach and decision

The team should not evaluate the system using sensitivity alone. It should also examine specificity, positive predictive value, alert volume, the cost of missed cases, and the cost of unnecessary interventions. A risk-tiering strategy could combine the alert with clinical history and laboratory measurements. Thresholds should be selected according to the consequences of false negatives and false positives, not solely according to statistical accuracy.

Outcome and learning points

The case shows how total probability estimates the total alert rate, while Bayes’ theorem estimates the probability that an alert is meaningful. It also demonstrates why model performance depends on prevalence. If the system is deployed in a population with a different complication rate, its predictive value will change even if sensitivity and specificity remain constant.

Applications in Data Science and Professional Practice

Probability supports binary and multiclass classification, risk scoring, Monte Carlo simulation, reliability analysis, A/B testing, inventory planning, credit assessment, and fraud detection. In machine learning, predicted probabilities allow organisations to rank cases, choose decision thresholds, quantify uncertainty, and allocate limited resources.

For managers, probability clarifies the difference between a model score and a decision rule. A probability of default of 0.18 does not itself determine whether credit should be denied; the decision also depends on loss severity, regulatory requirements, customer impact, and organisational risk tolerance. For technical teams, probability provides a basis for evaluating calibration, sampling variation, missing data, and distribution shift.

Digital systems increasingly automate probabilistic decisions. Such automation should include monitoring for changes in base rates, documentation of assumptions, reproducible data pipelines, and human review for high-impact cases. A probability estimate should not be presented as certainty, especially when data are sparse or the model has not been validated in the target population.

Common Errors, Limitations, and Ethical Considerations

A frequent error is confusing \(P(A\mid B)\) with \(P(B\mid A)\). Another is ignoring the base rate, adding overlapping probabilities without subtracting their intersection, or treating a sample proportion as an exact population probability. Independence should not be assumed merely because variables are recorded separately. Selection bias can also distort probabilities when the observed sample does not represent the population to which conclusions are applied.

Probability models are abstractions. They depend on a defined population, measurement process, time period, and set of assumptions. A model based on historical data may reproduce discriminatory patterns or perform unevenly across demographic groups. In high-impact applications, analysts should document data provenance, assess subgroup performance, protect privacy, explain uncertainty, and provide mechanisms for review or appeal. Ethical practice requires distinguishing statistical association from causal evidence and avoiding unjustified certainty in communication.

Best Practices

  • Define events and populations before calculating probabilities.
  • Use partitions and probability trees to make assumptions visible.
  • Report both conditional probabilities and their denominators.
  • Check base rates whenever interpreting tests, alerts, or classifiers.
  • Validate independence assumptions rather than accepting them automatically.
  • Compare model probabilities with observed frequencies through calibration analysis.
  • Conduct sensitivity analysis for uncertain priors and changing prevalence.
  • Align thresholds with consequences, costs, and professional standards.
  • Communicate uncertainty clearly to technical and non-technical stakeholders.

Current Developments

Modern probabilistic data science increasingly combines classical probability with probabilistic programming, Bayesian computation, uncertainty quantification, and simulation-based inference. Machine-learning systems are being evaluated not only for predictive accuracy but also for calibration, robustness under distribution shift, and reliability of uncertainty estimates. These developments make foundational probability especially important: sophisticated software can calculate a result quickly, but it cannot determine whether the sample space, assumptions, or interpretation are appropriate.

Chapter Summary

Probability formalises uncertainty through sample spaces, events, and probability measures. The axioms lead to complement, union, and inclusion–exclusion rules. Counting methods provide probabilities for equally likely finite outcomes, while conditional probability describes how information changes uncertainty. The multiplication rule supports sequential analysis; independence simplifies joint probabilities but must be justified. The law of total probability combines probabilities across groups, and Bayes’ theorem reverses conditional relationships to update prior beliefs using evidence. In data science, these tools underpin classification, diagnosis, risk scoring, alert management, simulation, and evidence-based decisions. Correct interpretation requires attention to base rates, assumptions, data quality, calibration, fairness, and the consequences of error.

Key Terms

Sample space: The set of all possible outcomes of a random experiment.

Outcome: A single possible result of a random experiment.

Event: A subset of the sample space representing a condition of interest.

Probability: A number from 0 to 1 quantifying the likelihood of an event.

Complement: The event consisting of all outcomes not in a specified event.

Union: The event that at least one of two or more events occurs.

Intersection: The event that two or more events occur together.

Mutually exclusive events: Events that cannot occur simultaneously.

Conditional probability: The probability of an event given that another event has occurred.

Independence: A relationship in which occurrence of one event does not alter the probability of another.

Permutation: An ordered arrangement of selected objects.

Combination: An unordered selection of objects.

Partition: A collection of mutually exclusive events that exhausts the sample space.

Law of total probability: A rule expressing an event probability as a weighted sum across a partition.

Bayes’ theorem: A rule for computing a conditional probability in the reverse direction.

Prior probability: The probability assigned before considering new evidence.

Likelihood: The probability of observed evidence under a specified condition or hypothesis.

Posterior probability: The updated probability after incorporating evidence.

Base rate: The prevalence or prior frequency of an event in a population.

Positive predictive value: The probability that a positive result corresponds to the condition of interest.

Review Questions

Short Answer Questions

1. What is the difference between a sample space and an event?

2. State the three axioms of probability.

3. When are two events mutually exclusive?

4. Define conditional probability and state its formula.

5. What does it mean for two events to be independent?

Long Answer Questions

1. Explain the union rule for probability and illustrate why the intersection must be subtracted.

2. Compare permutations and combinations, including an example of each.

3. Derive the multiplication rule from the definition of conditional probability.

4. Explain the law of total probability and Bayes’ theorem using a diagnostic or classification example.

5. Discuss the role of base rates, calibration, and uncertainty in automated decision systems.

Analytical / Application Questions

1. A disease affects 3% of a population. A test has sensitivity 92% and a false-positive rate of 6%. Calculate the probability of a positive test and the probability that a person with a positive test has the disease.

2. In a dataset, 45% of customers use a mobile application, 30% purchase a subscription, and 18% do both. Find the probability that a randomly selected customer uses the application or purchases a subscription, and the probability of neither.

3. A company receives applications from three regions representing 50%, 30%, and 20% of applicants. Their acceptance rates are 4%, 7%, and 10%, respectively. Calculate the overall acceptance probability and the probability that an accepted applicant came from the second region.

22. Multiple Choice Questions with Answers

Question 1

A user opens an email with probability 0.60, clicks its link with probability 0.25, and does both with probability 0.15. What is the probability that the user opens or clicks the email?

A. 0.40

B. 0.70

C. 0.85

D. 1.00

Correct Answer: B. 0.70

Question 2

Which condition defines independence of events A and B?

A. P(A∩B)=0

B. P(A∪B)=P(A)+P(B)

C. P(A∩B)=P(A)P(B)

D. P(A|B)=P(B|A)

Correct Answer: C. P(A∩B)=P(A)P(B)

Question 3

A rare condition has prevalence 2%. A test detects 95% of affected cases and has an 8% false-positive rate. Approximately what is the probability that a positive result indicates the condition?

A. 19.5%

B. 50.0%

C. 92.0%

D. 95.0%

Correct Answer: A. 19.5%

Question 4

Which expression correctly represents the law of total probability for a partition B1,...,Bk?

A. P(A)=ΣP(Bi|A)

B. P(A)=ΣP(A|Bi)P(Bi)

C. P(A)=P(A|B1)P(A|B2)

D. P(A)=P(Bi|A)P(A)

Correct Answer: B. P(A)=ΣP(A|Bi)P(Bi)

Question 5

If two events with positive probabilities are mutually exclusive, which statement is correct?

A. They must be independent

B. Their intersection has probability one

C. They cannot be independent

D. Their union has probability zero

Correct Answer: C. They cannot be independent

Question 6

How many unordered committees of three can be selected from ten distinct analysts?

A. 30

B. 120

C. 720

D. 1,000

Correct Answer: B. 120

Question 7

Which probability is the posterior probability in Bayes’ theorem?

A. P(B), assigned before evidence

B. P(A|B), evidence under a condition

C. P(B|A), condition after observing evidence A

D. P(A), the marginal evidence probability

Correct Answer: C. P(B|A), condition after observing evidence A

Question 8

A probability model reports P(default)=0.18 for a customer. What is the most accurate interpretation?

A. The customer will definitely default

B. The model estimates an 18% probability of default under its assumptions

C. Exactly 18% of all customers will default

D. The customer has an 18% chance of being approved

Correct Answer: B. The model estimates an 18% probability of default under its assumptions

Question 9

If P(A)=0.4 and P(B|A)=0.5, what is P(A∩B)?

A. 0.08

B. 0.20

C. 0.45

D. 0.90

Correct Answer: B. 0.20

Question 10

Why can a highly sensitive fraud detector still produce many false alarms?

A. Sensitivity always equals specificity

B. The sample space has no complement

C. A low fraud base rate and false-positive rate affect the predictive value

D. Bayes’ theorem applies only to medical data

Correct Answer: C. A low fraud base rate and false-positive rate affect the predictive value

Statistics and Probability for Data Science
Chapter 2 of 15

Statistics and Probability for Data Science

Chapter 3
Random Variables and Probability Distributions

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

3. Random Variables and Probability Distributions

Introduction and Context

Probability provides a language for uncertainty; a random variable converts uncertain outcomes into numerical quantities that can be analysed, modelled, and used for decision-making. In data science, this connection is fundamental. A customer’s next purchase, the number of defects in a production batch, the time until a machine fails, and the classification score assigned to an image are all uncertain quantities. Random variables and probability distributions provide formal methods for describing such quantities before, during, and after data collection.

A probability distribution does more than list possible values. It specifies how probability is allocated across those values. This allocation enables the calculation of expected outcomes, variability, tail risk, percentiles, and probabilities of events. It also supports statistical inference, simulation, predictive modelling, quality control, reliability analysis, and machine learning.

This chapter develops the principal ideas needed to work with discrete and continuous random variables. It examines probability mass and density functions, cumulative distribution functions, expectation, variance, moments, quantiles, and important distributions including Bernoulli, binomial, geometric, Poisson, uniform, normal, exponential, and related models. The emphasis is not only on formulae but also on selecting, interpreting, and critically evaluating probability models.

Learning Objectives

After studying this chapter, you should be able to:

1. Define random variables and distinguish discrete from continuous variables.

2. Use probability mass functions, probability density functions, and cumulative distribution functions.

3. Calculate and interpret expectation, variance, standard deviation, covariance, and moments.

4. Explain the assumptions and applications of major discrete and continuous distributions.

5. Use quantiles, percentiles, and standardisation in data analysis.

6. Select an appropriate distribution for a practical problem and identify model limitations.

7. Apply distributions to simulation, risk analysis, operations, and predictive analytics.

From Random Outcomes to Numerical Variables

A random experiment is a process whose outcome cannot be known with certainty in advance, although the possible outcomes and their probabilities may be described. The sample space, denoted by \(\Omega\), is the set of all possible outcomes. A random variable \(X\) is a function that assigns a numerical value to every outcome in the sample space.

The word “variable” can be misleading. A random variable is not merely a column of observed numbers; it is a probabilistic model for the numerical result of an uncertain process. For example, if three components are tested, \(X\) may denote the number that fail. Before testing, \(X\) is random. After testing, its observed value is fixed.

Random variables may be classified as follows:

  • A discrete random variable takes a finite or countably infinite set of values, such as 0, 1, 2, and so on.
  • A continuous random variable can take values in intervals of the real line, such as operating temperature or delivery time.
  • A mixed random variable has both discrete and continuous components, as may occur when a service time can be exactly zero for customers who abandon immediately and positive for others.

The distinction matters because probabilities are represented differently. For a discrete variable, probability is assigned to individual values. For a continuous variable, probability is assigned to intervals; the probability of any exact single value is ordinarily zero.

Probability Functions and Distribution Functions

Probability mass functions

For a discrete random variable \(X\), the probability mass function (PMF) is

\[p_X(x)=P(X=x).\]

A valid PMF satisfies

\[p_X(x)\geq 0, \qquad \sum_x p_X(x)=1.\]

The probability that \(X\) belongs to a set \(A\) is obtained by summing the masses of the values in that set:

\[P(X\in A)=\sum_{x\in A}p_X(x).\]

Suppose a help desk receives 0, 1, 2, or 3 urgent calls in an hour, with probabilities 0.10, 0.25, 0.40, and 0.25 respectively. The probability of at least two calls is \(0.40+0.25=0.65\).

Probability density functions

A continuous random variable is described by a probability density function (PDF), written \(f_X(x)\). A PDF must satisfy

\[f_X(x)\geq 0, \qquad \int_{-\infty}^{\infty}f_X(x)\,dx=1.\]

Probabilities are areas under the density curve:

\[P(a\leq X\leq b)=\int_a^b f_X(x)\,dx.\]

The value \(f_X(x)\) is not itself a probability and may exceed 1 when the measurement scale is sufficiently narrow. For a continuous variable, \(P(X=x)=0\) for every particular value \(x\), although intervals can have positive probability.

Cumulative distribution functions

The cumulative distribution function (CDF) is defined for every random variable by

\[F_X(x)=P(X\leq x).\]

For a discrete variable, the CDF is a step function. For a continuous variable, it is obtained by integrating the PDF:

\[F_X(x)=\int_{-\infty}^{x}f_X(t)\,dt.\]

The CDF is particularly useful for interval probabilities:

\[P(a<X\leq b)=F_X(b)-F_X(a).\]

Quantiles are also defined through the CDF. The \(q\)-quantile is a value \(x_q\) such that \(F_X(x_q)\geq q\), with an appropriate convention when the distribution has jumps. The median is the 0.5 quantile; the first and third quartiles are the 0.25 and 0.75 quantiles.

Expectation, Variability, and Moments

Expectation

The expected value, or mean, of a discrete random variable is

\[E[X]=\sum_x x p_X(x),\]

provided the sum is well defined. For a continuous random variable,

\[E[X]=\int_{-\infty}^{\infty}x f_X(x)\,dx.\]

Expectation is a probability-weighted average, not necessarily a value that the variable can actually take. If a fair die is rolled, its expected value is 3.5 even though 3.5 cannot appear on one roll.

For a function \(g(X)\), the law of the unconscious statistician gives

\[E[g(X)]=\sum_x g(x)p_X(x)\]

for a discrete variable, or

\[E[g(X)]=\int g(x)f_X(x)\,dx\]

for a continuous variable. This result allows quantities such as \(E[X^2]\) to be calculated directly from the distribution.

Expectation is linear:

\[E[aX+bY]=aE[X]+bE[Y],\]

whether or not \(X\) and \(Y\) are independent. This property is central in aggregate forecasting and portfolio analysis.

Variance and standard deviation

Variance measures expected squared deviation from the mean:

\[\operatorname{Var}(X)=E[(X-\mu)^2],\qquad \mu=E[X].\]

The computational form is

\[\operatorname{Var}(X)=E[X^2]-[E[X]]^2.\]

Standard deviation is \(\sigma=\sqrt{\operatorname{Var}(X)}\), and unlike variance it has the same units as the original variable. Variance is never negative and is zero only when the variable is constant with probability one.

For constants \(a\) and \(b\),

\[\operatorname{Var}(aX+b)=a^2\operatorname{Var}(X).\]

Adding a constant changes location but not variability; multiplying by a constant changes the standard deviation by its absolute value.

Higher moments and shape

The raw moment of order \(r\) is \(E[X^r]\). The central moment of order \(r\) is \(E[(X-\mu)^r]\). The second central moment is variance. The third central moment is related to skewness, and the fourth to kurtosis.

A standardized third central moment is

\[\gamma_1=\frac{E[(X-\mu)^3]}{\sigma^3},\]

which describes asymmetry. Positive skewness generally indicates a longer right tail. A common excess-kurtosis measure is

\[\gamma_2=\frac{E[(X-\mu)^4]}{\sigma^4}-3.\]

These measures should be interpreted cautiously, particularly with small samples or extreme observations. Quantiles and visualisations may provide more stable descriptions of skewed data.

Covariance and dependence

For two random variables,

\[\operatorname{Cov}(X,Y)=E[(X-E[X])(Y-E[Y])].\]

The correlation is

\[\rho_{XY}=\frac{\operatorname{Cov}(X,Y)}{\sigma_X\sigma_Y},\]

when both standard deviations are positive. Correlation measures linear association, not general dependence. Zero correlation does not always imply independence. If \(X\) and \(Y\) are independent, then \(E[XY]=E[X]E[Y]\) and their covariance is zero, subject to the existence of the relevant expectations.

Important Discrete Distributions

Bernoulli distribution

A Bernoulli trial has two outcomes, conventionally coded as success (1) and failure (0). If the probability of success is \(p\), then

\[P(X=x)=p^x(1-p)^{1-x},\qquad x\in\{0,1\}.\]

Its mean and variance are

\[E[X]=p,\qquad \operatorname{Var}(X)=p(1-p).\]

Examples include whether a transaction is fraudulent, whether a customer renews, or whether a sensor detects a fault. The two outcomes need not be equally likely, and “success” is simply the outcome being counted.

Binomial distribution

The binomial distribution counts successes in \(n\) independent Bernoulli trials with a common success probability \(p\):

\[P(X=k)=\binom{n}{k}p^k(1-p)^{n-k},\qquad k=0,1,\ldots,n.\]

Its mean and variance are \(np\) and \(np(1-p)\). The model requires a fixed number of trials, two outcomes per trial, constant success probability, and independence. Sampling without replacement from a small finite population may violate independence; a hypergeometric distribution may then be more suitable.

Geometric distribution

If independent Bernoulli trials continue until the first success, the number of trials required, \(X\), has the geometric distribution:

\[P(X=k)=(1-p)^{k-1}p,\qquad k=1,2,\ldots.\]

Its mean is \(1/p\), and its variance is \((1-p)/p^2\). The distribution is memoryless: given that the first success has not yet occurred, the remaining waiting-time distribution is unchanged. A different convention counts failures before the first success; analysts must state which definition they use.

Poisson distribution

The Poisson distribution models a count of events in a fixed interval when events occur independently at a constant average rate \(\lambda\):

\[P(X=k)=e^{-\lambda}\frac{\lambda^k}{k!},\qquad k=0,1,2,\ldots.\]

Both its mean and variance equal \(\lambda\). It is useful for modelling incoming calls, website requests, or defects per unit, provided the rate is reasonably stable and events are not strongly clustered. If events occur at rate \(\lambda\) per hour, a four-hour interval has Poisson mean \(4\lambda\).

The Poisson distribution can approximate a binomial distribution when \(n\) is large and \(p\) is small, with \(\lambda=np\). The approximation is not a substitute for checking assumptions.

Related count models

The negative binomial distribution can model the number of trials or failures required to obtain a specified number of successes. It is also frequently used for overdispersed count data, where the variance exceeds the mean. A binomial or Poisson model may be inadequate when observations are heterogeneous or correlated. In applied analytics, negative binomial regression is often preferred to Poisson regression when overdispersion is present.

Important Continuous Distributions

Uniform distribution

A continuous variable uniformly distributed on \([a,b]\) has constant density

\[f(x)=\frac{1}{b-a},\qquad a\leq x\leq b.\]

Its mean and variance are

\[E[X]=\frac{a+b}{2},\qquad \operatorname{Var}(X)=\frac{(b-a)^2}{12}.\]

The uniform model is appropriate when all values in a bounded interval are considered equally plausible, or as a simple model for random-number generation. It should not be adopted merely because the variable has known minimum and maximum values.

Normal distribution

The normal distribution has density

\[f(x)=\frac{1}{\sigma\sqrt{2\pi}}\exp\left[-\frac{(x-\mu)^2}{2\sigma^2}\right],\qquad \sigma>0.\]

It is symmetric about \(\mu\), with mean, median, and mode equal to \(\mu\), and variance \(\sigma^2\). The standard normal distribution is \(N(0,1)\). A normal variable can be standardised as

\[Z=\frac{X-\mu}{\sigma}.\]

Standardisation permits probabilities to be obtained from the standard normal CDF, often denoted by \(\Phi\). For example,

\[P(X\leq x)=\Phi\left(\frac{x-\mu}{\sigma}\right).\]

The empirical 68–95–99.7 rule states that approximately 68%, 95%, and 99.7% of a normal distribution lie within one, two, and three standard deviations of its mean. These are approximations, not universal rules. The normal model is often justified by measurement mechanisms or by the central limit theorem, but individual data need not be normal for sample means to be approximately normal under suitable conditions.

Exponential distribution

The exponential distribution models a waiting time until the next event in a Poisson process. With rate \(\lambda>0\), its density and CDF are

\[f(x)=\lambda e^{-\lambda x},\quad x\geq0,\]

\[F(x)=1-e^{-\lambda x},\quad x\geq0.\]

Its mean is \(1/\lambda\), and its variance is \(1/\lambda^2\). It is memoryless:

\[P(X>s+t\mid X>s)=P(X>t).\]

This property is mathematically convenient but may be unrealistic for ageing equipment, where failure risk changes with operating time. The Weibull distribution is often more flexible because its shape parameter can represent increasing, decreasing, or constant hazard.

Gamma and lognormal distributions

The gamma distribution generalises the exponential distribution and can model the waiting time until several Poisson events occur. It is positive-valued and right-skewed, making it useful for claim sizes, service times, and accumulated waiting times.

A lognormal variable is one whose logarithm is normally distributed. It is also positive and right-skewed. Income, transaction values, and biological measurements may sometimes be better represented by a lognormal model than a normal model. Choice should be supported by domain knowledge and diagnostics rather than by convenience.

Choosing and Using a Distribution

Distribution selection is a modelling decision. A useful workflow is:

1. Define the random quantity and its measurement unit.

2. Determine whether it is a count, binary outcome, bounded measurement, waiting time, or unrestricted measurement.

3. Examine support: possible values may be nonnegative, bounded, integer-valued, or real-valued.

4. Consider the data-generating mechanism and assumptions such as independence, constant rate, or symmetry.

5. Estimate parameters using appropriate methods, commonly maximum likelihood or method of moments.

6. Compare the fitted model with data using graphical diagnostics, probability plots, goodness-of-fit measures, and validation on relevant outcomes.

7. Assess sensitivity: determine whether decisions change under plausible alternative distributions.

A histogram alone is not sufficient. Bin choices can conceal tails, and a large sample may reveal statistically significant deviations that have little practical effect. Conversely, a visually plausible model may underestimate rare but consequential events. Tail probabilities, quantiles, and decision-specific loss should receive explicit attention.

Applications in Data Science and Professional Practice

Probability distributions appear throughout the data-science lifecycle. In exploratory analysis, they summarise uncertainty and identify skewness, outliers, and unusual concentration. In predictive modelling, a model may estimate a full conditional distribution rather than only a point prediction. A demand forecast, for example, can provide the probability that demand exceeds inventory rather than merely its expected value.

In operations, Poisson counts support staffing and capacity planning, while exponential or gamma waiting-time models support queue and reliability analysis. In finance and insurance, quantiles and tail probabilities inform loss limits and reserves. In manufacturing, binomial models describe defect counts and normal models may describe dimensional variation. In digital services, distributions of latency and request counts guide service-level objectives and infrastructure allocation.

Simulation is another major application. A fitted distribution can generate synthetic observations for stress testing, Monte Carlo estimation, and scenario analysis. Simulation results are only as credible as the assumptions and parameter estimates behind them. Random generation does not convert a poor model into a reliable forecast.

Modern software libraries calculate PMFs, CDFs, quantiles, random samples, and fitted parameters. They reduce arithmetic errors but do not decide whether a Poisson process is appropriate or whether a normal approximation is defensible. Reproducible analysis should record the distribution, parameterisation, software version, random seed where relevant, and model-validation procedure.

Illustrative Case Study: Modelling Support-Centre Workload

Background

A software company wants to plan staffing for its technical support centre. The centre receives requests throughout the day, and managers need to estimate the probability that more than 20 requests will arrive in a one-hour period.

Situation and problem

Historical records suggest that the average number of requests in a one-hour interval is 16. However, managers have noticed that requests sometimes arrive in bursts after system releases. A simple Poisson model may be useful, but its assumptions must be examined.

Analysis

Under a Poisson model with \(\lambda=16\), the request count \(X\) has mean and variance both equal to 16. The probability of more than 20 requests is

\[P(X>20)=1-P(X\leq20),\]

which can be computed using a statistical software package. The resulting probability can be translated into a staffing target, but the model should first be checked against historical intervals.

Suppose the observed variance is substantially greater than 16. This overdispersion suggests that the constant-rate, independent-event assumption is inadequate. Possible causes include release-related clustering, different demand levels across time periods, or unobserved heterogeneity. A negative binomial model or a time-varying Poisson model may be more suitable.

Approach and solution

The analyst segments data by hour of day and release status, compares Poisson and negative binomial fits, and evaluates out-of-sample tail predictions. The centre then uses the model that best predicts high-volume intervals, not merely the model with the best average fit. A simulation incorporates predicted hourly rates and tests staffing policies under ordinary and release-day conditions.

Outcome

The analysis demonstrates that a single average rate can understate congestion risk. A model that represents changing rates and overdispersion produces more realistic upper-tail estimates and supports a flexible staffing plan, such as reserving additional agents during releases.

Learning points

The case illustrates four principles: the mean alone does not determine a distribution; variance is a diagnostic for count models; tail probabilities can matter more than average performance; and model selection must reflect the operational decision. It also shows why domain knowledge and data-generating mechanisms are as important as formulae.

Limitations, Risks, and Common Mistakes

A frequent mistake is confusing a PDF value with a probability. Probabilities require an area or an interval calculation for continuous variables. Another is assuming independence because observations are recorded in separate rows; time series, clustered customers, and repeated measurements often remain dependent.

Analysts also use the normal distribution for bounded, strongly skewed, or count-valued data without checking support. A normal model can assign negative probabilities to quantities that cannot be negative. Likewise, a Poisson model is often applied to counts with excess zeros, changing rates, or variance much larger than the mean.

Parameter uncertainty is another risk. Fitting a distribution does not mean its parameters are known exactly. Confidence intervals, predictive intervals, bootstrap procedures, or Bayesian posterior distributions may be needed. Outliers can substantially alter estimated means and variances, especially in heavy-tailed settings.

Ethically, distributional assumptions can affect access to resources, insurance premiums, credit decisions, and employee evaluation. Analysts should document assumptions, quantify uncertainty, test subgroup performance, and avoid presenting model-based probabilities as objective facts. Sensitive applications require governance, auditability, privacy protection, and human review where consequences are significant.

Current Developments and Best Practices

Contemporary analytics increasingly uses probabilistic forecasting, which produces calibrated distributions rather than single predictions. Quantile regression, Bayesian hierarchical models, survival models, probabilistic graphical models, and neural forecasting systems can represent uncertainty at several levels. Generative models and simulation-based inference also rely on the ability to describe and sample from complex distributions.

These methods do not eliminate foundational distributional reasoning. Good practice remains to define the target quantity clearly, inspect support and dependence, distinguish aleatory uncertainty from uncertainty about parameters or models, validate calibration, and evaluate performance in the tails when decisions concern rare events. Where no standard distribution is adequate, empirical, mixture, hierarchical, or semiparametric models may be preferable.

Chapter Summary

A random variable represents the numerical outcome of an uncertain experiment. Discrete variables use probability mass functions, while continuous variables use densities and interval probabilities; the cumulative distribution function applies to both. Expectation describes probability-weighted location, variance describes dispersion, and higher moments and quantiles describe shape and tail behaviour. Covariance and correlation describe aspects of joint variation.

Bernoulli and binomial distributions model binary trials and counts of successes. Geometric distributions model trials until a first success, while Poisson distributions model event counts under a constant-rate process. Uniform, normal, exponential, gamma, lognormal, and Weibull-related models describe important continuous phenomena. Each distribution depends on assumptions about support, independence, rate, shape, and the data-generating mechanism.

In data science, distributions support forecasting, simulation, reliability, capacity planning, risk analysis, and probabilistic machine learning. A responsible analyst chooses models using both statistical evidence and domain knowledge, validates decision-relevant quantities, reports parameter uncertainty, and recognises that a convenient distribution may fail in the tails or under dependence.

Key Terms

Random variable: A function assigning numerical values to outcomes of a random experiment.

Discrete random variable: A random variable with finite or countably infinite possible values.

Continuous random variable: A random variable taking values over intervals of the real line.

Probability mass function: A function assigning probabilities to individual values of a discrete variable.

Probability density function: A nonnegative function whose interval areas give probabilities for a continuous variable.

Cumulative distribution function: The function \(F(x)=P(X\leq x)\) for a random variable.

Expectation: The probability-weighted average or mean of a random variable.

Variance: The expected squared deviation from the mean.

Standard deviation: The positive square root of variance.

Moment: An expected power of a variable or its deviation from the mean.

Quantile: A value below which a specified proportion of a distribution lies.

Covariance: A measure of joint linear variation between two variables.

Correlation: A standardized measure of linear association.

Bernoulli distribution: A distribution for one binary trial.

Binomial distribution: The distribution of successes in a fixed number of independent Bernoulli trials.

Geometric distribution: The distribution of trials required to obtain the first success.

Poisson distribution: A count distribution for events occurring at a constant average rate.

Normal distribution: A symmetric continuous distribution determined by mean and variance.

Exponential distribution: A continuous waiting-time distribution with the memoryless property.

Overdispersion: A condition in which observed variance exceeds that expected under a specified model.

Review Questions

Short Answer Questions

1. What is the difference between a discrete random variable and a continuous random variable?

2. Why is a PDF value not itself a probability?

3. State the relationship between variance and the second raw moment.

4. What assumptions are required for a binomial model?

5. Explain the memoryless property of the exponential distribution.

Long Answer Questions

1. Explain PMFs, PDFs, and CDFs, including how each is used to calculate probabilities.

2. Derive and interpret the mean and variance of a Bernoulli random variable.

3. Compare the binomial, geometric, and Poisson distributions in terms of their mechanisms and applications.

4. Explain standardisation for a normal random variable and discuss the role of the central limit theorem.

5. Discuss a systematic workflow for selecting and validating a probability distribution in data science.

Analytical / Application Questions

1. A call centre receives an average of 12 calls per ten minutes. Explain when a Poisson model would be appropriate and identify two diagnostics that could reveal its inadequacy.

2. A delivery-time variable is positive and strongly right-skewed. Compare the suitability of normal, exponential, gamma, and lognormal models for this problem.

3. A quality team observes 100 independent items, each with a 0.03 probability of defect. Formulate a suitable model for the number of defects, calculate its mean and variance, and discuss whether a Poisson approximation might be reasonable.

22. Multiple Choice Questions with Answers

Question 1

A continuous random variable has density f(x). Which expression gives the probability that it lies between a and b?

A. f(b)-f(a)

B. ∫a^b f(x) dx

C. f(a)f(b)

D. P(X=a)+P(X=b)

Correct Answer: B. ∫a^b f(x) dx

Question 2

If X has mean 5 and variance 9, what are the mean and variance of Y=2X+4?

A. Mean 14, variance 13

B. Mean 10, variance 18

C. Mean 14, variance 36

D. Mean 9, variance 36

Correct Answer: C. Mean 14, variance 36

Question 3

Which situation most directly satisfies the binomial model?

A. Counting arrivals during a variable-rate day

B. Counting successes in 20 independent trials with the same success probability

C. Measuring the time until a machine fails

D. Measuring a temperature that varies continuously

Correct Answer: B. Counting successes in 20 independent trials with the same success probability

Question 4

A Poisson random variable has parameter λ=7. Which statement is correct?

A. Its mean is 7 and variance is 49

B. Its mean is 49 and variance is 7

C. Its mean and variance are both 7

D. Its standard deviation is 7 and mean is 1/7

Correct Answer: C. Its mean and variance are both 7

Question 5

For a Bernoulli random variable with success probability p, which variance is correct?

A. p^2

B. 1-p

C. p(1-p)

D. p/(1-p)

Correct Answer: C. p(1-p)

Question 6

Which distribution is most directly associated with the waiting time until the next event in a constant-rate Poisson process?

A. Binomial

B. Exponential

C. Uniform

D. Geometric

Correct Answer: B. Exponential

Question 7

A fitted count model has observed variance much greater than its mean. Which concern is most relevant if a Poisson model was used?

A. Underdispersion caused by a bounded continuous variable

B. Overdispersion indicating that the Poisson assumptions may fail

C. The count must follow a normal distribution

D. The expected value must be zero

Correct Answer: B. Overdispersion indicating that the Poisson assumptions may fail

Question 8

If Z=(X−μ)/σ, what is the purpose of this transformation when X is normally distributed?

A. It makes X discrete

B. It changes the distribution to uniform

C. It standardises X to a normal variable with mean 0 and variance 1

D. It removes all sampling uncertainty

Correct Answer: C. It standardises X to a normal variable with mean 0 and variance 1

Question 9

Which statement about quantiles is correct?

A. The median is always equal to the mean

B. The 0.75 quantile has approximately 75% of the distribution at or below it

C. A quantile can only be defined for discrete variables

D. Quantiles measure only variance

Correct Answer: B. The 0.75 quantile has approximately 75% of the distribution at or below it

Question 10

A support centre models hourly requests with a single Poisson rate, but release periods create clustered arrivals. What is the most appropriate response?

A. Keep the model because the mean is sufficient

B. Replace all counts with continuous measurements

C. Investigate time-varying rates or an overdispersed count model

D. Assume the requests are uniformly distributed

Correct Answer: C. Investigate time-varying rates or an overdispersed count model

Statistics and Probability for Data Science
Chapter 3 of 15

Statistics and Probability for Data Science

Chapter 4
Joint Distributions and Dependence

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

4. Joint Distributions and Dependence

Introduction and Context

Many data-science questions concern more than one variable at a time. A retailer may study transaction value and customer age; a public-health researcher may examine exposure and disease status; a machine-learning engineer may investigate the joint behaviour of model errors and input characteristics. Analysing variables separately can conceal relationships that are essential for prediction, risk assessment, and decision-making. Joint distributions provide the mathematical framework for describing how two or more random variables behave together.

The ideas in this chapter extend the single-variable probability concepts introduced earlier. A marginal distribution describes one variable viewed in isolation, while a conditional distribution describes one variable given information about another. Covariance and correlation summarise certain forms of dependence, but they do not capture every important relationship. Conditional expectation, transformations, and mixture distributions provide more flexible tools for modelling and analysing multivariate data.

These concepts are central to statistical modelling. Regression, Bayesian inference, portfolio risk, classification, simulation, missing-data analysis, and probabilistic machine learning all rely on an understanding of joint and conditional behaviour. Equally important is knowing when a convenient summary, such as correlation, is insufficient or misleading.

Learning Objectives

After completing this chapter, the reader should be able to:

1. Define joint, marginal, and conditional distributions for discrete and continuous random variables.

2. Derive marginal distributions from joint distributions and calculate conditional probabilities or densities.

3. Explain independence and distinguish it from zero correlation.

4. Compute and interpret covariance, correlation, and conditional expectation.

5. Analyse transformations of random variables using suitable methods.

6. Explain mixtures and their effects on dependence and variability.

7. Identify limitations of correlation-based reasoning.

8. Apply these ideas to data-science and professional decision-making problems.

The Joint Distribution as a Description of Co-occurrence

Let X and Y be random variables defined on the same probability space. Their joint distribution describes probabilities associated with pairs of values occurring together. For discrete variables, the joint probability mass function (pmf) is

pX,Y(x,y) = P(X = x, Y = y).

It satisfies pX,Y(x,y) ≥ 0 and

Σx Σy pX,Y(x,y) = 1.

For continuous variables, the joint probability density function (pdf), fX,Y(x,y), is non-negative and satisfies

∫∫ fX,Y(x,y) dx dy = 1.

Probabilities are obtained by integrating over regions. For example,

P((X,Y) ∈ A) = ∬A fX,Y(x,y) dx dy.

A joint distribution contains more information than two separate distributions. Knowing that X is normally distributed and Y is normally distributed does not, by itself, determine how X and Y behave together. Different joint distributions can have the same marginal distributions but very different dependence structures.

A useful geometric interpretation is to regard (X,Y) as a random point in a plane. A joint density indicates where probability mass is concentrated. A narrow diagonal cloud suggests positive association, while an elongated cloud with negative slope suggests negative association. Curved or separated patterns may indicate dependence that a straight-line summary cannot represent.

Marginal Distributions

The marginal distribution of X is obtained by summing or integrating out Y. For discrete variables,

pX(x) = Σy pX,Y(x,y).

For continuous variables,

fX(x) = ∫ fX,Y(x,y)dy.

Similarly,

pY(y) = Σx pX,Y(x,y), fY(y) = ∫ fX,Y(x,y)dx.

The word marginal reflects the traditional practice of placing row and column totals in the margins of a probability table. Marginalisation is also fundamental in statistical computing: a variable that is not of immediate interest is integrated out while preserving uncertainty about the variable of interest.

Example: A Discrete Joint Distribution

Suppose X records the number of service requests received in an hour and Y records whether a response exceeds a specified time threshold. Consider the joint table:

Y = 0 Y = 1 Total

X = 0 0.30 0.05 0.35

X = 1 0.20 0.15 0.35

X = 2 0.05 0.25 0.30

Total 0.55 0.45 1.00

The marginal probability P(X=1) is 0.35, and P(Y=1) is 0.45. The probability that two or more requests occur and the response is delayed is P(X≥2,Y=1)=0.25. The table also suggests dependence: the conditional probability P(Y=1|X=2)=0.25/0.30=0.833, whereas P(Y=1)=0.45. Delays are more likely when the request count is two.

Conditional Distributions and the Logic of Information

A conditional distribution updates the distribution of one variable after the value or event involving another variable is known. For discrete variables,

P(Y=y|X=x) = pX,Y(x,y)/pX(x),

provided pX(x)>0. For continuous variables, the conditional density is

fY|X(y|x) = fX,Y(x,y)/fX(x),

provided fX(x)>0.

The joint distribution can be reconstructed from a marginal and a conditional distribution:

fX,Y(x,y) = fY|X(y|x)fX(x).

This factorisation is especially important in probabilistic modelling. It separates a baseline distribution for X from a model describing how Y changes when X changes. The alternative factorisation is fX,Y(x,y)=fX|Y(x|y)fY(y). Bayes’ theorem connects the two conditional directions:

fX|Y(x|y) = fY|X(y|x)fX(x)/fY(y).

Conditional probabilities must not be confused with joint probabilities. P(X=x,Y=y) concerns both events occurring together; P(Y=y|X=x) concerns the probability of Y after restricting attention to cases where X=x.

Independence

X and Y are independent if knowledge of one does not change the distribution of the other. For discrete variables,

pX,Y(x,y)=pX(x)pY(y)

for every x and y. For continuous variables,

fX,Y(x,y)=fX(x)fY(y)

almost everywhere.

Equivalent statements include P(Y∈B|X=x)=P(Y∈B) for relevant x and P(X∈A,Y∈B)=P(X∈A)P(Y∈B) for all measurable sets A and B. Independence is a strong condition. It implies zero covariance when the relevant moments exist, but zero covariance does not generally imply independence.

A common professional error is to infer independence from an absence of visible linear association. Independence concerns all aspects of the joint distribution, including nonlinear and tail behaviour.

Covariance, Correlation, and Dependence

Covariance measures the direction of joint linear variation:

Cov(X,Y)=E[(X−EX)(Y−EY)] = E[XY]−E[X]E[Y].

If large values of X tend to occur with large values of Y, covariance is typically positive. If large values of one tend to occur with small values of the other, it is typically negative. Covariance depends on measurement units: changing dollars to cents multiplies covariance by 100, while changing metres to centimetres affects it similarly.

The Pearson correlation coefficient standardises covariance:

ρX,Y = Cov(X,Y)/(σXσY),

provided both standard deviations are positive. It lies between −1 and 1. A value near 1 indicates strong positive linear association; a value near −1 indicates strong negative linear association; a value near 0 indicates little linear association.

Correlation is invariant to positive changes of scale and changes sign under a negative rescaling. It is therefore easier to compare across datasets than covariance. However, it remains a measure of linear association, not a complete measure of dependence.

Important Distinctions

If X and Y are independent, then Cov(X,Y)=0, assuming finite expectations and variances. The converse fails. For example, let X be uniformly distributed on [−1,1] and let Y=X². Y is completely determined by X, so the variables are dependent. Yet

E[X]=0,

E[XY]=E[X³]=0,

and therefore Cov(X,Y)=0.

The dependence is curved rather than linear. A scatterplot would reveal a U-shaped pattern, even though Pearson correlation is zero.

Correlation can also be distorted by outliers. A single unusual observation may substantially alter the means, standard deviations, and covariance. Restriction of range can reduce an observed correlation even when a relationship exists in the wider population. Aggregating data can produce a relationship different from the relationship within subgroups, a phenomenon associated with ecological bias and Simpson’s paradox.

Rank-based measures such as Spearman’s rho and Kendall’s tau can be useful when relationships are monotonic but not linear, or when variables are ordinal. They do not, however, automatically solve problems caused by confounding, selection, or non-monotonic dependence.

Conditional Expectation: Prediction with Partial Information

The conditional expectation of Y given X is the expected value of Y after X has been observed. For a discrete X,

E[Y|X=x] = Σy yP(Y=y|X=x).

For a continuous conditional density,

E[Y|X=x] = ∫ y fY|X(y|x)dy.

The expression E[Y|X] denotes a random variable: a function of X. It is the best mean-square predictor of Y based on X. More precisely, among all functions g(X), E[Y|X] minimises E[(Y−g(X))²]. This result explains why conditional expectation is central to regression and forecasting.

The law of total expectation states

E[Y] = E[E[Y|X]].

For variance, the law of total variance states

Var(Y)=E[Var(Y|X)] + Var(E[Y|X]).

The first term represents average variability remaining within groups defined by X. The second represents variability between conditional means. This decomposition is useful in hierarchical data, quality control, risk modelling, and analysis of variance.

Example: Conditional Risk

Suppose a loan applicant belongs to a risk group X, and Y is the eventual monetary loss. Even if the overall expected loss E[Y] is moderate, the conditional values E[Y|X=high] and E[Y|X=low] may differ substantially. A risk model that uses only the overall mean ignores information available from group membership. Conversely, if group membership is a proxy for a protected attribute, using it requires careful fairness and governance analysis.

Transformations of Random Variables

Data science frequently transforms variables: logarithms reduce skewness, ratios express rates, and principal components rotate coordinate systems. Probability theory must determine the distribution of transformed variables.

For a discrete transformation, probabilities are found by summing the probabilities of all original points that produce the transformed value. If U=g(X,Y), then

P(U=u)=Σ(x,y):g(x,y)=u pX,Y(x,y).

For continuous one-to-one transformations, let (U,V)=g(X,Y), with inverse (X,Y)=h(U,V). The change-of-variables formula is

fU,V(u,v)=fX,Y(x(u,v),y(u,v)) |J|,

where J is the determinant of the Jacobian matrix of the inverse transformation:

J = ∂(x,y)/∂(u,v).

The absolute value is required because densities describe non-negative probability volume.

Sum and Difference

If U=X+Y, deriving the distribution of U generally requires convolution. For continuous variables,

fU(u)=∫ fX,Y(x,u−x)dx.

If X and Y are independent, this becomes the familiar convolution of their marginal densities. Independence is therefore a simplifying assumption, not a requirement of the transformation method.

For U=X+Y and V=X−Y, the inverse is X=(U+V)/2 and Y=(U−V)/2. The Jacobian’s absolute determinant is 1/2, so the joint density of (U,V) is obtained by substituting these expressions and multiplying by 1/2.

Transformations can reveal structure that is hidden in the original scale. For instance, the logarithm converts multiplicative relationships into additive ones, while standardisation makes variables comparable in scale. Such transformations alter interpretation and can affect correlation, so they should be justified rather than applied mechanically.

Mixture Distributions and Hidden Groups

A mixture distribution arises when observations come from multiple subpopulations, but the subgroup label may be observed or unobserved. If Z is a latent group indicator with P(Z=k)=πk and conditional density fX|Z(x|k), then

fX(x)=Σk πk fX|Z(x|k).

The mean of a mixture is

E[X]=Σk πk E[X|Z=k],

and its variance is

Var(X)=E[Var(X|Z)] + Var(E[X|Z]).

A mixture may be multimodal, skewed, or heavy-tailed even when every component distribution is normal. In data science, Gaussian mixture models are used for clustering, density estimation, anomaly detection, and soft classification.

Mixtures also explain why aggregate correlations can be misleading. Suppose two groups each show a positive relationship between X and Y, but the group means are arranged so that the combined data show a negative relationship. The aggregate association then reflects both within-group association and between-group differences. This is one form of Simpson’s paradox.

A mixture is not the same as a single distribution with averaged parameters. If a population contains two groups with different means, the between-group component contributes to total variance. Ignoring that component can lead to underestimated uncertainty and inappropriate decisions.

An Illustrative Case Study: Predicting Customer Churn

Background

A subscription software company wants to identify customers at risk of cancelling. It has data on monthly usage X, customer-support contacts Y, contract type Z, and churn status. The analytics team initially reports that usage and support contacts have correlation close to zero.

Situation and Problem

Management interprets the near-zero correlation as evidence that usage and support needs are unrelated. It proposes excluding support contacts from the churn model. However, the data are a mixture of contract types, and the scatterplot appears to contain distinct groups.

Analysis

Within annual contracts, customers with high usage tend to contact support more frequently because they use advanced features. Within monthly contracts, high usage is associated with fewer support contacts because experienced users solve problems independently. When the groups are combined, the opposing slopes produce a weak overall correlation.

The team estimates conditional distributions rather than relying only on a single correlation. It examines P(churn=1|X,Y,Z), calculates group-specific conditional means, and compares the joint distribution of usage and support contacts by contract type. It also uses the law of total variance to distinguish variation within contract types from variation between them.

A logistic model is fitted with usage, support contacts, contract type, and an interaction between usage and contract type. A mixture-model diagnostic is used as an exploratory tool, not as proof that the population has exactly two natural clusters.

Approach and Outcome

The revised analysis shows that support contacts are informative after conditioning on contract type. The interaction indicates that the meaning of a support contact differs across customer groups. The company retains support history in the model but restricts its use to legitimate service-improvement purposes. Model performance is evaluated separately across contract types, and probability calibration is checked before operational deployment.

Learning Points

The case illustrates that a marginal correlation can conceal conditional dependence. Joint and conditional distributions provide a richer account of the data. Mixture structure and interactions should be investigated before variables are discarded. Finally, predictive usefulness does not by itself justify every possible use of a variable; governance and fairness remain part of the analysis.

Applications in Data Science and Professional Practice

Joint distributions underpin feature engineering, probabilistic graphical models, Bayesian networks, and simulation. In finance, the joint behaviour of asset returns is used for portfolio risk and stress testing. In healthcare, conditional distributions support diagnostic reasoning and treatment evaluation. In manufacturing, dependence between process variables can identify failure mechanisms. In marketing, customer attributes and responses are analysed jointly for segmentation and targeting.

In machine learning, a generative model estimates p(X,Y) or p(X|Y)p(Y), whereas a discriminative model focuses directly on p(Y|X). Missing-data methods require assumptions about the joint distribution of observed and unobserved variables. Monte Carlo simulation requires generating samples with the intended dependence structure; simulating each variable independently can severely understate joint risk.

Modern software makes calculation accessible, but it does not remove the need for statistical judgement. A covariance matrix may be estimated automatically, yet the analyst must assess sample size, outliers, missingness, non-stationarity, and whether a linear summary is appropriate. Visualising pairwise relationships, conditioning on important variables, and examining tails are essential complements to numerical summaries.

Limitations, Risks, and Common Mistakes

Several mistakes recur in applied work:

  • Treating correlation as evidence of causation. Association may arise from confounding, reverse causality, selection, or common time trends.
  • Treating zero correlation as independence. Nonlinear and tail dependence can remain.
  • Ignoring units and scale when interpreting covariance.
  • Using Pearson correlation automatically for ordinal, heavily skewed, or contaminated data.
  • Computing conditional probabilities with the wrong denominator.
  • Assuming that marginal normality implies joint normality. The dependence structure must also be specified.
  • Ignoring subgroup structure, producing misleading aggregate conclusions.
  • Estimating correlations from small samples without uncertainty intervals.
  • Treating a fitted mixture component as a real social or biological group without substantive evidence.
  • Confusing statistical prediction with a causal intervention.

Correlation matrices also have technical limitations. Pairwise estimates may be unstable, and a matrix assembled from different missing-data subsets may fail to be a valid positive-semidefinite covariance matrix. In high-dimensional settings, regularisation or dimensional reduction may be needed, but these methods introduce modelling choices that require validation.

Ethical and Governance Considerations

Dependence analysis can expose sensitive relationships involving health, income, location, or protected characteristics. Analysts should minimise unnecessary use of personal data, document data provenance, and control access to joint datasets. Conditional relationships can differ across demographic groups; reporting only aggregate results may hide unequal risks or service quality.

When a model uses conditional probabilities to make decisions, calibration and error rates should be examined across relevant groups. A correlation discovered in historical data may reflect past discrimination rather than a legitimate mechanism. Transparency about assumptions, uncertainty, and limitations is therefore part of professional statistical practice.

Emerging Directions and Best Practice

Dependence modelling is moving beyond Pearson correlation toward copulas, graphical models, nonlinear representation learning, and neural generative models. Copulas separate marginal behaviour from dependence, allowing analysts to combine non-normal marginals with flexible dependence structures. Vine copulas and normalising flows can model complex multivariate relationships, although they require substantial data and careful validation.

A sound workflow is to begin with the substantive question, inspect the data jointly, identify plausible subgroups and temporal structure, choose summaries appropriate to the measurement scale, and estimate uncertainty. Analysts should compare marginal, conditional, and joint views; test sensitivity to outliers and transformations; and validate conclusions on new data where possible. Interpretability and governance should be considered alongside predictive performance.

Chapter Summary

Joint distributions describe how random variables occur together. Marginal distributions are obtained by summing or integrating out variables, while conditional distributions update uncertainty using information about another variable. Independence factorises a joint distribution into marginals and implies zero covariance, but zero covariance does not imply independence.

Covariance measures unstandardised linear co-movement, and correlation standardises it to the interval [−1,1]. Neither captures all forms of dependence. Conditional expectation gives the best mean-square prediction based on available information and leads to the laws of total expectation and total variance. Transformations require summation, integration, convolution, or Jacobian methods. Mixture distributions represent heterogeneous populations and can create misleading aggregate associations. Effective data-science practice therefore combines mathematical summaries with visualisation, subgroup analysis, uncertainty assessment, domain knowledge, and ethical governance.

Key Terms

Joint distribution: The probability law describing two or more random variables together.

Joint pmf: The probability assigned to each combination of values of discrete variables.

Joint pdf: A density whose integrals over regions give probabilities for continuous variables.

Marginal distribution: The distribution of one variable obtained by summing or integrating out the others.

Conditional distribution: The distribution of one variable given information about another.

Independence: A relationship in which knowledge of one variable does not alter the distribution of another.

Covariance: The expected product of deviations of two variables from their means.

Correlation: Standardised covariance measuring linear association.

Conditional expectation: The expected value of a variable given observed information.

Law of total expectation: The identity E[Y]=E[E[Y|X]].

Law of total variance: The decomposition Var(Y)=E[Var(Y|X)]+Var(E[Y|X]).

Transformation: A new random variable created by applying a function to existing variables.

Jacobian: The determinant used to adjust density under a differentiable change of variables.

Convolution: The operation used to derive the distribution of a sum of random variables.

Mixture distribution: A distribution formed by combining component distributions with mixing probabilities.

Latent variable: An unobserved variable used to represent hidden structure.

Simpson’s paradox: A reversal or distortion of an association after data are aggregated across groups.

Nonlinear dependence: Dependence that is not adequately represented by a straight-line relationship.

Copula: A model separating marginal distributions from their dependence structure.

Review Questions

Short Answer Questions

1. How is a marginal density obtained from a joint density?

2. State the condition defining independence for two continuous random variables.

3. Why is covariance dependent on measurement units?

4. What does conditional expectation represent in prediction?

5. Distinguish a mixture distribution from a single distribution with averaged parameters.

Long Answer Questions

1. Explain the relationship among joint, marginal, and conditional distributions, including the relevant factorisations.

2. Discuss covariance and correlation, including their interpretation and limitations.

3. Derive and explain the laws of total expectation and total variance.

4. Describe the change-of-variables method for continuous random variables and explain the role of the Jacobian.

5. Explain how hidden subgroups can produce misleading aggregate associations, using Simpson’s paradox as a framework.

Analytical / Application Questions

1. Let X be uniformly distributed on [−1,1] and Y=X². Show that X and Y are dependent but uncorrelated. Explain why correlation fails in this example.

2. A bank observes that the overall correlation between income and loan default is weak. Propose an analysis using joint and conditional distributions that could reveal subgroup-specific risk.

3. A portfolio simulation generates each asset return independently, although historical data show substantial dependence during market downturns. Explain the likely risk consequences and propose a more appropriate modelling strategy.

22. Multiple Choice Questions with Answers

Question 1

For a continuous pair (X,Y), which expression gives the marginal density of X?

A. fX(x)=fX,Y(x,y)

B. fX(x)=∫ fX,Y(x,y)dy

C. fX(x)=∫ fY|X(y|x)dx

D. fX(x)=fY(y)fX,Y(x,y)

Correct Answer: B. fX(x)=∫ fX,Y(x,y)dy

Question 2

If X and Y are independent and have finite variances, which statement must hold?

A. Their correlation must equal 1

B. Their conditional means must be unequal

C. Their covariance must equal 0

D. Their joint distribution must be uniform

Correct Answer: C. Their covariance must equal 0

Question 3

Let Y=X² where X is symmetric about zero. Which conclusion is correct?

A. X and Y are independent

B. X and Y must have correlation 1

C. X and Y can be dependent but have zero covariance

D. Y must have a normal distribution

Correct Answer: C. X and Y can be dependent but have zero covariance

Question 4

What does E[Y|X] represent among all functions of X under squared-error loss?

A. The largest possible prediction error

B. The best mean-square predictor of Y

C. The marginal variance of Y

D. The probability that X equals Y

Correct Answer: B. The best mean-square predictor of Y

Question 5

Which identity correctly expresses the law of total variance?

A. Var(Y)=E[Y]+Var(X)

B. Var(Y)=E[Var(Y|X)]+Var(E[Y|X])

C. Var(Y)=Var(Y|X)−E[E[Y|X]]

D. Var(Y)=Cov(X,Y)²

Correct Answer: B. Var(Y)=E[Var(Y|X)]+Var(E[Y|X])

Question 6

When transforming a continuous random vector, why is the absolute Jacobian determinant used?

A. To ensure probabilities remain non-negative after volume changes

B. To force all variables to become independent

C. To remove the marginal densities

D. To guarantee a normal distribution

Correct Answer: A. To ensure probabilities remain non-negative after volume changes

Question 7

A weak aggregate correlation becomes strongly positive after conditioning on contract type. What is the most plausible explanation?

A. The variables cannot be jointly distributed

B. A subgroup or mixture structure was masking conditional dependence

C. Marginalisation always creates perfect correlation

D. Correlation is invariant to grouping

Correct Answer: B. A subgroup or mixture structure was masking conditional dependence

Question 8

Which statement about Pearson correlation is most accurate?

A. It detects every form of dependence

B. It is unaffected by extreme outliers

C. It measures standardised linear association

D. A value of zero proves independence

Correct Answer: C. It measures standardised linear association

Question 9

For a mixture distribution, total variance includes which components?

A. Only the variance within the first component

B. Average within-component variance and variance of component means

C. Only the variance of component probabilities

D. The covariance of unrelated variables only

Correct Answer: B. Average within-component variance and variance of component means

Question 10

A simulation generates two strongly dependent financial returns independently. What is a likely consequence?

A. Joint extreme losses may be underestimated

B. The marginal distributions become impossible

C. The returns necessarily become perfectly correlated

D. Conditional probabilities become irrelevant

Correct Answer: A. Joint extreme losses may be underestimated

Statistics and Probability for Data Science
Chapter 4 of 15

Statistics and Probability for Data Science

Chapter 5
Sampling Theory and Asymptotic Foundations

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

5. Sampling Theory and Asymptotic Foundations

Introduction and Context

Data science rarely has access to an entire population in a directly observable form. A population may consist of all customers of a bank, all transactions processed by a platform, all manufactured items produced during a year, or all possible future users of a digital service. Although a census of the population is conceptually attractive, it is often too expensive, slow, technically difficult, or impossible. Sampling provides a principled way to learn about a population from a manageable subset of observations.

Sampling theory supplies the bridge between data and inference. It explains how a sample should be selected, how sample statistics vary from one sample to another, and under what conditions those statistics provide reliable information about population parameters. The subject is therefore central to estimation, hypothesis testing, survey research, experimentation, quality control, and machine learning evaluation.

Two ideas are especially important. First, a sample statistic is itself a random quantity because it depends on the observations selected. Its probability distribution is called a sampling distribution. Second, as sample size increases, suitably defined estimators often become more stable and approximately normal. The law of large numbers and the central limit theorem formalize these ideas and provide the asymptotic foundations of scalable analytics.

The word “asymptotic” refers to the behavior of a procedure as the sample size becomes very large. Asymptotic reasoning does not claim that real datasets are infinite. Instead, it provides approximations that become increasingly accurate under stated assumptions. Understanding those assumptions is essential: a large dataset does not automatically eliminate bias, dependence, measurement error, or poor sampling design.

Learning Objectives

By the end of this chapter, students should be able to:

1. Distinguish populations, samples, parameters, statistics, and sampling frames.

2. Compare probability and non-probability sampling methods.

3. Explain sampling distributions and derive the standard error of common statistics.

4. Analyze the bias–variance trade-off in sampling and estimation.

5. State and interpret the law of large numbers and the central limit theorem.

6. Recognize the effects of dependence, clustering, nonresponse, and selection bias.

7. Apply sampling concepts to surveys, experiments, quality control, and large-scale analytics.

8. Evaluate the ethical, technical, and organizational consequences of sampling decisions.

The Population–Sample Relationship

A population is the complete set of units about which a researcher wishes to make a statement. The units may be people, firms, events, images, web sessions, or physical products. A target population is the conceptual population of interest, whereas the accessible population is the portion that can actually be reached. The difference matters. If a study intends to understand all citizens but samples only registered online users, its accessible population is narrower than its target population.

A sampling frame is the operational list or mechanism from which observations are selected. Examples include a customer database, a register of households, a list of manufactured components, or a stream of logged transactions. Coverage error arises when the frame excludes, duplicates, or incorrectly represents members of the target population.

A population characteristic is called a parameter. Common parameters include the population mean μ, variance σ², proportion p, and regression coefficient β. A sample statistic is computed from observed data, such as the sample mean X̄, sample variance S², sample proportion p̂, or estimated regression coefficient b. Parameters are usually fixed but unknown; statistics are observable but vary across samples.

This distinction is foundational. If repeated samples of equal size were drawn from the same population, their sample means would generally differ. Therefore, the uncertainty of an estimate cannot be assessed merely by inspecting one observed value. It must be understood through the distribution that the statistic would have across repeated samples.

Probability Sampling: Known Chances of Selection

In probability sampling, every population unit has a known, non-zero probability of selection, although the probabilities need not be equal. This requirement makes it possible to use probability theory to quantify sampling uncertainty and, with suitable weighting, to produce population-representative estimates.

Simple Random Sampling

In simple random sampling, every sample of a specified size has the same probability of being selected. If n units are drawn without replacement from a population of N units, each unit has inclusion probability n/N. Simple random sampling is conceptually clean and often serves as the benchmark for other designs.

For a sample mean under simple random sampling without replacement,

SE(X̄) = (σ/√n)√[(N − n)/(N − 1)],

where the second factor is the finite population correction. When the sampling fraction n/N is small, the correction is close to one and is often ignored. Increasing n reduces standard error at a rate proportional to 1/√n, not 1/n. Thus, obtaining four times as much precision generally requires approximately sixteen times the sample size only if precision is measured by halving the standard error; more exactly, quadrupling n halves the standard error.

Systematic Sampling

Systematic sampling selects units at a regular interval from an ordered frame. If the sampling interval is k, a random starting point is selected among the first k units, after which every kth unit is included. The method is operationally convenient, particularly for production lines or ordered records. However, periodic patterns in the frame can create serious bias if the interval aligns with an underlying cycle.

Stratified Sampling

In stratified sampling, the population is divided into relatively homogeneous subgroups called strata, and a sample is drawn from each stratum. Strata may be defined by region, age group, customer type, or risk category. Stratification can improve precision when units within strata are similar and strata differ from one another. It also guarantees representation of important subgroups.

Samples may be allocated proportionally or disproportionately. Disproportionate allocation may deliberately oversample a small but important group. Population estimates must then use appropriate weights; otherwise, the sample composition can distort the overall result.

Cluster and Multistage Sampling

Cluster sampling selects groups, or clusters, such as schools, hospitals, villages, or retail branches, and then surveys units within selected clusters. It is cost-effective when travel, administration, or data extraction is organized around groups. Its disadvantage is that observations within a cluster tend to be correlated. Consequently, the effective sample size may be much smaller than the nominal number of observations.

Multistage sampling combines stages, for example selecting regions, then branches, then customers. It is common in large surveys and distributed operational systems. Variance estimation must reflect all stages of selection rather than treating the final observations as a simple random sample.

Non-Probability Sampling and Its Consequences

Non-probability sampling does not provide a known selection probability for every population unit. Common forms include convenience sampling, purposive sampling, quota sampling, volunteer sampling, and respondent-driven or snowball recruitment.

Such methods may be appropriate when a sampling frame is unavailable, when research is exploratory, or when access to a specialized population is difficult. They are also common in product research and online experimentation. Their central limitation is that conventional sampling error cannot generally be calculated from the sample alone. A large convenience sample can be less representative than a small probability sample if the selection mechanism is related to the outcome.

For example, an online poll about public transport may attract people with unusually strong opinions or unusually frequent internet access. Increasing the number of respondents reduces random variation within the recruited group, but it does not necessarily correct systematic differences between respondents and nonrespondents. This distinction is often summarized as the difference between precision and accuracy.

Sampling Distributions and Standard Error

A sampling distribution is the probability distribution of a statistic over repeated samples drawn under a specified design. It is not the distribution of individual observations. The distribution of incomes in a population, for example, differs from the sampling distribution of the sample mean of income.

If observations X₁, …, Xn are independent and identically distributed with mean μ and variance σ², then

E(X̄) = μ,

Var(X̄) = σ²/n,

and

SE(X̄) = σ/√n.

Because σ is usually unknown, it is estimated by the sample standard deviation S, giving the estimated standard error S/√n. For a sample proportion p̂ based on independent Bernoulli observations,

E(p̂) = p,

Var(p̂) = p(1 − p)/n,

and the estimated standard error is √[p̂(1 − p̂)/n].

The standard error measures the expected variation of an estimator across repeated samples. It is not the standard deviation of the raw observations and not a guarantee that the estimate is close to the parameter. A biased procedure can have a small standard error while consistently missing the target.

Under appropriate regularity conditions, an approximate 95 percent interval for a parameter may be formed as estimate ± 1.96 × standard error. This familiar expression relies on an approximately normal sampling distribution and on a valid variance estimate. For complex survey designs, clustering and weighting require design-based variance estimators rather than the simple formula for independent observations.

Bias, Variance, and the Quality of an Estimator

Bias is the difference between the expected value of an estimator and the parameter it is intended to estimate:

Bias(θ̂) = E(θ̂) − θ.

Variance describes the estimator’s variability across repeated samples. Mean squared error combines both:

MSE(θ̂) = Var(θ̂) + [Bias(θ̂)]².

The bias–variance trade-off occurs because procedures designed to reduce variability may introduce systematic distortion, while highly flexible or poorly controlled procedures may reduce bias in one setting but increase variance. In sampling, a carefully designed stratified sample may lower variance, whereas undercoverage may introduce bias. In prediction, a simple model may be stable but systematically inadequate, while a complex model may fit the sample closely but generalize poorly.

It is useful to distinguish sampling bias from non-sampling errors. Sampling bias results from the selection mechanism. Nonresponse, inaccurate measurement, data processing errors, and changes in the population can also affect estimates. A census eliminates sampling variability but does not eliminate these other errors.

Design Effect and Effective Sample Size

When observations are correlated, the usual independent-observation standard error is too small. A common summary is the design effect:

DEFF = Var(actual estimator) / Var(estimator under simple random sampling).

For equal-sized clusters, a simplified expression is

DEFF ≈ 1 + (m − 1)ρ,

where m is the average cluster size and ρ is the intracluster correlation. The corresponding effective sample size is approximately n/DEFF. If DEFF equals four, a nominal sample of 1,000 observations may contain information comparable to only about 250 independent observations.

The Law of Large Numbers

The law of large numbers explains why averages stabilize as the amount of information increases. In its weak form, if X₁, X₂, … are independent and identically distributed with finite mean μ, then for every ε > 0,

P(|X̄n − μ| > ε) → 0 as n → ∞.

In words, the sample mean converges in probability to the population mean. The law justifies using averages to estimate long-run expectations, provided the data-generating conditions are suitable.

The law does not say that every large sample is representative of every population. It applies to observations generated according to the relevant probabilistic mechanism. If a sample is selected through a biased process, increasing its size may make the biased estimate more stable rather than more correct. Similarly, if observations are strongly dependent, heavy-tailed, or generated by a changing process, the usual version may not apply without modification.

In data engineering, the law of large numbers supports the monitoring of aggregate metrics such as conversion rates, average latency, defect rates, and expected revenue. Yet analysts must check whether the stream is stationary, whether repeated events from the same user dominate the data, and whether the metric is being measured consistently.

The Central Limit Theorem

The central limit theorem (CLT) provides a remarkably general approximation for the distribution of standardized sums or means. Under common conditions, if X₁, …, Xn are independent and identically distributed with finite mean μ and finite variance σ², then

√n(X̄n − μ)/σ → N(0, 1)

in distribution as n becomes large.

Equivalently, for sufficiently large n,

X̄n ≈ N(μ, σ²/n).

The CLT explains why normal approximations arise even when individual observations are not normally distributed. A population may be skewed or discrete, but averages of sufficiently many independent observations can have an approximately bell-shaped sampling distribution.

The required sample size is not universal. It depends on skewness, tail behavior, dependence, the statistic being studied, and the accuracy required. For a highly skewed distribution, a larger sample may be necessary. For a heavy-tailed distribution with infinite or poorly behaved variance, the classical CLT may be inaccurate or inapplicable. Resampling, robust methods, transformations, or specialized limit theorems may then be preferable.

The CLT is often misinterpreted. It does not state that the raw data become normal. It states that a suitably standardized aggregate statistic approaches a normal distribution. Nor does it imply that a large sample corrects selection bias. Normality of the sampling distribution concerns uncertainty; representativeness concerns validity of the target being estimated.

Resampling as an Empirical Alternative

When analytical sampling distributions are difficult to derive, resampling methods provide practical approximations. In the nonparametric bootstrap, observations are sampled with replacement from the observed dataset, and the statistic is recomputed for each resample. The empirical distribution of the repeated statistics approximates the sampling distribution.

The bootstrap can estimate standard errors, confidence intervals, and bias for means, medians, regression coefficients, and many machine-learning metrics. It is especially useful when the statistic has a complicated form. However, the ordinary bootstrap assumes that the observed data adequately represent the population and that the resampling units are appropriate. For time series, clustered data, or survey samples, block, cluster, or design-based bootstrap methods may be needed.

The bootstrap is not a remedy for a defective sampling frame. Resampling a biased sample reproduces its selection structure. It estimates uncertainty conditional on the observed data, not necessarily total error relative to the target population.

Applications in Data Science and Organizations

Sampling appears throughout the data lifecycle. During data collection, it reduces the cost of surveys, labeling, experiments, and quality inspection. During model development, a sample may be used to train or validate an algorithm when the full data repository is too large. During monitoring, sampled events can estimate service-level metrics while reducing storage and processing requirements.

In A/B testing, random assignment creates comparable treatment groups and permits causal interpretation under appropriate assumptions. The number of users required depends on baseline variability, minimum detectable effect, desired power, and significance level. Repeatedly checking results and stopping when a favorable value appears can inflate false-positive risk unless sequential methods are used.

In fraud detection, rare-event sampling may be necessary because fraud cases are uncommon. Deliberate oversampling can improve model training, but predicted probabilities and business-level estimates may require recalibration to reflect the real prevalence. In manufacturing, stratification by machine, shift, or raw-material batch may reveal localized defects hidden by an overall average.

For scalable analytics, sampling can reduce computational cost in exploratory queries, approximate dashboards, and distributed model training. A uniform sample may be acceptable for estimating a global mean but unsuitable for rare subgroups or tail quantiles. Sampling design should therefore follow the decision objective. If the organization must estimate a 99.9th-percentile response time, sampling only typical requests can be seriously misleading.

Illustrative Case Study: Estimating Customer Churn from a Large Platform

Background

A subscription platform has 20 million active accounts and wants to estimate the proportion of customers likely to cancel during the next quarter. A full customer survey is expensive, and the analytics team proposes an online questionnaire distributed through an in-app banner.

Situation and Problem

The banner is shown to a simple operational sample of 200,000 active accounts, but only 18,000 customers respond. The resulting estimated churn intention is 14 percent. Management asks whether this figure can be reported as the churn rate for all customers.

Analysis

The first issue is nonresponse. Respondents may differ from nonrespondents in engagement, satisfaction, language, device access, or likelihood of cancellation. The response rate alone does not determine bias, but it signals that the observed sample is not automatically representative.

The second issue is construct validity. Stated intention to cancel is not identical to actual cancellation. The organization must link responses to subsequent behavior while respecting privacy and consent requirements.

The third issue is subgroup structure. Churn may vary substantially by subscription plan, region, tenure, and customer-support history. A simple respondent average can overrepresent groups more likely to see or complete the questionnaire.

Approach and Solution

The team first defines the target population and constructs strata based on plan, region, tenure, and recent activity. It compares response rates across strata and calculates nonresponse-adjustment weights using known population totals. The weighted estimate is then calibrated against observed historical churn where comparable cohorts exist.

For uncertainty estimation, the team uses a survey-weighted variance procedure rather than treating the 18,000 respondents as a simple random sample. It also reports subgroup estimates and sensitivity analyses under alternative assumptions about nonrespondents. A separate probability sample of customers is contacted through multiple channels to assess whether the in-app survey has systematic coverage problems.

To predict actual churn, the analysts use the survey responses as features in a validated model, evaluate calibration on a later cohort, and distinguish predictive performance from population prevalence estimation. The model is monitored for differential error across customer groups.

Outcome

The organization does not publish the unadjusted 14 percent figure. Instead, it reports a weighted estimate with an uncertainty interval, describes the assumptions behind adjustment, and presents separate estimates for important segments. The predictive model is used to prioritize retention interventions, while causal testing is used to determine whether those interventions reduce cancellations.

Learning Points

A large respondent count cannot compensate for a selection mechanism related to the outcome. Weighting can reduce known composition differences but cannot guarantee removal of nonresponse bias. Sampling, measurement, prediction, and causal evaluation are distinct tasks. Sound decision-making requires identifying which quantity is being estimated and designing the data process around that quantity.

Limitations, Risks, and Common Mistakes

Several errors recur in professional sampling practice. Treating a convenient dataset as a random sample is perhaps the most consequential. Analysts also confuse the standard deviation of observations with the standard error of an estimate, ignore clustering, use inappropriate weights, and report confidence intervals without explaining the sampling design.

Another mistake is equating statistical significance with practical importance. A very large sample can make a trivial difference statistically significant. Conversely, a meaningful effect may be estimated imprecisely in a small or highly variable sample.

Analysts should be cautious with extremely large datasets. Big data can contain duplicate records, automated activity, feedback loops, and systematic missingness. It may represent platform behavior rather than the broader population. Data volume improves precision only for the process actually observed.

Heavy-tailed outcomes create additional difficulties. A few extreme observations can dominate means and produce unstable variance estimates. Median-based summaries, trimmed means, robust standard errors, transformations, or explicit tail modeling may be more appropriate.

Ethical, Governance, and Professional Considerations

Sampling decisions affect whose experiences become visible in organizational decisions. Excluding people without reliable internet access, underrepresenting minority groups, or oversampling easily reachable customers can produce unequal service quality and unfair resource allocation. Ethical practice therefore requires attention to coverage, inclusion, privacy, consent, and the consequences of error.

Data minimization should guide collection: analysts should sample and retain only information necessary for the stated purpose. Sensitive attributes may be needed to audit representativeness and fairness, but access must be governed carefully. Documentation should record the target population, frame, selection method, inclusion probabilities, weights, response rates, missing-data treatment, and uncertainty calculations.

In regulated settings, estimates used for credit, employment, healthcare, insurance, or public services may require reproducible procedures and evidence that affected groups were not systematically excluded. Transparency about uncertainty is a professional obligation, not merely a presentation preference.

Contemporary Developments and Best Practice

Modern data platforms increasingly support approximate query processing, reservoir sampling, distributed sketching, and streaming summaries. These techniques make it possible to estimate large-scale metrics with bounded memory or reduced computation. Their statistical guarantees depend on the sampling design and on whether the stream is changing over time.

Machine-learning systems also use active sampling, where observations are selected because they are informative for labeling or model improvement. Active sampling can be highly efficient, but the resulting data are not automatically representative. Importance weighting, exploration policies, and evaluation on an unbiased holdout set help separate learning efficiency from population estimation.

A sound sampling workflow should:

  • define the target population and estimand before collecting data;
  • inspect the sampling frame for coverage and duplication;
  • choose a probability design when population inference is required;
  • document inclusion probabilities and apply justified weights;
  • account for clustering, stratification, finite populations, and nonresponse;
  • distinguish bias, variance, measurement error, and model error;
  • use simulation or resampling to assess finite-sample behavior;
  • report uncertainty, sensitivity analyses, and subgroup performance;
  • monitor whether the data-generating process changes over time.

Chapter Summary

Sampling theory explains how information from a subset can support conclusions about a population. Probability sampling provides known selection probabilities and a foundation for design-based uncertainty, while non-probability sampling may be useful operationally but is vulnerable to unknown selection bias. Sampling distributions describe the repeated-sample behavior of statistics, and standard errors quantify their variability.

Bias and variance are distinct components of estimation quality, jointly summarized by mean squared error. The law of large numbers explains the stabilization of averages under suitable conditions, whereas the central limit theorem supports normal approximations for many standardized aggregate statistics. Neither theorem removes selection bias or dependence. Clustered designs, nonresponse, heavy tails, and changing data-generating processes require additional care.

In data science, sampling affects surveys, experiments, model training, monitoring, fraud analytics, quality control, and scalable computation. Responsible practice requires a clearly defined estimand, a defensible sampling process, appropriate variance estimation, transparent documentation, and attention to fairness and privacy.

Key Terms

Population: The complete set of units about which inference is intended.

Target population: The conceptual population to which conclusions are meant to apply.

Sampling frame: The operational list or mechanism from which a sample is selected.

Sample: A subset of units observed from a population or accessible frame.

Parameter: A fixed numerical characteristic of a population.

Statistic: A numerical quantity calculated from sample data.

Probability sampling: Sampling in which each unit has a known, non-zero selection probability.

Non-probability sampling: Sampling in which selection probabilities are unknown or not defined by design.

Sampling distribution: The probability distribution of a statistic over repeated samples.

Standard error: The standard deviation of an estimator’s sampling distribution.

Sampling bias: Systematic deviation caused by the selection mechanism.

Nonresponse bias: Bias arising when participation is related to the outcome or relevant characteristics.

Finite population correction: An adjustment reducing variance when a substantial fraction of a finite population is sampled.

Design effect: The ratio of actual estimator variance to variance under a reference simple-random design.

Effective sample size: The size of an independent random sample with approximately equivalent information.

Law of large numbers: A result stating that sample averages converge to the population mean under suitable conditions.

Central limit theorem: A result describing the approximate normality of standardized sums or means under suitable conditions.

Bootstrap: A resampling method used to approximate a statistic’s sampling distribution.

Estimand: The precise population quantity a study seeks to estimate.

Mean squared error: The sum of an estimator’s variance and squared bias.

Review Questions

Short Answer Questions

1. Distinguish a target population from a sampling frame.

2. What is a sampling distribution, and why is it different from the distribution of raw observations?

3. Define standard error and explain how it differs from standard deviation.

4. State the law of large numbers in practical terms.

5. Why can a large convenience sample remain biased?

Long Answer Questions

1. Compare simple random, stratified, cluster, and systematic sampling, including an appropriate use case for each.

2. Explain the bias–variance trade-off and relate it to mean squared error.

3. Present the central limit theorem, discuss its assumptions, and explain two common misinterpretations.

4. Explain how clustering affects standard errors and effective sample size.

5. Discuss how sampling theory supports scalable analytics while preserving statistical validity.

Analytical / Application Questions

1. A company samples 10,000 transactions from a stream in which 80 percent come from five large customers. Explain why the sample may not support inference about all customers and propose a better design.

2. A survey estimate has a small standard error but is based on an online volunteer sample. Analyze what can and cannot be concluded from the reported precision.

3. An experiment reports a statistically significant improvement after repeated interim analyses. Identify the inferential risk and recommend a more defensible analysis strategy.

22. Multiple Choice Questions with Answers

Question 1

Which statement best distinguishes a parameter from a statistic?

A. A parameter is calculated from a sample, whereas a statistic describes a population.

B. A parameter describes a population, whereas a statistic is calculated from sample data.

C. A parameter always has greater variance than a statistic.

D. A parameter is necessarily unknown, whereas a statistic is necessarily known before sampling.

Correct Answer: B. A parameter describes a population, whereas a statistic is calculated from sample data.

Question 2

A researcher wants every major customer segment represented and expects customers within each segment to be relatively similar. Which design is most appropriate?

A. Stratified sampling

B. Convenience sampling

C. Simple systematic sampling without checking the frame

D. Volunteer sampling

Correct Answer: A. Stratified sampling

Question 3

What does the standard error of a sample mean primarily measure?

A. The spread of individual observations around the sample mean

B. The expected variation of the sample mean across repeated samples

C. The bias caused by an incomplete sampling frame

D. The proportion of missing observations

Correct Answer: B. The expected variation of the sample mean across repeated samples

Question 4

If independent observations have finite variance and the sample size is quadrupled, the standard error of the sample mean is approximately:

A. Doubled

B. Unchanged

C. Halved

D. Reduced to one-fourth

Correct Answer: C. Halved

Question 5

Which conclusion follows from the law of large numbers under its usual assumptions?

A. Every large sample is representative of every target population.

B. The sample average converges in probability to the population mean.

C. Raw observations become normally distributed as sample size increases.

D. Sampling bias disappears when the sample is sufficiently large.

Correct Answer: B. The sample average converges in probability to the population mean.

Question 6

The central limit theorem primarily concerns the behavior of:

A. Individual observations in the population

B. The sampling distribution of suitably standardized sums or means

C. The sampling frame before data collection

D. The response rate of a survey

Correct Answer: B. The sampling distribution of suitably standardized sums or means

Question 7

A survey samples many people from the same school, producing correlated responses. If the analyst treats all responses as independent, the reported standard error will most likely be:

A. Too large

B. Too small

C. Exactly unbiased in every case

D. Equal to the population standard deviation

Correct Answer: B. Too small

Question 8

Which statement about a large non-probability sample is most accurate?

A. Its large size guarantees unbiased population estimates.

B. Its standard error automatically captures selection bias.

C. It may have high precision for the recruited group while remaining biased for the target population.

D. It is equivalent to a stratified random sample.

Correct Answer: C. It may have high precision for the recruited group while remaining biased for the target population.

Question 9

In the illustrative churn case, why was weighting alone not treated as a complete solution?

A. Weights always increase sampling bias.

B. Weighting cannot address any differences between subgroups.

C. Weighting can adjust known composition differences but cannot guarantee removal of nonresponse bias.

D. Weights prevent the calculation of uncertainty intervals.

Correct Answer: C. Weighting can adjust known composition differences but cannot guarantee removal of nonresponse bias.

Question 10

If a clustered sampling design has a design effect of four and a nominal sample size of 1,000, the approximate effective sample size is:

A. 40

B. 250

C. 996

D. 4,000

Correct Answer: B. 250

Statistics and Probability for Data Science
Chapter 5 of 15

Statistics and Probability for Data Science

Chapter 6
Statistical Estimation and Uncertainty

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

6. Statistical Estimation and Uncertainty

Introduction and context

Data science rarely has access to an entire population. Instead, analysts observe a sample and use it to learn about unknown features of the population, such as an average transaction value, a failure probability, a regression coefficient, or the proportion of customers likely to churn. Statistical estimation provides the formal language and methods for making such inferences.

An estimate is not the parameter itself. It is evidence-based information about the parameter, produced under assumptions about how the data were generated. Consequently, a responsible data scientist must communicate both an estimate and the uncertainty surrounding it. A sample mean of 72.4 may be useful, but its interpretation changes substantially if the associated interval is (71.9, 72.9) rather than (55, 90).

This chapter develops point and interval estimation, with particular attention to the method of moments and maximum likelihood. It also examines likelihood, sufficiency, consistency, efficiency, confidence intervals, bootstrap methods, and practical communication of uncertainty. These ideas connect probability models with statistical decision-making and form a foundation for inference, experimentation, predictive modelling, and risk analysis.

Learning objectives

By the end of this chapter, you should be able to:

1. Distinguish parameters, statistics, estimators, estimates, and pivotal quantities.

2. Construct estimators using the method of moments and maximum likelihood.

3. Interpret likelihood functions without confusing them with probability distributions for parameters.

4. Assess estimators using bias, variance, mean squared error, consistency, efficiency, and sufficiency.

5. Construct and interpret confidence intervals, including bootstrap intervals.

6. Explain how sample size, variability, and confidence level affect interval width.

7. Recognise assumptions, sources of uncertainty, and common inferential errors.

8. Communicate statistical uncertainty clearly in professional and managerial settings.

From a sample to an unknown parameter

Let X1, X2, ..., Xn denote observations from a population described by a model with unknown parameter θ. A statistic T(X1, ..., Xn) is any function of the observed data that does not depend on unknown quantities. When a statistic is designed to provide information about θ, it is called an estimator and is often written as θ-hat. Once data have been observed, the numerical value of the estimator is called an estimate.

For example, if customer spending is modelled with population mean μ, the sample mean X-bar is an estimator of μ. Before observing data, X-bar is a random variable and has a sampling distribution. After observing the sample, X-bar may equal 72.4; this is the estimate.

A parameter is fixed but unknown within a specified model, whereas an estimator varies from sample to sample. This distinction is essential. An estimate can be close to the parameter in one sample and less accurate in another, even when the same method is used.

Sampling distributions

The sampling distribution of an estimator describes its behaviour over repeated samples from the same population. It is the basis for measuring uncertainty. If observations are independent with mean μ and variance σ², then the sample mean has

E(X-bar) = μ and Var(X-bar) = σ²/n.

Thus, increasing the sample size reduces the variance of the sample mean, although it does not automatically remove bias caused by poor sampling or model misspecification. Under suitable regularity conditions, the central limit theorem implies that a suitably standardised sample mean is approximately normal for sufficiently large n. The phrase “sufficiently large” depends on the population distribution, skewness, dependence, and the purpose of the analysis.

Constructing estimators

Method of moments

The method of moments matches sample moments with corresponding population moments. The first population moment is E(X), the second is E(X²), and so forth. If a model has one unknown parameter, the first sample moment is usually equated to the first population moment. For p unknown parameters, p equations are formed using the first p moments.

Suppose X follows a Poisson distribution with parameter λ. Since E(X) = λ, the method-of-moments estimator is

λ-hat = X-bar.

As another example, suppose a uniform distribution on (0, θ) is assumed. Its mean is θ/2. Equating the sample mean to θ/2 gives

θ-hat-MM = 2X-bar.

The method is computationally simple and often provides a useful starting value for more sophisticated estimation. However, moment estimators may be inefficient, may not respect parameter constraints in unusual settings, and need not have desirable small-sample properties.

Maximum likelihood estimation

Maximum likelihood selects the parameter value under which the observed data are most plausible. For observations x1, ..., xn with joint density or probability mass function f(x1, ..., xn; θ), the likelihood is

L(θ; x) = f(x1, ..., xn; θ),

viewed as a function of θ with the data held fixed. The maximum likelihood estimator is the value θ-hat that maximises L(θ; x). In practice, analysts usually maximise the log-likelihood

l(θ) = log L(θ; x),

because products become sums and numerical calculations become more stable.

Consider independent Bernoulli observations Xi with success probability p. The likelihood is

L(p) = p raised to the number of successes times (1-p) raised to the number of failures.

The log-likelihood is maximised at p-hat = X-bar, the observed proportion of successes. Thus, the sample proportion is the maximum likelihood estimator of a Bernoulli probability.

For independent observations from a normal distribution with unknown mean μ and known variance σ², maximising the likelihood yields μ-hat = X-bar. If both μ and σ² are unknown, the maximum likelihood estimator of μ remains X-bar, while the maximum likelihood estimator of variance is

σ²-hat-MLE = (1/n) sum (Xi - X-bar)².

This differs from the unbiased sample variance, which divides by n-1. The MLE is biased downward for finite n, but the bias tends to zero as n increases.

Likelihood and log-likelihood in practice

Likelihood is relative evidence about parameter values given the observed data. It is not a probability distribution over θ unless a prior distribution is introduced in a Bayesian model. Comparing L(θ1) and L(θ2) indicates how much more compatible the data are with one parameter value than another under the assumed model.

The score function is the derivative of the log-likelihood, U(θ) = d l(θ)/dθ. A solution to U(θ) = 0 is a candidate maximum, but it must be checked against boundaries and the curvature of the likelihood. The observed information is the negative second derivative of the log-likelihood. Greater curvature near the maximum generally indicates more precise estimation.

In data science, likelihood optimisation underlies logistic regression, Poisson regression, survival models, mixture models, and many machine-learning procedures. Numerical methods such as Newton–Raphson, quasi-Newton optimisation, and expectation-maximisation may be required when a closed-form solution is unavailable.

How estimators are evaluated

No single property completely characterises an estimator. Evaluation requires considering both statistical performance and the practical consequences of errors.

Bias and variance

The bias of an estimator T for θ is

Bias(T) = E(T) - θ.

An unbiased estimator has expected value equal to θ. Unbiasedness is attractive, but it is not always essential. A biased estimator with much smaller variance may have lower overall error.

The mean squared error is

MSE(T) = E[(T - θ)²] = Var(T) + Bias(T)².

This decomposition expresses the bias–variance trade-off. In predictive analytics, reducing variance through regularisation may introduce a small bias while substantially improving generalisation. In estimation, the appropriate criterion depends on the cost of different errors and the intended use of the estimate.

Consistency

An estimator Tn is consistent for θ if it converges in probability to θ as sample size increases. Informally, repeated estimation with increasingly large samples becomes increasingly concentrated around the true parameter. Consistency is an asymptotic property; it does not guarantee good performance at a particular sample size.

For example, under independent sampling with finite variance, X-bar is consistent for μ because its variance decreases as n increases. An estimator can be biased in finite samples and still be consistent if its bias disappears and its variability shrinks with n.

Efficiency

When comparing unbiased estimators of the same parameter, an estimator with smaller variance is generally considered more efficient. The Cramér–Rao lower bound gives a theoretical lower bound on the variance of unbiased estimators under regularity conditions:

Var(T) is at least 1 divided by the Fisher information.

The Fisher information measures how much information the sample contains about θ. For independent observations, information commonly adds across observations. Maximum likelihood estimators are often asymptotically efficient: for large samples, their variance approaches the lowest achievable variance under the model.

Efficiency should not be interpreted mechanically. A highly efficient estimator under a badly specified model can be misleading. Robustness, interpretability, computational cost, and sensitivity to outliers may matter more than a small theoretical variance advantage.

Sufficiency

A statistic S(X) is sufficient for θ if, after observing S(X), the remaining details in the sample provide no additional information about θ. The factorisation theorem provides a practical criterion: if the joint likelihood can be written as

f(x; θ) = g(S(x), θ)h(x),

where h does not depend on θ, then S is sufficient.

For independent Bernoulli observations, the total number of successes is sufficient for p. For a normal sample with known variance, the sample mean is sufficient for μ. Sufficiency supports data reduction, though it does not imply that a statistic is unbiased, efficient in every sense, or appropriate when the model is wrong.

Interval estimation and confidence

A point estimate alone hides sampling variability. An interval estimator gives a range of plausible values produced by a stated procedure. A 95% confidence interval is a procedure that, under repeated sampling and valid assumptions, contains the fixed parameter in approximately 95% of constructed intervals.

The frequentist interpretation is often misunderstood. After an interval has been calculated, the parameter is not assigned a 95% probability of lying inside that particular interval in the frequentist framework. The 95% refers to the long-run coverage of the method. Statements such as “we are 95% confident” are acceptable practical shorthand if the procedure and assumptions are understood.

Normal-based intervals

If the population standard deviation σ is known and the population is normal, a confidence interval for μ is

X-bar plus or minus z_(α/2) σ divided by square root of n,

where 1 − α is the confidence level. When σ is unknown and the population is normal, the t distribution is used:

X-bar plus or minus t_(α/2,n−1) s divided by square root of n.

The t distribution has heavier tails than the standard normal distribution, particularly for small samples, reflecting additional uncertainty from estimating σ. As n increases, the t distribution approaches the standard normal distribution.

For a proportion p, the simple Wald interval p-hat plus or minus z times the estimated standard error can perform poorly with small samples or probabilities near zero or one. Wilson or exact methods are often preferable. A data scientist should select an interval method based on the sampling design and model, not merely because it is familiar.

Bootstrap confidence intervals

When an analytic sampling distribution is difficult to derive, the bootstrap approximates it by repeatedly resampling observations with replacement from the observed sample. For each resample, the statistic is recalculated. The resulting empirical distribution approximates the sampling distribution of the statistic.

A percentile bootstrap interval takes selected quantiles of the bootstrap estimates. Other methods, such as bias-corrected and accelerated intervals, adjust for skewness and bias. Bootstrap methods are powerful but not magical: they can fail when the sample is unrepresentative, observations are dependent, the statistic is unstable, or the sample is too small to reflect the population.

Width, precision, and sample size

The width of an interval is influenced by variability, sample size, and confidence level. For a mean, the standard error is proportional to 1 divided by the square root of n. Therefore, reducing the standard error by half generally requires approximately four times as many independent observations. A higher confidence level produces a wider interval, while lower variability produces a narrower interval.

Precision is not the same as accuracy. A narrow interval can be precisely wrong when systematic bias, selection bias, measurement error, dependence, or model misspecification is ignored. Uncertainty communication must therefore distinguish sampling uncertainty from other sources of uncertainty.

A practical workflow for estimation

A defensible estimation analysis usually follows these stages:

1. Define the target parameter and the population to which the conclusion will apply.

2. Clarify the sampling process, unit of analysis, measurement scale, and dependence structure.

3. Choose a probability model or a robust alternative, documenting assumptions.

4. Construct a point estimator using moments, likelihood, or another justified method.

5. Evaluate bias, variance, consistency, efficiency, and sensitivity where relevant.

6. Quantify uncertainty using an appropriate analytical, bootstrap, or simulation-based interval.

7. Diagnose outliers, influential observations, missingness, and model misfit.

8. Report the estimate, interval, sample size, method, assumptions, and practical meaning.

This workflow prevents the common mistake of treating estimation as a purely computational task. The validity of an interval depends at least as much on how data were collected and modelled as on the formula used to calculate it.

Illustrative case: estimating service reliability

Background

A cloud-service provider monitors 400 randomly selected service requests to estimate the probability p that a request completes without a critical error. Of the requests, 376 are successful.

Situation and analysis

The natural point estimate is p-hat = 376/400 = 0.94. Under an independent Bernoulli model, the estimated standard error is approximately the square root of p-hat(1 − p-hat)/n, which is about 0.0119. A 95% normal approximation interval is therefore approximately 0.94 plus or minus 1.96(0.0119), or (0.917, 0.963).

However, the analyst investigates the data-generating process before publishing this result. Requests were sampled across time, but several requests came from the same customer session. This clustering violates the simple independence assumption and may make the interval too narrow. The analyst also discovers that automated retries were counted as successful completions, although the service-level agreement defines success as completion on the first attempt.

Approach and solution

The team revises the definition of success, removes duplicate retry records according to a pre-specified rule, and uses a cluster-robust or session-level analysis. A bootstrap that resamples sessions rather than individual requests is used as a sensitivity analysis. The report presents the revised estimate and interval, explains the sampling unit, and separately reports first-attempt and eventual-success rates.

Outcome

The original estimate appeared highly precise but answered an ambiguous question and understated uncertainty. The revised analysis produced a more defensible measure for operational decisions, even though its interval was wider.

Learning points

The case illustrates that an estimator is inseparable from the estimand, sampling design, and measurement definition. A narrower interval is not automatically better. Transparent reporting of uncertainty can lead to better resource planning, more credible service commitments, and fewer disputes between technical and managerial teams.

Common errors, limitations, and professional responsibilities

Several errors recur in applied estimation. Analysts may confuse an estimate with a parameter, interpret a confidence level as a posterior probability, use a normal approximation with a very small or extreme sample, or report excessive decimal places. They may also ignore dependence, treat nonresponse as random without evidence, or calculate a highly precise interval from biased data.

Model selection creates another risk. Maximum likelihood is conditional on the assumed likelihood. If the distribution, independence assumption, or link function is inappropriate, optimisation can produce a precise estimate of the wrong quantity. Sensitivity analysis using alternative models, robust standard errors, resampling schemes, or simulation is therefore valuable.

Ethically, uncertainty should not be hidden when estimates affect individuals or groups. Credit limits, fraud alerts, medical prioritisation, and employee evaluations may rely on estimated probabilities. Decision-makers should know the uncertainty, relevant subgroup performance, data limitations, and consequences of false positives and false negatives. Privacy-preserving aggregation may also be necessary when releasing estimates from sensitive data. Governance should include reproducible code, versioned datasets, documented assumptions, and an audit trail for changes to estimands or models.

Technology and emerging practice

Statistical software makes estimation accessible through optimisation libraries, resampling frameworks, probabilistic programming, and automated reporting. Automatic differentiation enables efficient likelihood optimisation in complex models. Bayesian computation, including Markov chain Monte Carlo and variational inference, extends uncertainty analysis by representing uncertainty about parameters with probability distributions; however, these methods require prior specification and diagnostics.

Modern machine-learning systems increasingly use conformal prediction, calibrated probabilities, and distribution-free or weak-assumption intervals to quantify predictive uncertainty. These tools address uncertainty about future observations rather than only uncertainty about a population parameter. Their guarantees depend on assumptions such as exchangeability and may weaken under distribution shift. The distinction between parameter uncertainty, sampling uncertainty, measurement uncertainty, and predictive uncertainty should remain explicit.

Best practices for communicating uncertainty

A professional report should state what was estimated, for which population, from what sample, using which method. It should present the point estimate and interval together, use units and meaningful rounding, and explain the practical implication. Charts should show interval bars or bands where appropriate rather than displaying estimates alone.

Avoid claims such as “there is a 95% chance that the true value is in this interval” unless using a Bayesian interpretation with a clearly specified posterior. Avoid describing a non-significant result as proof of no effect; a wide interval may simply indicate insufficient information. Finally, distinguish statistical significance from practical importance. An estimate can be statistically distinguishable from zero yet operationally trivial, while a practically important effect may be estimated too imprecisely to reach a conventional threshold.

Chapter Summary

Statistical estimation uses sample data to learn about unknown population parameters. Point estimators such as the sample mean, method-of-moments estimators, and maximum likelihood estimators provide numerical summaries, while confidence intervals and bootstrap procedures quantify sampling uncertainty. Estimators should be assessed through bias, variance, mean squared error, consistency, efficiency, and sufficiency rather than by a single criterion. Likelihood measures relative compatibility of parameter values with observed data, and log-likelihood simplifies computation. Interval width depends on variability, sample size, and confidence level, but precision does not guarantee accuracy when data or models are biased. Sound professional practice requires explicit estimands, appropriate sampling assumptions, sensitivity analysis, transparent uncertainty communication, and ethical attention to the consequences of statistical decisions.

Key Terms

Parameter: A fixed but unknown numerical characteristic of a population or probability model.

Statistic: A function of observed data that does not depend on unknown parameters.

Estimator: A statistic intended to estimate an unknown parameter.

Estimate: The numerical value obtained when an estimator is applied to observed data.

Sampling distribution: The probability distribution of a statistic over repeated samples.

Bias: The difference between an estimator’s expected value and the parameter it estimates.

Variance: A measure of the dispersion of an estimator across repeated samples.

Mean squared error: The expected squared difference between an estimator and its target, equal to variance plus squared bias.

Consistency: The property of converging in probability to the target parameter as sample size increases.

Efficiency: Relative precision of an estimator, commonly assessed through variance under comparable conditions.

Sufficiency: The property whereby a statistic retains all sample information relevant to a parameter under a model.

Likelihood: A function expressing the relative compatibility of parameter values with observed data.

Log-likelihood: The logarithm of the likelihood, usually maximised for computational convenience.

Maximum likelihood estimator: The parameter value that maximises the likelihood of the observed data.

Method of moments: An estimation method that equates sample moments with population moments.

Confidence interval: An interval produced by a procedure designed to achieve stated long-run coverage.

Standard error: The standard deviation of an estimator’s sampling distribution, or its estimate.

Bootstrap: A resampling method that approximates sampling variability using repeated samples from observed data.

Fisher information: A measure of the information a sample contains about an unknown parameter.

Estimand: The precisely defined population quantity that an analysis seeks to estimate.

Review Questions

Short Answer Questions

1. Distinguish an estimator from an estimate using an example.

2. Define consistency and explain why it is an asymptotic property.

3. What is the difference between likelihood and probability?

4. State the bias–variance decomposition of mean squared error.

5. Why is the t distribution used when estimating a normal mean with unknown variance?

Long Answer Questions

1. Explain the method of moments and maximum likelihood, including their advantages and limitations.

2. Discuss bias, variance, mean squared error, consistency, efficiency, and sufficiency as criteria for evaluating estimators.

3. Explain the frequentist interpretation of a 95% confidence interval and contrast it with a common incorrect interpretation.

4. Describe bootstrap confidence intervals, including situations in which ordinary bootstrap resampling may be inappropriate.

5. Develop a practical workflow for estimating a population parameter and communicating its uncertainty in a data-science project.

Analytical / Application Questions

1. A sample of 100 Bernoulli trials contains 82 successes. Explain which point estimator you would use, identify assumptions behind a simple confidence interval, and describe why an alternative interval method might be preferred.

2. An analyst reports a very narrow confidence interval based on 10,000 records, but the records come from only 50 repeated customers. Analyse why the interval may be misleading and propose a better approach.

3. Two estimators are available: one is unbiased with high variance, and the other has small bias but much lower variance. Explain how you would compare them using mean squared error and what additional practical considerations should influence the decision.

22. Multiple Choice Questions with Answers

Question 1

Which statement best distinguishes an estimator from an estimate?

A. An estimator is fixed, whereas an estimate varies across samples.

B. An estimator is a rule or statistic; an estimate is its observed numerical value.

C. An estimator is a population parameter; an estimate is always a confidence interval.

D. There is no distinction between the two terms.

Correct Answer: B. An estimator is a rule or statistic; an estimate is its observed numerical value.

Question 2

For a Poisson model with parameter λ, which method-of-moments estimator follows directly from E(X) = λ?

A. The sample variance divided by the sample mean

B. The reciprocal of the sample mean

C. The sample mean

D. The sample maximum

Correct Answer: C. The sample mean

Question 3

Why is log-likelihood commonly maximised instead of likelihood?

A. It changes a parameter into a random variable.

B. It converts products into sums and is usually numerically more stable.

C. It guarantees that the estimator is unbiased.

D. It removes all model assumptions.

Correct Answer: B. It converts products into sums and is usually numerically more stable.

Question 4

An estimator has bias 2 and variance 9. What is its mean squared error?

A. 7

B. 9

C. 11

D. 13

Correct Answer: D. 13

Question 5

Which property means that an estimator approaches the true parameter in probability as sample size increases?

A. Sufficiency

B. Consistency

C. Unbiasedness

D. Ancillarity

Correct Answer: B. Consistency

Question 6

A 95% frequentist confidence interval is correctly interpreted as a method that:

A. Assigns a 95% probability to the fixed parameter after the interval is observed.

B. Contains 95% of the sample observations.

C. Captures the fixed parameter in approximately 95% of repeated applications under valid assumptions.

D. Guarantees that the model is correctly specified.

Correct Answer: C. Captures the fixed parameter in approximately 95% of repeated applications under valid assumptions.

Question 7

Why can a narrow confidence interval still be misleading?

A. Narrow intervals always indicate excessive sample size.

B. Sampling precision does not eliminate bias from poor sampling or model misspecification.

C. Confidence intervals cannot be calculated for large samples.

D. Narrow intervals imply that the estimator has infinite variance.

Correct Answer: B. Sampling precision does not eliminate bias from poor sampling or model misspecification.

Question 8

For a normal population mean with unknown variance and a small sample, which distribution is generally used for the standardised mean?

A. Uniform distribution

B. Poisson distribution

C. Student’s t distribution

D. Bernoulli distribution

Correct Answer: C. Student’s t distribution

Question 9

In the service-reliability case, why was resampling sessions rather than individual requests more appropriate?

A. Sessions contain no information about reliability.

B. Requests within a session may be dependent, so the session is the relevant sampling unit.

C. Session-level resampling always produces narrower intervals.

D. It converts a frequentist analysis into a Bayesian analysis.

Correct Answer: B. Requests within a session may be dependent, so the session is the relevant sampling unit.

Question 10

Which statement about maximum likelihood estimation is most accurate?

A. It is valid regardless of whether the assumed likelihood represents the data-generating process.

B. It chooses the parameter value that maximises compatibility of the observed data under the specified model.

C. It always produces an unbiased estimator in finite samples.

D. It cannot be used in regression models.

Correct Answer: B. It chooses the parameter value that maximises compatibility of the observed data under the specified model.

Statistics and Probability for Data Science
Chapter 6 of 15

Statistics and Probability for Data Science

Chapter 7
Hypothesis Testing and Statistical Decision-Making

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

7. Hypothesis Testing and Statistical Decision-Making

Introduction and Context

Data science rarely ends with describing what has happened. In many professional settings, the more difficult question is whether an observed pattern is sufficiently convincing to justify action. A marketing analyst may observe a higher conversion rate after a campaign change; a hospital may find that one treatment group recovers more quickly; a manufacturer may record a reduction in defects after introducing a new process. In each case, the observed difference may reflect a genuine underlying effect, random sampling variation, measurement error, or a combination of these factors.

Hypothesis testing provides a formal framework for reasoning under uncertainty. It does not prove that a claim is true or false in an absolute sense. Rather, it evaluates how compatible observed data are with a specified assumption about a population or data-generating process. Statistical decision-making extends this reasoning by considering the size and practical importance of an effect, the costs of errors, available resources, and organizational objectives.

This distinction is essential. A very large dataset can produce a statistically significant result for an effect too small to matter operationally. Conversely, a meaningful effect may fail to achieve statistical significance when the sample is small or highly variable. Competent data scientists therefore interpret p-values alongside confidence intervals, effect sizes, power, study design, and business or policy consequences.

Learning Objectives

By the end of this chapter, the reader should be able to:

1. Formulate null and alternative hypotheses for one-sample and two-sample problems.

2. Explain p-values, significance levels, confidence intervals, and statistical evidence.

3. Conduct and interpret tests for means, proportions, and differences between groups.

4. Distinguish Type I and Type II errors and explain statistical power.

5. Estimate sample-size requirements and understand the influence of effect size and variability.

6. Select appropriate parametric and non-parametric testing procedures.

7. Recognize the problems created by multiple testing, optional stopping, and p-hacking.

8. Combine statistical evidence with effect sizes, costs, risks, and managerial objectives.

9. Apply hypothesis-testing principles in data-science and organizational settings.

From a Business Question to Statistical Hypotheses

A hypothesis test begins with a substantive question, not with a statistical formula. For example, “Does the redesigned checkout page improve purchasing?” must be translated into a measurable outcome, a target population, a comparison, and a decision rule. If the outcome is the proportion of visitors who purchase, the parameter of interest may be the difference between the new and existing conversion rates.

The null hypothesis, denoted by H₀, represents a reference position. It commonly states that there is no difference, no association, or no effect. The alternative hypothesis, denoted by H₁ or Hₐ, represents the claim supported if the data provide sufficient evidence against H₀. For a difference in average delivery time, the hypotheses might be:

H₀: μnew − μold = 0

Hₐ: μnew − μold < 0

The alternative is one-sided because the operational question is whether the new process reduces delivery time. If any difference would be relevant, the alternative would be two-sided:

Hₐ: μnew − μold ≠ 0.

The choice between one-sided and two-sided testing must be made before inspecting the results. A one-sided test should not be selected merely because the observed result happens to point in a convenient direction. In most exploratory and general-purpose analyses, two-sided tests are safer because effects in either direction may have implications.

A test statistic summarizes how far the sample result lies from the null expectation, relative to sampling variability. In a one-sample mean test with known or sufficiently well-estimated standard error, the general form is:

Test statistic = (observed estimate − null value) / standard error.

For a sample mean with unknown population standard deviation, the one-sample t-statistic is:

t = (x̄ − μ₀)/(s/√n),

where x̄ is the sample mean, μ₀ is the hypothesized mean, s is the sample standard deviation, and n is the sample size. Under suitable assumptions, this statistic follows a t-distribution with n − 1 degrees of freedom when H₀ is true.

P-Values, Significance Levels, and Evidence

The p-value is the probability, assuming that H₀ is true, of observing a test statistic at least as extreme as the one obtained. “At least as extreme” is determined by the alternative hypothesis. A small p-value indicates that the data would be unusual under the null model; it does not indicate the probability that H₀ is true.

For example, a p-value of 0.03 does not mean that there is a 3% probability that the null hypothesis is true. Nor does it mean that the alternative hypothesis has a 97% probability of being true. Such interpretations confuse a conditional probability about data given a hypothesis with a probability assigned to the hypothesis itself.

Before testing, the analyst usually specifies a significance level, α, such as 0.05. If p ≤ α, the null hypothesis is rejected. If p > α, the analyst fails to reject H₀. The phrase “fail to reject” is preferable to “accept H₀,” because a non-significant result may reflect insufficient information rather than evidence that the null hypothesis is exactly true.

Statistical significance is a decision convention, not a natural boundary between truth and falsehood. A result with p = 0.049 is not meaningfully different from one with p = 0.051. The p-value should therefore be reported as part of a broader interpretation that includes the estimated effect and its uncertainty.

A confidence interval gives a range of parameter values compatible with the data and the selected confidence procedure. A 95% confidence interval is often described informally as a range of plausible values. In repeated sampling, 95% of intervals constructed by the same valid procedure would contain the fixed parameter. It is not technically correct to say that there is a 95% probability that a particular fixed parameter lies in the already calculated interval under the frequentist interpretation.

For a two-sided test at α = 0.05, a 95% confidence interval that excludes the null value corresponds to rejecting H₀ at the 5% level, assuming the same model and procedure. The interval adds information that a p-value alone cannot provide: direction, magnitude, and precision.

One-Sample and Two-Sample Procedures

One-sample tests

A one-sample test compares a sample with a benchmark or hypothesized population value. A retailer might test whether the average order value differs from $50, or a sensor manufacturer might test whether the mean measurement bias differs from zero.

The one-sample t-test is appropriate for a mean when observations are independent, the outcome is quantitative, and the population is approximately normal or the sample is sufficiently large for the sampling distribution of the mean to be reliable. Severe skewness, extreme outliers, or dependence may invalidate a simple t-test.

For a population proportion, a one-sample proportion test compares an observed proportion p̂ with a hypothesized value p₀. For sufficiently large expected counts, a z approximation may be used:

z = (p̂ − p₀)/√[p₀(1 − p₀)/n].

When expected counts are small, exact binomial methods or carefully chosen alternatives are preferable.

Independent two-sample tests

An independent two-sample test compares outcomes from two unrelated groups, such as customers exposed to two different advertisements. The parameter may be a difference in means, proportions, or distributional characteristics.

The two-sample t-test evaluates a difference in means. Welch’s t-test is generally preferred to the equal-variance version when group variances or sample sizes differ, because it does not require the assumption of equal population variances. The estimated difference should be reported with a confidence interval.

For two proportions, the analyst may test whether conversion rates differ between groups. The test requires attention to independence and expected counts. In a randomized experiment, the difference in proportions is often more interpretable than a ratio alone, although relative measures such as risk ratios or odds ratios can also be useful.

Paired data

A paired design arises when the same units are measured twice or when units are deliberately matched. Examples include employee productivity before and after training, or blood pressure measured before and after treatment. The appropriate analysis is based on within-pair differences:

di = afteri − beforei.

A one-sample t-test can then be applied to the differences. Treating paired observations as independent discards information and may produce an incorrect standard error.

Categorical and frequency data

For categorical outcomes, chi-square tests can assess independence between variables or goodness of fit to a specified distribution. For example, a company may test whether product preference is associated with customer segment. The chi-square approximation depends on adequate expected frequencies; sparse tables may require exact methods or model-based approaches.

Non-parametric alternatives

When assumptions concerning normality or outliers are problematic, rank-based methods may be useful. The Mann–Whitney test compares the distributions or rank locations of two independent groups, while the Wilcoxon signed-rank test addresses paired data. These procedures do not automatically test differences in means, and their interpretation depends on the shape of the distributions. Non-parametric methods are not assumption-free; they replace some assumptions with others.

Assumptions and the Quality of Evidence

Hypothesis tests are conditional on assumptions. The most important include independence, appropriate sampling or assignment, correct measurement, suitable distributional approximations, and a correctly specified comparison. Independence is especially important: thousands of observations from the same customer, machine, household, or time series may contain far less information than thousands of independent observations.

Random sampling supports generalization from a sample to a target population. Random assignment in an experiment supports causal interpretation of differences between treatment groups. These are different ideas. A randomized experiment conducted on a narrow convenience sample may provide strong evidence about causality within the study but limited evidence about a broader population.

Data screening should be conducted before final testing. Analysts should inspect missingness, outliers, coding errors, group imbalance, and measurement definitions. Transformations may stabilize variance or reduce skewness, but they should be justified rather than used merely to obtain a desired p-value.

Type I Error, Type II Error, and Power

A Type I error occurs when H₀ is rejected even though it is true. Its probability is controlled by α under the assumptions of the test. A Type II error occurs when H₀ is not rejected even though a specified alternative is true. Its probability is commonly denoted by β. Statistical power is 1 − β: the probability of detecting an effect of a specified size under specified conditions.

The consequences of these errors depend on context. A false positive in a safety-critical medical screening system may be costly, while a false negative may delay an effective intervention. In exploratory product experimentation, the organization may tolerate more false positives during early discovery but require stronger evidence before large-scale deployment.

Power depends on the significance level, sample size, effect size, variability, and test design. Holding other factors constant:

  • Larger samples increase power.
  • Larger true effects increase power.
  • Lower variability increases power.
  • A higher α increases power but also increases Type I error risk.
  • One-sided tests can have greater power in the specified direction, but only when scientifically justified.

A non-significant result does not establish that an effect is absent. Analysts should ask whether the confidence interval excludes effects that would matter operationally. If a study estimates a $2 reduction with a 95% interval from −$8 to $12, the evidence is inconclusive about both meaningful savings and meaningful losses. A larger sample may be needed.

Effect Size and Practical Significance

An effect size describes the magnitude of a phenomenon independently, or partly independently, of sample size. For mean differences, the raw effect may be directly meaningful: average processing time fell by 4.2 minutes. A standardized effect such as Cohen’s d expresses the difference relative to pooled variability:

d = (x̄1 − x̄2)/sp.

For proportions, useful measures include absolute risk difference, relative risk, odds ratio, and number needed to treat. The correct measure depends on the decision context. A rise in conversion from 10% to 11% is a one-percentage-point absolute increase but a 10% relative increase. Both statements are mathematically correct, yet they lead to different managerial impressions.

Practical significance requires domain knowledge. A statistically significant improvement of 0.1 seconds may be irrelevant in a low-volume process but important in a high-frequency automated system. Conversely, a small probability reduction may be highly valuable when the consequences of failure are severe. Effect sizes should therefore be translated into financial, operational, customer, safety, or social outcomes.

Sample Size Planning

Sample-size planning should occur before data collection whenever possible. The analyst specifies the desired significance level, target power, minimum detectable effect, variability or baseline rate, design structure, and likely attrition or missingness.

For a two-group comparison of means with equal group sizes, a simplified planning relationship is:

n per group ≈ 2(zα/2 + zβ)²σ²/Δ²,

where σ is the common standard deviation, Δ is the minimum meaningful difference, zα/2 reflects the selected two-sided significance level, and zβ reflects the desired power. The exact formula depends on the test and design.

The minimum detectable effect should not be chosen solely because it produces a convenient sample size. It should represent the smallest change that would justify action after considering costs and constraints. Underpowered studies waste resources and produce imprecise estimates; excessively large studies may detect trivial effects and expose unnecessary numbers of participants to intervention or data collection.

Sequential designs and interim analyses can be efficient, but repeated inspection of unadjusted p-values inflates the Type I error rate. Such designs require pre-specified stopping rules or sequential-testing methods.

Multiple Testing and Research Integrity

When many hypotheses are tested, the chance of at least one false positive increases. If 20 independent null hypotheses are each tested at α = 0.05, the probability of at least one false rejection is approximately 1 − 0.95²⁰, or about 64%, assuming all null hypotheses are true and independence holds.

The family-wise error rate is the probability of making one or more Type I errors within a family of tests. Bonferroni adjustment controls this rate by testing each hypothesis at α/m, where m is the number of tests. Holm’s step-down procedure is often more powerful while maintaining family-wise control. In large-scale exploratory analyses, controlling the false discovery rate—the expected proportion of false discoveries among rejected hypotheses—may be more appropriate. The Benjamini–Hochberg procedure is a widely used approach.

Multiple testing problems also arise through unplanned subgroup analyses, repeated model selection, trying several outcome definitions, and stopping data collection when a desired result appears. These practices can make nominal p-values misleading. Pre-registration, analysis plans, transparent reporting, replication, and separation of exploratory from confirmatory analyses improve credibility.

A Decision Framework for Data Scientists and Managers

Statistical evidence is one input into a decision, not the decision itself. A useful decision process contains five linked questions:

1. What population, intervention, and outcome are being studied?

2. What effect would be practically meaningful?

3. How precise and credible is the estimate?

4. What are the costs of false positives, false negatives, implementation, and delay?

5. What action is justified given the evidence and uncertainty?

A decision may be framed using expected loss. If action A produces benefit when an effect exists but imposes cost when it does not, the organization should compare expected benefits and costs under plausible states of nature. This may lead to different thresholds in a low-risk pilot and a high-risk production deployment.

For example, an A/B test may show that a recommendation algorithm increases click-through rate by 0.8 percentage points, with p = 0.01. Before deployment, management should examine whether the increase also improves revenue, whether long-term retention declines, whether the result generalizes across customer segments, and whether the algorithm introduces unfair exposure patterns. Statistical significance alone cannot answer these questions.

Illustrative Case Study: Evaluating a Customer-Service Intervention

Background

A fictional online retailer introduces an automated message intended to reduce repeat contacts to its customer-service center. Management wants to know whether the intervention reduces the average number of contacts per customer during the 30 days following a support interaction.

Situation and design

Customers are randomly assigned to either the existing communication process or the new automated message. The control group contains 2,400 customers and has a mean of 1.84 contacts, with a standard deviation of 2.10. The intervention group contains 2,400 customers and has a mean of 1.70 contacts, with a standard deviation of 2.00. The observed difference, intervention minus control, is −0.14 contacts.

Management defines a reduction of at least 0.10 contacts as operationally worthwhile because it would reduce workload enough to offset implementation costs. The analysis uses a two-sided Welch t-test at α = 0.05 because either an increase or decrease could be important.

Analysis

The estimated reduction is 0.14 contacts. With large samples, the standard error is sufficiently small that the p-value is below 0.05. Thus, the null hypothesis of no difference is rejected at the selected significance level. The result supports an association between the intervention and fewer subsequent contacts under the randomized design.

However, the analyst also reports a confidence interval. Suppose the 95% interval for the difference is −0.22 to −0.06 contacts. The interval suggests that the true average reduction may be as large as 0.22 contacts or as small as 0.06 contacts. Although the interval excludes zero, it includes effects below the pre-specified practical threshold of 0.10.

The analysis should also examine heterogeneous effects. The intervention may reduce contacts among customers with simple requests but increase them among customers with complex or accessibility-related needs. Segment analysis must be planned or adjusted for multiple comparisons, and subgroup estimates should be interpreted cautiously.

Decision and outcome

Management chooses a monitored phased rollout rather than an immediate universal deployment. The rollout includes a holdout group, monitoring of repeat contacts, resolution time, customer satisfaction, complaint rates, and accessibility indicators. After implementation, the organization can compare operational outcomes and detect unintended consequences.

Learning points

The case illustrates that statistical significance and practical significance are related but distinct. Random assignment strengthens causal interpretation, while the confidence interval reveals uncertainty about the size of the effect. A staged decision is appropriate when the evidence is promising but the consequences of implementation are not fully known. The analysis also demonstrates why a single headline metric should not determine a managerial decision.

Common Errors, Limitations, and Risks

Several errors recur in applied hypothesis testing. Treating p < 0.05 as a universal rule ignores effect size, context, and the cost of errors. Reporting only significant findings creates publication and selection bias. Testing assumptions mechanically, such as relying only on a normality test, can be misleading; graphical inspection, study design, robustness, and substantive knowledge matter as well.

Analysts should avoid changing the hypothesis after seeing the result without labeling the analysis as exploratory. They should not remove outliers solely because they weaken significance, nor should they test many models and report only the most favorable one. Correlation does not become causation through a small p-value. Statistical adjustment cannot repair severe selection bias, confounding, poor measurement, or data leakage.

A further limitation is that classical tests often answer a narrower question than decision-makers believe. A test may assess whether an average differs from a benchmark while management needs to know whether the effect is consistent across regions, profitable after costs, durable over time, or safe for vulnerable groups.

Ethics, Governance, and Digital Practice

Hypothesis testing can affect access to credit, healthcare, employment, insurance, and public services. Analysts must therefore consider privacy, consent, fairness, explainability, and the possibility that an apparently neutral outcome measure embeds unequal consequences. Statistical significance should not be used to legitimize discriminatory practices or to conceal uncertainty from stakeholders.

In automated analytics environments, reproducible pipelines should preserve the data version, feature definitions, sampling rules, code, model settings, and analysis plan. Dashboards that display p-values without confidence intervals or sample sizes can encourage overinterpretation. Automated experimentation platforms should include safeguards for multiple testing, monitoring, stopping rules, and metric manipulation.

Current practice increasingly combines classical inference with resampling, Bayesian analysis, causal inference, and sequential experimentation. Bootstrap intervals can be useful when analytic assumptions are doubtful. Bayesian methods express uncertainty through posterior distributions and can incorporate prior information. Causal methods such as randomized trials, matching, regression adjustment, and difference-in-differences address questions that a simple significance test cannot resolve. These methods do not eliminate the need for careful design and transparent assumptions.

Best Practices for Professional Analysis

A defensible hypothesis-testing workflow should:

  • Define the decision, population, outcome, and practically meaningful effect before analysis.
  • Select the test according to the design and measurement scale.
  • Check independence, missing data, outliers, and relevant distributional assumptions.
  • Report the estimate, confidence interval, p-value, sample size, and analytical method.
  • Distinguish statistical significance from practical importance.
  • Plan sample size and power before collecting data.
  • Adjust for multiple comparisons when a family of tests is being interpreted together.
  • Separate confirmatory analyses from exploratory findings.
  • Conduct sensitivity and subgroup analyses transparently.
  • Translate results into operational consequences and monitor post-decision outcomes.

Chapter Summary

Hypothesis testing evaluates the compatibility of observed data with a null model. It requires clearly formulated null and alternative hypotheses, an appropriate test statistic, and assumptions justified by the study design and data. The p-value measures the extremeness of the data under H₀; it is not the probability that H₀ is true. Confidence intervals and effect sizes provide essential information about magnitude and precision.

One-sample, independent two-sample, paired, proportion, categorical, and non-parametric procedures address different designs and outcome types. Type I and Type II errors represent different risks, while power expresses the probability of detecting a specified effect. Sample-size planning should be based on meaningful effects, variability, α, desired power, and resource constraints. Multiple testing, optional stopping, and selective reporting can inflate false discoveries.

For data-science practice, statistical evidence must be integrated with causal design, business value, ethical considerations, implementation costs, and the consequences of incorrect decisions. A statistically significant finding is a starting point for judgment, not a substitute for it.

Key Terms

Null hypothesis: A reference statement about a population parameter, commonly asserting no effect or no difference.

Alternative hypothesis: A statement describing the effect or difference considered plausible against the null hypothesis.

P-value: The probability, assuming the null hypothesis is true, of observing a result at least as extreme as the sample result.

Significance level: The pre-specified maximum probability of a Type I error, denoted by α.

Test statistic: A standardized quantity used to compare an observed estimate with a null value.

Type I error: Rejection of a true null hypothesis.

Type II error: Failure to reject a false null hypothesis.

Statistical power: The probability of rejecting the null hypothesis when a specified alternative effect is true.

Effect size: A quantitative measure of the magnitude of a difference or relationship.

Confidence interval: An interval produced by a procedure that captures the fixed parameter at a stated long-run frequency.

One-sample test: A test comparing a sample estimate with a specified population or benchmark value.

Independent two-sample test: A test comparing outcomes from two unrelated groups.

Paired test: A test based on differences within matched or repeated observations.

Welch’s t-test: A two-sample t-test that does not require equal population variances.

Parametric test: A test based on a specified distributional model and population parameters.

Non-parametric test: A test relying less directly on a particular population distribution, often using ranks.

Family-wise error rate: The probability of making at least one Type I error across a family of tests.

False discovery rate: The expected proportion of false rejections among all rejected hypotheses.

Minimum detectable effect: The smallest effect a study is designed to identify with specified power.

Practical significance: The importance of an effect for real-world decisions, independent of statistical significance alone.

Review Questions

Short Answer Questions

1. What is the difference between a null hypothesis and an alternative hypothesis?

2. Why is “fail to reject” usually preferable to “accept” the null hypothesis?

3. Define a p-value without interpreting it as the probability that the null hypothesis is true.

4. What factors influence statistical power?

5. Why are paired observations analyzed through within-pair differences?

Long Answer Questions

1. Explain how confidence intervals, p-values, and effect sizes complement one another in statistical interpretation.

2. Compare Type I and Type II errors and discuss how their relative costs may affect an organizational decision.

3. Describe the assumptions and appropriate applications of one-sample, independent two-sample, and paired t-tests.

4. Explain why multiple testing increases false-positive risk and compare family-wise error control with false-discovery-rate control.

5. Discuss how a data scientist should translate a statistically significant result into a managerial recommendation.

Analytical / Application Questions

1. An experiment estimates that a new interface increases conversion by 0.6 percentage points, with p = 0.002 and a 95% confidence interval from 0.2 to 1.0 percentage points. Explain what can and cannot be concluded, and identify additional information needed before rollout.

2. A study reports a non-significant difference between two treatments, but its confidence interval ranges from a clinically important benefit to a clinically important harm. How should the result be interpreted, and what would you recommend regarding sample size or further research?

3. An analyst tests 30 customer segments and reports the three segments with p-values below 0.05. Evaluate the evidential problem and propose a more defensible analysis plan.

22. Multiple Choice Questions with Answers

Question 1

Which interpretation of a p-value is correct?

A. It is the probability that the null hypothesis is true.

B. It is the probability that the alternative hypothesis is true.

C. Assuming the null hypothesis is true, it is the probability of observing a result at least as extreme as the one obtained.

D. It is the probability that the sample was selected randomly.

Correct Answer: C. Assuming the null hypothesis is true, it is the probability of observing a result at least as extreme as the one obtained.

Question 2

A study estimates a mean difference of 4 units with a 95% confidence interval from -2 to 10 units. At the 5% two-sided level, what is the appropriate conclusion?

A. Reject the null hypothesis because the estimated difference is positive.

B. Reject the null hypothesis because the interval contains values greater than zero.

C. Fail to reject the null hypothesis because the interval includes zero.

D. Accept the null hypothesis as exactly true.

Correct Answer: C. Fail to reject the null hypothesis because the interval includes zero.

Question 3

Which design most directly calls for a paired analysis?

A. Comparing two unrelated customer samples.

B. Comparing measurements from the same employees before and after training.

C. Comparing defect rates across two independent factories.

D. Comparing preferences across independent age groups.

Correct Answer: B. Comparing measurements from the same employees before and after training.

Question 4

Which change generally increases statistical power, all else being equal?

A. Reducing the sample size.

B. Increasing measurement variability.

C. Reducing the true effect size.

D. Increasing the sample size.

Correct Answer: D. Increasing the sample size.

Question 5

A Type I error occurs when an analyst:

A. Fails to reject a false null hypothesis.

B. Rejects a true null hypothesis.

C. Uses a sample that is larger than necessary.

D. Reports an effect size without a p-value.

Correct Answer: B. Rejects a true null hypothesis.

Question 6

Why can a very large dataset produce a statistically significant but practically unimportant result?

A. Large samples always violate independence.

B. The standard error can become very small, making tiny effects statistically detectable.

C. P-values become probabilities that the alternative is true.

D. Confidence intervals become wider as sample size increases.

Correct Answer: B. The standard error can become very small, making tiny effects statistically detectable.

Question 7

When comparing two means with unequal variances and unequal sample sizes, which procedure is generally appropriate?

A. Welch’s t-test.

B. A one-sample proportion test.

C. A paired t-test regardless of study design.

D. A chi-square goodness-of-fit test.

Correct Answer: A. Welch’s t-test.

Question 8

What is the main purpose of a multiple-testing adjustment?

A. To increase the observed effect size.

B. To remove all sampling variability.

C. To control the increased risk of false discoveries created by testing many hypotheses.

D. To guarantee that every rejected hypothesis is causally valid.

Correct Answer: C. To control the increased risk of false discoveries created by testing many hypotheses.

Question 9

An analyst repeatedly checks results and stops data collection as soon as p < 0.05 without a pre-specified rule. What is the principal concern?

A. The procedure may inflate the Type I error rate.

B. The procedure necessarily eliminates statistical power.

C. The sample mean becomes equal to the population mean.

D. The analysis becomes automatically non-parametric.

Correct Answer: A. The procedure may inflate the Type I error rate.

Question 10

Which statement best reflects sound managerial use of statistical evidence?

A. Any statistically significant result should be implemented immediately.

B. A non-significant result proves that no effect exists.

C. The decision should consider effect size, uncertainty, error costs, implementation consequences, and evidence quality.

D. The p-value alone determines whether an intervention is profitable.

Correct Answer: C. The decision should consider effect size, uncertainty, error costs, implementation consequences, and evidence quality.

Statistics and Probability for Data Science
Chapter 7 of 15

Statistics and Probability for Data Science

Chapter 8
Regression and Generalized Linear Models

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

8. Regression and Generalized Linear Models

Introduction and Context

Regression is one of the central methods of statistical learning. It provides a formal way to describe how an outcome changes in relation to one or more explanatory variables, to quantify uncertainty, to make predictions, and to support decisions. In data science, regression is used in demand forecasting, credit scoring, clinical research, marketing attribution, policy analysis, reliability engineering, and many other domains.

The word regression refers not merely to drawing a line through data. A regression model expresses assumptions about a data-generating process. It distinguishes systematic variation, which may be explained by predictors, from random variation, measurement error, omitted variables, and other sources of uncertainty. Sound regression analysis therefore requires both mathematical modelling and critical assessment of whether the model is appropriate for the problem.

This chapter develops ordinary linear regression, polynomial and multiple regression, interactions and confounding, diagnostics, multicollinearity, heteroscedasticity, and regularization. It then extends the regression framework to generalized linear models (GLMs), including logistic and count-data models.

Learning Objectives

By the end of this chapter, students should be able to:

  • formulate and interpret simple and multiple linear regression models;
  • distinguish association from causation and identify confounding and interaction;
  • fit and interpret polynomial terms and categorical predictors;
  • assess assumptions using residual analysis and diagnostic measures;
  • explain multicollinearity, heteroscedasticity, influential observations, and appropriate remedies;
  • compare ordinary least squares with ridge and lasso regularization;
  • explain the structure of generalized linear models;
  • fit and interpret logistic, Poisson, and related models;
  • evaluate predictive performance without confusing it with causal validity; and
  • apply regression responsibly in professional and organizational settings.

From a Line to a Statistical Model

In simple linear regression, an outcome \(Y\) is related to a predictor \(X\) through

\[

Y_i=\beta_0+\beta_1X_i+\varepsilon_i,

\]

where \(\beta_0\) is the intercept, \(\beta_1\) is the expected change in the outcome for a one-unit increase in the predictor, and \(\varepsilon_i\) represents unexplained variation. The conditional mean is

\[

E(Y_i\mid X_i)=\beta_0+\beta_1X_i.

\]

The usual least-squares estimates choose coefficients that minimize the sum of squared residuals:

\[

\sum_{i=1}^{n}(y_i-\hat y_i)^2.

\]

A residual is \(e_i=y_i-\hat y_i\). The fitted line describes the mean relationship, not necessarily every individual observation. A large residual is not automatically evidence of a bad model; it may reflect natural variability. However, systematic residual patterns indicate that the model has failed to represent some important feature of the data.

Under the classical linear model, useful inferential assumptions include linearity in the coefficients, independent errors, constant error variance, and (for small-sample tests and intervals) approximately normal errors. Normality of the predictors is not required. Nor is normality of the outcome itself required when sample sizes are adequate and the other assumptions are reasonable.

The coefficient of determination, \(R^2\), is

\[

R^2=1-\frac{\text{SSE}}{\text{SST}},

\]

where SSE is the residual sum of squares and SST is the total sum of squares. It measures the proportion of variation in the observed outcome explained by the fitted model relative to an intercept-only model. A high \(R^2\) does not prove causation, guarantee accurate extrapolation, or establish that the model is useful for a particular decision.

Multiple Regression

With several predictors, the model becomes

\[

Y_i=\beta_0+\beta_1X_{i1}+\cdots+\beta_pX_{ip}+\varepsilon_i.

\]

Here, \(\beta_j\) is the expected change in \(Y\) associated with a one-unit increase in \(X_j\), holding the other included predictors constant. This conditional interpretation is valuable but can be misleading if the predictors are strongly related or if the variables held constant are consequences of the exposure being studied.

Categorical predictors are represented using indicator variables. If a variable has \(k\) categories, a model generally includes \(k-1\) indicators and selects one reference category. The coefficient for an indicator compares its category with the reference category, conditional on the remaining variables.

A coefficient estimate is commonly accompanied by a standard error, confidence interval, and p-value. A confidence interval communicates a range of parameter values compatible with the data and model assumptions. Statistical significance does not measure practical importance; a small effect may be precisely estimated in a large dataset, while an important effect may be uncertain in a small one.

Shape, Interactions, and Confounding

Polynomial Regression

A curved mean relationship can be modelled by including powers of a predictor:

\[

E(Y\mid X)=\beta_0+\beta_1X+\beta_2X^2.

\]

Although the model is nonlinear in \(X\), it remains linear in its coefficients and can be estimated by least squares. The marginal effect is

\[

\frac{dE(Y\mid X)}{dX}=\beta_1+2\beta_2X.

\]

Thus, \(\beta_1\) alone is not the overall effect of \(X\). Centering \(X\) before creating powers can improve interpretability and reduce numerical correlation between terms. High-degree polynomials often behave erratically near the boundaries and should not be used simply because they improve in-sample fit. Splines or other flexible methods may be preferable.

Interactions

An interaction means that the effect of one predictor depends on the level of another. For two variables,

\[

E(Y\mid X,Z)=\beta_0+\beta_1X+\beta_2Z+\beta_3XZ.

\]

The effect of \(X\) is \(\beta_1+\beta_3Z\), not simply \(\beta_1\). If \(Z=0\) is not meaningful, centering or otherwise choosing a meaningful reference value is important. Main effects should normally remain in a model containing their interaction, even when an individual main-effect test is not statistically significant.

Confounding and Causal Caution

A confounder is a variable associated with both a predictor and an outcome that creates or distorts their observed association. For example, an analysis may find that training hours are associated with productivity, but employee experience may influence both training participation and productivity. Adjusting for experience may change the training coefficient substantially.

Confounding is not solved mechanically by adding every available variable. Adjustment can introduce bias when conditioning on a collider, a variable influenced by two other variables. Causal modelling should therefore begin with subject-matter knowledge, a clear estimand, and preferably a causal diagram or design strategy. Regression alone generally estimates conditional associations, not causal effects.

Diagnosing a Fitted Model

Model diagnosis is an iterative process rather than a final ceremonial step. Important tools include:

  • Residual-versus-fitted plots: reveal curvature, unequal spread, and unusual observations.
  • Residuals versus predictors: reveal omitted nonlinear structure or interactions.
  • Normal Q–Q plots: assess whether residuals have strongly non-normal tails.
  • Scale–location plots: help identify changing residual variance.
  • Leverage: identifies observations with unusual predictor values.
  • Cook’s distance and related measures: assess whether a case has substantial influence on fitted coefficients.

An outlier is unusual in the outcome; a high-leverage point is unusual in predictor space; an influential observation materially changes the fitted model. These are different concepts. Deleting a point merely because it is inconvenient is bad practice. The analyst should verify data quality, investigate the substantive context, conduct sensitivity analyses, and report how conclusions change.

Heteroscedasticity

Heteroscedasticity occurs when the conditional variance of errors changes with predictors or fitted values. It does not necessarily bias ordinary least-squares coefficient estimates when the conditional mean is correctly specified, but conventional standard errors, confidence intervals, and tests may be unreliable. Remedies include transforming the outcome, using heteroscedasticity-robust standard errors, modelling the variance explicitly, or applying weighted least squares when a defensible variance model is available.

Multicollinearity

Multicollinearity occurs when predictors contain overlapping information. It often produces unstable coefficient estimates, large standard errors, unexpected coefficient signs, and sensitivity to small changes in the data. It does not necessarily reduce predictive accuracy. Variance inflation factors can be used as diagnostic indicators, but no universal cutoff replaces substantive judgement.

Possible responses include removing redundant variables, combining measurements, collecting more informative data, centering terms in polynomial or interaction models, or using ridge regression. Dropping a variable solely because of a high diagnostic value may damage interpretation when the variable is a theoretically essential confounder.

Validation and Prediction

A model should be evaluated on data not used for fitting. A train-test split or cross-validation estimates out-of-sample performance. For continuous outcomes, common measures include mean squared error, root mean squared error, and mean absolute error. Cross-validation must be designed around the data-generating process: time series should preserve temporal order, and observations from the same person or organization should not be split across training and test sets when that would cause leakage.

Prediction intervals are wider than confidence intervals for the mean because they include both uncertainty in the estimated mean and individual outcome variability. Extrapolation beyond the observed predictor range is especially risky, even when a model fits well within the sample.

Regularization and the Bias–Variance Trade-off

When there are many predictors, correlated features, or a relatively small sample, unconstrained least squares can overfit. Regularization shrinks coefficients toward zero by adding a penalty to the fitting objective.

Ridge regression minimizes

\[

\sum_i(y_i-\hat y_i)^2+\lambda\sum_j\beta_j^2,

\]

while lasso minimizes

\[

\sum_i(y_i-\hat y_i)^2+\lambda\sum_j|\beta_j|.

\]

The intercept is usually not penalized, and predictors should generally be standardized before penalization. Ridge tends to retain correlated predictors with smaller coefficients. Lasso can set some coefficients exactly to zero and therefore perform variable selection, although its selection can be unstable among highly correlated features. Elastic net combines both penalties.

The tuning parameter \(\lambda\) is selected using validation or cross-validation. Regularization introduces bias in exchange for reduced variance and often improved prediction. Penalized coefficients should not be interpreted like ordinary least-squares estimates without considering the penalty and the modelling objective.

Generalized Linear Models

Ordinary linear regression is unsuitable when the outcome is binary, a count, or otherwise restricted. A generalized linear model has three components:

1. a random component specifying the outcome distribution;

2. a systematic component, \(\eta=X\beta\), formed from predictors; and

3. a link function connecting the conditional mean \(\mu=E(Y\mid X)\) to \(\eta\):

\[

g(\mu)=X\beta.

\]

GLMs are commonly fitted by maximum likelihood, often using iteratively reweighted least squares. Their coefficients are interpreted on the link scale unless transformed into a more intuitive scale.

Logistic Regression

For a binary outcome, logistic regression models the log-odds:

\[

\log\left(\frac{p}{1-p}\right)=\beta_0+\beta_1X_1+\cdots+\beta_pX_p.

\]

Exponentiating a coefficient gives an odds ratio. Holding other variables constant, a one-unit increase in \(X_j\) multiplies the odds by \(e^{\beta_j}\). An odds ratio is not generally a risk ratio, especially when the outcome is common. Predicted probabilities are often more accessible to decision-makers than log-odds or odds ratios.

Performance should be assessed using discrimination and calibration. The ROC curve and area under the curve summarize ranking ability, while calibration examines agreement between predicted probabilities and observed frequencies. A classification threshold should reflect the relative costs of false positives and false negatives rather than being selected automatically at 0.5.

Count Models

Poisson regression models a non-negative count using

\[

\log(\mu_i)=\beta_0+\beta_1X_{i1}+\cdots+\beta_pX_{ip}.

\]

Exponentiating \(\beta_j\) gives an incidence-rate ratio for a one-unit increase in a predictor. If observations have different exposure times, an offset such as \(\log(t_i)\) can be included with coefficient fixed at one. The Poisson model assumes that conditional variance equals the conditional mean. Overdispersion, in which variance exceeds the mean, may require quasi-Poisson or negative binomial modelling. Excess zeros may motivate hurdle or zero-inflated approaches, but these should be justified by the data-generating process rather than selected automatically.

Other GLMs include gamma regression for positive, right-skewed outcomes and inverse Gaussian models for certain duration or cost data. The choice should reflect the outcome’s support, variance structure, scientific meaning, and predictive purpose.

An Illustrative Case: Hospital Readmission Risk

Background and problem

Suppose a hospital wants to estimate the probability that a patient will be readmitted within 30 days of discharge. The data include age, previous admissions, length of stay, comorbidity score, discharge destination, and whether a follow-up appointment was scheduled. The objective is operational: identify patients who may benefit from additional support, not to label patients as personally responsible for readmission.

Analysis and approach

A logistic regression is appropriate because the outcome is binary. The analyst first defines the prediction time and ensures that only information available before discharge is used. Variables recorded after discharge would create leakage. A model is fitted on training data and assessed on temporally later data. Calibration is examined because a hospital needs trustworthy probabilities for allocating scarce follow-up resources.

Suppose previous admissions has a positive coefficient. Its exponentiated coefficient represents the multiplicative change in odds associated with one additional previous admission, conditional on the other included predictors. The hospital should not interpret this as proof that previous admissions causes readmission. It may partly reflect unmeasured illness severity or social conditions.

The analyst checks for nonlinearity in age, interactions between discharge destination and follow-up care, missing-data patterns, and subgroup calibration. If the model performs less well for a demographic group, the organization investigates data quality, access differences, and clinical processes rather than simply lowering or raising a threshold for that group.

Outcome and learning points

The model becomes one component of a triage process. Staff review high-risk cases, and an evaluation compares outcomes under the new process with outcomes under usual care. The case demonstrates that a statistically adequate model is not automatically a beneficial intervention. Valid deployment requires temporal validation, governance, fairness assessment, human oversight, and monitoring for changes in patient populations and clinical practice.

Professional and Ethical Practice

Regression analysis can influence lending, employment, insurance, healthcare, public services, and resource allocation. Analysts should document the target population, data provenance, missing-data treatment, feature construction, exclusions, model version, validation design, and intended use. Sensitive attributes may be relevant for auditing fairness even when they are excluded from prediction.

Privacy protection includes data minimization, access controls, secure storage, and careful reporting of small groups. A model should not be deployed merely because it has a high accuracy or \(R^2\). Stakeholders need to understand uncertainty, limitations, operating thresholds, and consequences of errors. Model cards, reproducible pipelines, version control, drift monitoring, and periodic review support responsible operation.

Common mistakes include interpreting correlation as causation, reporting only p-values, ignoring nonlinear effects, fitting many transformations after inspecting the test set, treating missingness as harmless, deleting influential cases without investigation, and using accuracy for highly imbalanced classification. Automated machine-learning systems do not remove the need for design, diagnostics, domain expertise, or accountability.

Emerging Directions

Contemporary regression practice increasingly combines interpretable statistical models with flexible machine-learning methods. Generalized additive models, tree ensembles, boosting, Bayesian regression, and causal machine learning can capture complex structure, but their use should be matched to the objective. Explainability methods describe model behaviour but do not automatically establish causal explanations. Probabilistic forecasting, conformal prediction, distribution shift detection, and privacy-preserving analytics are also developing areas. The enduring principle is that predictive performance, interpretability, fairness, and operational value must be evaluated together.

Best-Practice Workflow

A defensible regression project generally follows this sequence:

1. Define the outcome, prediction or causal estimand, population, and decision context.

2. Inspect data quality, missingness, measurement units, sampling, and leakage risks.

3. Use subject knowledge to specify plausible predictors, transformations, and interactions.

4. Fit a transparent baseline before considering more complex models.

5. Diagnose residuals, dependence, variance, collinearity, influence, and calibration.

6. Use cross-validation or appropriate holdout data for performance assessment.

7. Compare alternatives using both statistical evidence and practical consequences.

8. Quantify uncertainty and conduct sensitivity and subgroup analyses.

9. Document the model and deploy with monitoring, governance, and a plan for revision.

Chapter Summary

Regression models quantify relationships between outcomes and predictors and support both explanation and prediction. Linear regression estimates conditional means through least squares, while multiple regression permits adjustment for several variables. Polynomial terms and interactions represent curvature and effect modification, but coefficients must be interpreted in context. Confounding requires causal reasoning rather than indiscriminate adjustment.

Residual diagnostics reveal nonlinearity, heteroscedasticity, non-normality, leverage, and influential observations. Multicollinearity can destabilize individual coefficients, and regularization can improve prediction by trading a little bias for lower variance. Generalized linear models extend regression to binary, count, and other non-normal outcomes through a distribution and link function. Logistic coefficients describe changes in log-odds, while Poisson coefficients describe changes in log rates. Valid application requires appropriate validation, ethical governance, transparent communication, and continuous monitoring.

Key Terms

Regression: A statistical method for modelling an outcome as a function of explanatory variables.

Conditional mean: The expected value of an outcome given specified predictor values.

Residual: The difference between an observed outcome and its fitted value.

Ordinary least squares: Estimation by minimizing the sum of squared residuals.

Multiple regression: Regression involving two or more predictors.

Polynomial regression: A linear-in-parameters model containing powers of a predictor.

Interaction: A relationship in which the effect of one predictor depends on another.

Confounding: Distortion of an association by a variable related to both exposure and outcome.

Multicollinearity: Strong dependence or overlap among predictors.

Heteroscedasticity: Non-constant conditional variance of model errors.

Leverage: The degree to which an observation has an unusual predictor pattern.

Influential observation: A case whose removal substantially changes model results.

Regularization: Penalization used to control coefficient size and reduce overfitting.

Ridge regression: Regression using an L2, or squared-coefficient, penalty.

Lasso regression: Regression using an L1, or absolute-coefficient, penalty.

Generalized linear model: A model combining an outcome distribution, linear predictor, and link function.

Logistic regression: A GLM for binary outcomes using the logit link.

Odds ratio: The ratio of odds associated with a specified change in a predictor.

Poisson regression: A log-link GLM commonly used for count outcomes.

Calibration: Agreement between predicted probabilities and observed outcome frequencies.

Review Questions

Short Answer Questions

1. What does a multiple-regression coefficient mean when other predictors are held constant?

2. Distinguish an outlier, a high-leverage observation, and an influential observation.

3. Why can heteroscedasticity make ordinary standard errors unreliable?

4. What is the purpose of a link function in a generalized linear model?

5. Why should predictors usually be standardized before ridge or lasso regression?

Long Answer Questions

1. Explain the assumptions of ordinary linear regression and describe diagnostic methods for assessing them.

2. Discuss interactions, polynomial terms, and the interpretation difficulties they create.

3. Compare ridge regression and lasso regression in terms of objective, coefficient behaviour, and use cases.

4. Explain logistic regression, including odds, odds ratios, probability prediction, discrimination, and calibration.

5. Describe how confounding differs from multicollinearity and why each requires a different response.

Analytical / Application Questions

1. A sales model has a strong residual funnel shape. What does this suggest, and what analyses or remedies would you consider?

2. A count model for emergency visits shows variance far greater than its mean and many zero observations. Which modelling issues arise, and what alternatives could be investigated?

3. A hospital prediction model performs well overall but is poorly calibrated for one demographic group. Design a responsible investigation and improvement plan.

22. Multiple Choice Questions with Answers

Question 1

In a multiple linear regression, the coefficient for X1 is interpreted as:

A. The unconditional change in Y for a one-unit change in X1

B. The expected change in Y for a one-unit change in X1, holding included predictors constant

C. The percentage of variation explained by X1 alone

D. The probability that X1 causes Y

Correct Answer: B. The expected change in Y for a one-unit change in X1, holding included predictors constant

Question 2

In a model containing X, Z, and XZ, the marginal effect of X is:

A. β1

B. β1 + β2

C. β1 + β3Z

D. β0 + β1X

Correct Answer: C. β1 + β3Z

Question 3

Which pattern most directly suggests heteroscedasticity?

A. Residuals forming a widening funnel as fitted values increase

B. Predictors having different measurement units

C. A categorical variable having three levels

D. A high value of the intercept

Correct Answer: A. Residuals forming a widening funnel as fitted values increase

Question 4

What is a primary effect of multicollinearity?

A. It always biases predictions upward

B. It makes the outcome binary

C. It can produce unstable coefficients and inflated standard errors

D. It guarantees heteroscedasticity

Correct Answer: C. It can produce unstable coefficients and inflated standard errors

Question 5

Which statement about lasso regression is correct?

A. It uses only a squared-coefficient penalty

B. It can shrink some coefficients exactly to zero

C. It cannot be used with standardized predictors

D. It always outperforms ridge regression

Correct Answer: B. It can shrink some coefficients exactly to zero

Question 6

Logistic regression models which quantity linearly in the predictors?

A. The raw probability without transformation

B. The odds ratio itself

C. The log-odds of the outcome

D. The residual variance

Correct Answer: C. The log-odds of the outcome

Question 7

If a logistic-regression coefficient is β, exp(β) represents:

A. A change in probability of exactly β

B. An odds multiplier for a one-unit predictor increase, conditional on other variables

C. The model’s accuracy

D. The residual standard deviation

Correct Answer: B. An odds multiplier for a one-unit predictor increase, conditional on other variables

Question 8

A Poisson model with an exposure-time offset is designed primarily to model:

A. A binary outcome

B. A continuous outcome with unrestricted negative values

C. A count or event rate accounting for differing exposure times

D. The correlation between two predictors

Correct Answer: C. A count or event rate accounting for differing exposure times

Question 9

Why is a random train-test split inappropriate in some time-series regression problems?

A. It prevents coefficient estimation

B. It can allow future information to influence training and produce leakage

C. It always increases heteroscedasticity

D. It removes the intercept

Correct Answer: B. It can allow future information to influence training and produce leakage

Question 10

Which statement best reflects responsible interpretation of a regression association?

A. A statistically significant coefficient proves causation

B. A high R² proves the model will extrapolate accurately

C. Causal interpretation requires design and subject-matter reasoning beyond regression alone

D. A small p-value establishes practical importance

Correct Answer: C. Causal interpretation requires design and subject-matter reasoning beyond regression alone

Statistics and Probability for Data Science
Chapter 8 of 15

Statistics and Probability for Data Science

Chapter 9
Experimental Design, A/B Testing and Causal Inference

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

9. Experimental Design, A/B Testing and Causal Inference

Introduction and Context

Data science is often presented as a discipline for prediction: estimating whether a customer will churn, forecasting demand, or classifying an image. Yet many of the most consequential decisions are causal. A product team wants to know whether a redesigned checkout page increases purchases; a public agency asks whether a training programme improves employment; a hospital evaluates whether a new treatment reduces readmissions. In each case, the central question is not merely what is associated with an outcome, but what would happen if a particular intervention were applied.

Causal questions are difficult because the same unit cannot ordinarily be observed both with and without treatment at the same time. For a given individual, we observe either the outcome under treatment or the outcome under control, but not both. Experimental design provides a disciplined way to approximate this missing counterfactual. Randomized experiments, including online A/B tests, use deliberate assignment to create comparable groups. When randomization is impossible, causal inference relies on carefully justified assumptions and quasi-experimental designs.

This chapter develops the principles required to design, analyse, and critique experiments. It connects classical analysis of variance (ANOVA) with modern experimentation, explains factorial and blocked designs, and introduces potential-outcomes reasoning, confounding, selection bias, and causal graphs. The emphasis is practical: a statistically significant result is not automatically a useful or credible causal conclusion.

Learning Objectives

By the end of this chapter, you should be able to:

1. Distinguish descriptive, predictive, and causal questions.

2. Explain counterfactuals, treatment effects, estimands, and randomization.

3. Design randomized, blocked, and factorial experiments.

4. Analyse treatment effects using means, confidence intervals, hypothesis tests, and ANOVA.

5. Design and interpret online A/B tests, including metrics, power, interference, and sequential monitoring.

6. Identify confounding, selection bias, attrition, measurement problems, and threats to validity.

7. Explain quasi-experimental approaches such as difference-in-differences, regression discontinuity, instrumental variables, and interrupted time series.

8. Evaluate causal claims using explicit assumptions, sensitivity analysis, and ethical standards.

From Association to Intervention

An association describes how variables vary together. If users who receive more support tickets have lower retention, this relationship may be real, but it does not establish that reducing support tickets would improve retention. The relationship may reflect reverse causality, omitted variables, or selection. For example, dissatisfied customers may both contact support frequently and be more likely to leave.

A causal effect is defined through a comparison with a counterfactual. Let \(Y_i(1)\) be the outcome for unit \(i\) if it receives treatment and \(Y_i(0)\) the outcome if it receives control. The individual treatment effect is

\[

\tau_i=Y_i(1)-Y_i(0).

\]

Only one of these two potential outcomes is observed. This is the fundamental problem of causal inference. Common population-level estimands include the average treatment effect (ATE),

\[

ATE=E[Y(1)-Y(0)],

\]

and the average treatment effect on the treated (ATT),

\[

ATT=E[Y(1)-Y(0)\mid T=1].

\]

The ATE asks what would happen if treatment were assigned to the target population. The ATT asks about those who actually received treatment. In practice, the estimand should be specified before analysis because a result can be accurate for one population and misleading for another.

A causal claim requires more than a difference in observed averages. It requires a design or set of assumptions that makes the treated and untreated outcomes comparable. Randomization is powerful because, in expectation, it balances both observed and unobserved characteristics between groups.

Designing a Credible Experiment

A sound experiment begins with a clearly defined unit of randomization: an individual, household, transaction, school, geographic region, or user account. The unit receiving treatment may differ from the unit at which outcomes are measured. For example, a marketing campaign may be assigned by household while purchases are measured for individuals. Such clustering affects standard errors and must be reflected in the analysis.

The treatment should be operationally precise. “Improved service” is not an adequate treatment definition; “a response within two hours using the revised script” is more reproducible. The control condition must also be specified. It may be business as usual, a placebo, or an alternative intervention. A well-defined primary outcome and a pre-established observation window prevent researchers from selecting favourable outcomes after examining results.

Random assignment can be represented by a treatment indicator \(T_i\), where \(T_i=1\) denotes treatment and \(T_i=0\) denotes control. Under complete randomization, every permissible assignment has a known probability. Under simple randomization, units are assigned independently, commonly using a random number generator. In restricted randomization, such as permuted blocks, the allocation is constrained to maintain balance.

Randomization does not automatically guarantee a useful experiment. The sample must be large enough to detect an effect that matters. Power depends on the significance level, desired power, outcome variability, treatment allocation, and minimum detectable effect. For a continuous outcome, greater variance or a smaller target effect requires a larger sample. For binary outcomes, baseline conversion rates and the practical meaning of a change are central to planning.

A confidence interval communicates both the estimated effect and its uncertainty. A narrow interval around a small effect may be more useful than a statistically significant but imprecise estimate. Statistical significance should therefore be separated from practical significance. A change can be detectable but economically irrelevant, or valuable but difficult to detect with a small sample.

Blocking and Stratification

Blocking improves precision when units can be grouped into relatively homogeneous blocks before treatment assignment. Suppose an online retailer expects treatment effects to differ by country and baseline activity. It can form blocks using country and activity category, then randomize treatment within each block. Comparisons are made among similar units rather than across highly heterogeneous groups.

Blocking is particularly valuable when a prognostic variable strongly predicts the outcome. It also protects against accidental imbalance in small samples. However, blocks must be defined before treatment and should not be based on post-treatment information. Excessive blocking can create very small cells and complicate implementation.

In analysis, a blocked experiment may be represented as

\[

Y_{ij}=\mu+\tau T_{ij}+\beta_j+\varepsilon_{ij},

\]

where \(\beta_j\) represents the effect of block \(j\). The treatment coefficient estimates the treatment difference after accounting for systematic block variation. Covariate adjustment can similarly improve precision in a randomized experiment, provided it is based on pre-treatment variables.

Factorial Experiments

A factorial design studies two or more factors simultaneously. In a 2 × 2 experiment, factor A might be email subject line and factor B might be delivery time. Participants are assigned to four combinations: A1B1, A1B2, A2B1, and A2B2. This design estimates two main effects and their interaction.

The main effect of A is the average difference between A1 and A2 across levels of B. The interaction effect asks whether the effect of A changes depending on B. For example, a concise subject line may improve open rates for morning delivery but reduce them for evening delivery. Examining only average effects would conceal this interaction.

Factorial designs are efficient because one experiment can address several decisions. Their main limitation is interpretive complexity, particularly when there are many factors or when interactions are substantial. Researchers should specify plausible interactions in advance and avoid treating every subgroup pattern as confirmatory evidence.

ANOVA as a Framework for Experimental Analysis

Analysis of variance decomposes outcome variability into systematic components attributable to experimental factors and residual variation. In a one-way ANOVA with \(k\) groups, the total sum of squares is partitioned as

\[

SS_T=SS_B+SS_W,

\]

where \(SS_B\) is between-group variation and \(SS_W\) is within-group variation. The F statistic compares the mean square between groups with the mean square within groups:

\[

F=\frac{MS_B}{MS_W}.

\]

The null hypothesis is that all group means are equal. A significant omnibus F test indicates that at least one mean differs, but it does not identify which groups differ. Planned contrasts or appropriately adjusted post-hoc comparisons are then required.

In a randomized experiment with two groups, the difference in means and the corresponding t test are equivalent to a one-factor ANOVA. ANOVA becomes especially useful for factorial designs, blocked experiments, and models containing covariates. Its assumptions include independent errors, appropriate treatment of the outcome scale, and reasonably stable variance. Robust standard errors, transformations, generalized linear models, or random-effects models may be preferable when these assumptions are doubtful.

An important distinction is between experimental factors and nuisance variables. A nuisance variable is not the principal focus but explains outcome variation, such as site, batch, day, or machine. Blocking and covariate adjustment account for nuisance variation without confusing it with treatment effects.

Online A/B Testing in Practice

An A/B test is a randomized experiment in which users are exposed to version A or version B of a product, message, algorithm, or interface. A typical workflow is:

1. State a decision-oriented hypothesis and primary metric.

2. Define eligibility, randomization unit, treatment variants, and exposure rules.

3. Estimate sample size and test duration.

4. Implement assignment using a stable randomization mechanism.

5. Verify balance, exposure, logging, and data quality.

6. Analyse the pre-specified primary outcome and relevant secondary outcomes.

7. Interpret effect size, interval, heterogeneity, costs, and risks.

8. Decide whether to launch, revise, continue, or reject the intervention.

The randomization unit must prevent contamination. If users share an account or influence one another, individual-level assignment may allow treatment to spill into the control group. Cluster randomization, in which entire teams, stores, or communities are assigned, may be more appropriate, although it usually requires a larger sample.

Metrics should correspond to the decision. A product change may increase click-through rate while decreasing completed purchases or increasing customer complaints. A guardrail metric, such as latency or cancellation rate, can prevent a narrow primary metric from masking harm. Ratio metrics require care because the numerator and denominator may be correlated; user-level aggregation or suitable regression methods are often preferable to treating every event as independent.

Repeated peeking at results can inflate the false-positive rate if ordinary fixed-sample tests are used. This does not mean that monitoring is prohibited. Sequential testing procedures, alpha-spending methods, or Bayesian decision rules can support continuous monitoring when specified appropriately. Stopping because an early estimate happens to be favourable is not equivalent to a planned stopping rule.

Multiple comparisons create another risk. Testing many metrics, segments, and variants increases the chance of finding a seemingly positive result by chance. Researchers should identify a primary outcome, control the family-wise error rate or false discovery rate when appropriate, and label exploratory findings clearly.

Internal and External Validity

Internal validity concerns whether the estimated effect is credible for the units and conditions studied. Randomization supports internal validity, but it can be weakened by noncompliance, differential attrition, faulty exposure, interference, or informative missingness. An intention-to-treat analysis estimates the effect of assignment, preserving the benefits of randomization. A per-protocol analysis estimates the effect among those who followed the protocol but may be confounded because compliance is not random.

External validity concerns generalization. An experiment among frequent users during a holiday period may not represent new users or ordinary weeks. Treatment effects can vary by population, setting, implementation quality, and competing interventions. Generalization should therefore be justified rather than assumed. Replication across relevant contexts and analysis of pre-specified effect modifiers improve confidence.

Heterogeneous treatment effects are scientifically and managerially important. An average positive effect may conceal harm for a subgroup. Conversely, a near-zero average may result from strong benefits for some users and harms for others. Subgroup analysis should use credible pre-treatment variables, adequate sample sizes, interaction models, and cautious interpretation.

When Randomization Is Not Available

Observational data do not provide random treatment assignment, but several designs can approximate a counterfactual under explicit assumptions.

Difference-in-differences compares changes over time in a treated group with changes in a comparison group:

\[

\hat\tau_{DiD}=(\bar Y_{T,after}-\bar Y_{T,before})-(\bar Y_{C,after}-\bar Y_{C,before}).

\]

Its central assumption is parallel trends: absent treatment, the treated and comparison groups would have changed similarly. Pre-treatment trends can provide evidence, but cannot prove this assumption. Anticipation, concurrent policies, and changing group composition threaten validity.

Regression discontinuity exploits a treatment rule based on a cutoff, such as eligibility above a score of 70. Units just above and below the threshold may be comparable. The effect is local to the cutoff, and credibility requires that units cannot precisely manipulate the assignment variable and that other outcomes do not jump at the threshold.

Instrumental variables use a variable that affects treatment but influences the outcome only through treatment. For example, an assignment lottery may serve as an instrument for programme participation. The exclusion restriction is strong and often difficult to defend. Under additional assumptions, the resulting estimate commonly applies to compliers rather than the entire population.

Interrupted time series examines whether the level or slope of an outcome changes after an intervention. It requires sufficient pre-intervention data and attention to seasonality, autocorrelation, concurrent shocks, and changes in measurement.

Matching and propensity-score methods can balance measured covariates, but they do not remove bias from unmeasured confounders. A propensity score is a design aid, not a guarantee of causality. Regression adjustment, weighting, matching, and doubly robust estimators all depend on assumptions about treatment assignment, overlap, and outcome modelling.

Causal Graphs and Confounding

A directed acyclic graph (DAG) makes causal assumptions visible. A confounder is a common cause of treatment and outcome. For example, customer tenure may influence both eligibility for a retention offer and the probability of renewal. Failing to adjust for tenure can create a spurious treatment association.

A backdoor path is a non-causal path connecting treatment and outcome. Adjustment should block relevant backdoor paths, usually by conditioning on pre-treatment confounders. Researchers should not adjust automatically for every available variable. A mediator lies on the causal pathway from treatment to outcome; controlling for it may remove part of the total treatment effect. A collider is caused by two variables; conditioning on it can create an association that was not previously present.

This framework clarifies why post-treatment variables are dangerous. If treatment changes engagement and engagement affects retention, controlling for engagement estimates a direct effect rather than the total effect and may introduce bias if engagement is measured with error or affected by other causes.

Illustrative Case Study: A Delivery Platform Experiment

Background. A fictional food-delivery platform considers a redesigned order-tracking screen. Product managers believe that clearer status information will reduce customer support contacts and increase repeat orders.

Situation and problem. The initial observational comparison shows that users who viewed the new screen had higher repeat-order rates. However, the new screen was initially enabled for highly engaged users, who were already more likely to return. The product team must determine whether the screen itself causes improvement.

Approach. The team defines the account as the randomization unit and assigns eligible accounts to the existing screen or the new screen using a persistent random hash. The primary outcome is repeat ordering within 30 days. Secondary outcomes are support contacts, delivery-related complaints, and app latency. Support contacts are designated as a guardrail because reducing contact by making help harder to find would be unacceptable.

Before launch, the team conducts a power analysis based on the historical repeat-order rate and a minimum effect considered commercially meaningful. Randomization is stratified by country and prior-month order frequency. Assignment remains fixed for the test period to avoid users experiencing both versions. Instrumentation records assignment, exposure, order events, support contacts, and latency.

Analysis. The intention-to-treat difference in repeat-order rates is estimated with a confidence interval. A regression model adjusts for the pre-treatment blocking variables to improve precision. The team checks balance and exposure rates, but does not remove users simply because they did not click the screen; doing so would change the estimand and potentially introduce selection bias. A factorial extension is considered for a future test combining the tracking screen with proactive delay notifications, because the effects may interact.

Outcome. Suppose the new screen produces a modest increase in repeat ordering with a confidence interval excluding zero, while support contacts fall and latency remains unchanged. The result supports deployment for the tested population. However, the team reports that the experiment does not establish the effect for users excluded from the test or for markets with different delivery processes. It also schedules monitoring after rollout because novelty effects and operational changes may alter the result.

Learning points. The case illustrates why causal evidence requires more than an observed association. Clear estimands, persistent randomization, pre-treatment stratification, guardrail metrics, intention-to-treat analysis, and attention to generalization are all part of responsible experimentation.

Common Failure Modes and Professional Judgement

A frequent error is randomizing after treatment has already been selectively offered. This creates the appearance of experimentation without its protection against confounding. Another is randomizing by event while analysing as if events were independent, even though many events come from the same user. Standard errors then become too small.

Attrition is problematic when dropout differs by treatment and is related to potential outcomes. Missing outcomes should be investigated rather than silently discarded. Noncompliance requires distinguishing assignment effects from treatment-received effects. Spillovers violate the assumption that one unit’s treatment does not affect another unit’s outcome, often called the stable unit treatment value assumption (SUTVA).

Analysts should avoid changing the primary metric, eligibility criteria, or stopping rule after seeing results without clearly labelling the analysis as exploratory. A statistically significant result can be produced through extensive searching. Conversely, failure to reject the null hypothesis is not proof that the treatment has no effect; it may reflect low power or a wide confidence interval.

Ethically, experiments require proportionality, respect for privacy, and protection from avoidable harm. Users should not be exposed to serious risk merely to improve a small business metric. Sensitive interventions may require informed consent, independent review, or regulatory approval. Data minimization, access control, retention limits, and transparent governance are essential when experimentation uses behavioural or personal data. Automated experimentation systems should preserve audit logs, version assignments, and reproducible analysis code.

Emerging Practice in Data-Driven Experimentation

Modern organizations increasingly use experimentation platforms that automate randomization, exposure logging, metric computation, and monitoring. Machine-learning systems can assist with heterogeneous treatment-effect estimation, adaptive allocation, and experiment prioritization. These tools can improve efficiency but also introduce risks: adaptive algorithms may complicate inference, optimization may favour short-term metrics, and black-box subgroup findings may be unstable.

Causal machine learning is most useful when it complements, rather than replaces, design. Double machine learning, causal forests, Bayesian hierarchical models, and uplift modelling can estimate treatment heterogeneity while controlling complex covariates. Their credibility still depends on data quality, overlap, treatment definition, and assumptions about confounding. The practical standard remains clear: state the causal question, make assumptions explicit, design comparison groups carefully, and communicate uncertainty.

Best Practices for Experimenters

A defensible experimental programme should:

  • define the estimand, unit, treatment, control, population, and time horizon before data collection;
  • randomize with a reproducible mechanism and prevent contamination where possible;
  • use blocking or covariate adjustment based only on pre-treatment information;
  • select one primary outcome and meaningful guardrail metrics;
  • conduct power and minimum-detectable-effect planning;
  • monitor data quality without repeatedly applying unplanned significance tests;
  • report effect sizes and confidence intervals, not only p-values;
  • distinguish intention-to-treat, per-protocol, and treatment-on-the-treated interpretations;
  • investigate missingness, noncompliance, interference, and heterogeneous effects;
  • document deviations, exploratory analyses, and limitations;
  • assess ethical, privacy, operational, and generalization consequences before deployment.

Chapter Summary

Experimental design provides the foundation for credible causal claims. Potential outcomes define treatment effects through counterfactual comparisons, while randomization makes treatment groups comparable in expectation. Blocking improves precision and protects balance; factorial designs estimate main effects and interactions; ANOVA decomposes variation and supports multi-factor analysis. Online A/B testing extends these principles to digital products but requires careful attention to randomization units, metrics, power, contamination, sequential monitoring, and multiple comparisons.

When randomization is unavailable, difference-in-differences, regression discontinuity, instrumental variables, interrupted time series, matching, and adjustment can provide evidence under explicit assumptions. Causal graphs help distinguish confounders, mediators, and colliders. Across all designs, validity depends on implementation, measurement, missing data, compliance, interference, and the match between the target population and the study sample. Responsible data science treats causal inference as a combination of design, statistical analysis, domain knowledge, transparency, and ethical judgement.

Key Terms

Counterfactual: The potential outcome that would have occurred under an alternative treatment condition.

Potential outcome: The outcome a unit would experience under a specified treatment or control condition.

Average treatment effect (ATE): The average difference between treatment and control potential outcomes in a target population.

Average treatment effect on the treated (ATT): The average causal effect among units that received treatment.

Randomization: Assignment of units to conditions using a chance mechanism.

Treatment effect: A causal difference in outcomes attributable to an intervention.

Estimand: The precisely defined causal quantity a study seeks to estimate.

Blocking: Grouping similar units before random assignment to improve balance and precision.

Factorial design: An experiment that varies two or more factors simultaneously.

Interaction: A condition in which the effect of one factor depends on the level of another factor.

ANOVA: A method that partitions outcome variation into systematic and residual components.

A/B test: A randomized comparison between two versions of a product, message, or intervention.

Guardrail metric: A secondary measure used to detect harmful consequences of an intervention.

Confounder: A variable that causally influences both treatment assignment and outcome.

Selection bias: Distortion caused by systematic differences in who enters, remains in, or is observed in comparison groups.

Intention-to-treat effect: The effect of being assigned to treatment, regardless of compliance.

Difference-in-differences: An estimator comparing changes over time between treated and comparison groups.

Regression discontinuity: A quasi-experiment based on treatment assignment at a known threshold.

Instrumental variable: A variable that affects treatment but affects the outcome only through treatment under an exclusion assumption.

Collider: A variable caused by two other variables; conditioning on it can induce spurious association.

Review Questions

Short Answer Questions

1. Why does randomization help estimate a causal effect?

2. Distinguish the ATE from the ATT.

3. What is the purpose of blocking in an experiment?

4. Why can repeated unplanned peeking at A/B-test results be problematic?

5. Define a collider and explain why conditioning on one may create bias.

Long Answer Questions

1. Explain the potential-outcomes framework and the fundamental problem of causal inference. How do randomized experiments address it?

2. Describe how a factorial experiment estimates main effects and interactions. Give an example in a digital product setting.

3. Discuss the design and analysis requirements of a reliable online A/B test.

4. Explain ANOVA, including the decomposition of variation and interpretation of the F statistic.

5. Compare difference-in-differences, regression discontinuity, instrumental variables, and interrupted time series, including a key assumption for each.

Analytical / Application Questions

1. A company gives a new retention offer only to customers who have contacted support in the previous month. Customers receiving the offer renew more often. Identify possible sources of bias and propose a randomized design.

2. An A/B test increases click-through rate but also increases cancellations and latency. How should the product team evaluate the result and decide whether to deploy?

3. A policy is assigned to municipalities with unemployment rates above a fixed threshold. Explain how you would use a regression-discontinuity design and what validity checks would be necessary.

22. Multiple Choice Questions with Answers

Question 1

Which quantity is defined as E[Y(1) − Y(0)] for a target population?

A. Average treatment effect

B. Average treatment effect on the treated

C. Intention-to-treat effect only

D. Selection bias

Correct Answer: A. Average treatment effect

Question 2

A researcher randomizes users within country and prior-activity groups. What is the main purpose of this procedure?

A. To guarantee a statistically significant result

B. To improve balance and precision using blocking

C. To eliminate measurement error

D. To estimate only post-treatment effects

Correct Answer: B. To improve balance and precision using blocking

Question 3

In a 2 × 2 factorial experiment, an interaction exists when:

A. Both factors have identical sample sizes

B. The outcome has no residual variation

C. The effect of one factor depends on the level of the other

D. Each factor is tested in a separate experiment

Correct Answer: C. The effect of one factor depends on the level of the other

Question 4

Why is an intention-to-treat analysis often preferred in a randomized experiment with noncompliance?

A. It preserves the original benefits of random assignment

B. It guarantees a larger treatment effect

C. It excludes participants who did not follow instructions

D. It estimates only the effect among perfect compliers

Correct Answer: A. It preserves the original benefits of random assignment

Question 5

A product team repeatedly checks an ordinary fixed-sample p-value and stops whenever it falls below 0.05. What is the main concern?

A. Blocking bias

B. Inflated false-positive risk

C. Loss of external validity caused by randomization

D. Automatic violation of SUTVA

Correct Answer: B. Inflated false-positive risk

Question 6

A variable causes both treatment assignment and the outcome. In a causal analysis, this variable is most accurately called a:

A. Mediator

B. Collider

C. Confounder

D. Guardrail metric

Correct Answer: C. Confounder

Question 7

Difference-in-differences relies centrally on which assumption?

A. Treatment effects are identical for every individual

B. Treated and comparison groups would have followed parallel trends without treatment

C. The treatment is assigned by a random number generator

D. The outcome cannot vary over time

Correct Answer: B. Treated and comparison groups would have followed parallel trends without treatment

Question 8

A treatment is assigned to units scoring above 70, and outcomes are compared just above and below 70. Which design is being used?

A. Regression discontinuity

B. Factorial randomization

C. One-way blocking

D. Matched-pairs ANOVA

Correct Answer: A. Regression discontinuity

Question 9

Why might adjusting for a post-treatment mediator be inappropriate when estimating a total treatment effect?

A. It can remove part of the pathway through which treatment operates

B. It always increases the sample size

C. It converts a randomized study into a factorial design

D. It guarantees confounding

Correct Answer: A. It can remove part of the pathway through which treatment operates

Question 10

An A/B test shows a small statistically significant increase in clicks, but purchases decline and complaints rise. What is the most appropriate interpretation?

A. Deploy immediately because statistical significance settles the decision

B. Ignore all secondary outcomes because they were not randomized

C. Evaluate the primary and guardrail metrics together before deciding

D. Conclude that randomization failed without further investigation

Correct Answer: C. Evaluate the primary and guardrail metrics together before deciding

Statistics and Probability for Data Science
Chapter 9 of 15

Statistics and Probability for Data Science

Chapter 10
Nonparametric, Robust and Resampling Methods

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

10. Nonparametric, Robust and Resampling Methods

Introduction and Context

Many statistical procedures are developed under assumptions about the population from which data arise. Common assumptions include normality, equal variances, independence, linearity, and the measurement of variables on an interval or ratio scale. These assumptions are useful because they make probability calculations tractable and often lead to powerful tests and efficient estimators. However, real data frequently contain outliers, skewed distributions, ordinal measurements, small samples, dependence, or complex sampling structures. In such situations, a classical method may produce misleading conclusions even when its calculations are technically correct.

This chapter develops three related responses to these difficulties. Nonparametric methods reduce reliance on a specified population distribution, often by replacing raw measurements with ranks or by constructing a reference distribution directly from the observed data. Robust methods seek estimates and procedures that remain stable when the data contain contamination, extreme observations, or departures from ideal assumptions. Resampling methods repeatedly reuse the available sample to approximate sampling distributions, standard errors, confidence intervals, or null distributions. Permutation tests, the bootstrap, and cross-validation are especially important in data science because they can be applied to statistics and predictive models for which simple theoretical formulas are unavailable.

These methods are not assumption-free. Every method depends on assumptions concerning independence, exchangeability, sampling, or the statistic being estimated. The central professional skill is therefore not to choose a “distribution-free” method automatically, but to match the method to the data-generating process, the research question, and the consequences of error.

Learning Objectives

After studying this chapter, the student should be able to:

1. Explain why nonparametric, robust, and resampling methods are needed.

2. Select and interpret rank-based tests for common study designs.

3. Distinguish robustness from distribution-free inference.

4. Construct and interpret permutation tests and bootstrap confidence intervals.

5. Explain the logic of cross-validation and identify sources of data leakage.

6. Evaluate assumptions, limitations, and ethical implications in practical applications.

7. Use software outputs critically rather than treating computational results as automatic evidence.

When Classical Assumptions Become Problematic

A normality assumption concerns the distribution of observations or, in regression, often the distribution of errors conditional on predictors. It does not mean that every variable in a data set must be normally distributed. Nevertheless, strong skewness, heavy tails, zero-inflation, censoring, or a small sample can make normal-theory procedures unreliable. A single extreme observation can substantially alter a mean, standard deviation, correlation, or regression coefficient.

Measurement scale also matters. A satisfaction response recorded as “very dissatisfied” through “very satisfied” is ordinal: the ordering is meaningful, but the numerical distance between adjacent categories need not be equal. Applying a t-test to such data may be defensible in some large-sample settings, but it should not be treated as automatically appropriate. Rank methods are often better aligned with the information actually present in the measurements.

A useful diagnostic sequence is:

  • What is the estimand: a mean, median, probability of superiority, association, prediction error, or another quantity?
  • Are observations independent, paired, clustered, or repeated over time?
  • Are extreme values errors, valid rare cases, or evidence of a mixture of populations?
  • Does the proposed method require exchangeability, symmetry, equal distributions, or only independence?
  • Would a transformation, robust estimator, nonparametric method, or resampling approach best address the problem?

A method should be chosen because its assumptions fit the scientific question—not merely because a normality test has produced a small or large p-value.

Rank-Based Inference

Ranks and their interpretation

To rank observations, order them from smallest to largest and replace each value with its position. Tied values receive their average rank. Ranking discards some information about the distances between observations but preserves order and reduces the influence of extreme numerical values. A rank-based result commonly concerns whether one group tends to produce larger observations than another, rather than whether its arithmetic mean is larger.

The Mann–Whitney U test, also called the Wilcoxon rank-sum test, compares two independent groups. All observations are ranked together, and the ranks belonging to one group are summed. Under the null hypothesis of identical distributions, group labels are exchangeable. If the two distributions have a similar shape, the test is often interpreted as a test of location or median difference. Without that shape condition, it is more accurately interpreted as evidence that one group tends to yield larger values than the other.

For two paired or matched samples, the Wilcoxon signed-rank test ranks the absolute nonzero differences within pairs and uses their signs. It tests whether the distribution of paired differences is symmetric around zero under its usual interpretation. It is not simply a nonparametric substitute for every paired t-test: symmetry of differences is relevant, and zero differences affect the effective sample size.

For three or more independent groups, the Kruskal–Wallis test ranks all observations and compares the rank sums across groups. A significant result indicates that at least one group differs in distribution. It does not identify which groups differ; post hoc pairwise comparisons require multiplicity control, such as the Holm procedure. For repeated measurements across three or more conditions, the Friedman test ranks observations within each subject or block and tests whether conditions differ systematically.

Association through ranks

The Spearman rank correlation is the Pearson correlation calculated on ranks. It measures monotonic association: as one variable increases, the other tends to increase or decrease. It can detect a strong curved monotonic relationship that Pearson correlation may summarize poorly, but it will not necessarily detect a nonmonotonic relationship. Kendall’s tau is based on concordant and discordant pairs and often has a useful probabilistic interpretation, especially for ordinal data. Neither coefficient establishes causation, and both require attention to ties, dependence, and confounding.

Effect sizes and reporting

A p-value from a rank test does not communicate the size or practical importance of an effect. Reports should include a suitable effect size, confidence interval where available, sample sizes, the direction of the effect, and a description of the data. Examples include the Hodges–Lehmann estimate of a location shift, rank-biserial correlation, probability of superiority, or Kendall’s tau. A result such as “the probability that a randomly selected treated observation exceeds a randomly selected control observation is estimated at 0.68” is often more informative than a statement that the groups are statistically different.

Robust Estimation and Robust Models

A procedure is robust when its performance changes relatively little under plausible violations of its assumptions or the presence of a limited number of unusual observations. Robustness is not equivalent to being nonparametric. A robust regression model may be parametric, and a rank test can be sensitive to distributional differences even though it does not specify a normal population.

The median has a breakdown point of approximately 50 percent: nearly half the observations must be contaminated before it can be driven arbitrarily far. The mean has a breakdown point of zero because one arbitrarily large observation can change it without bound. The trimmed mean removes a fixed proportion of observations from both tails before averaging and can provide a useful compromise between the mean and median. The winsorized mean replaces extreme observations with less extreme retained values rather than deleting them.

The ordinary standard deviation is highly sensitive to outliers. The median absolute deviation (MAD) is a robust scale estimator based on the median of absolute deviations from the median. For approximately normal data, a consistency adjustment is often applied when using MAD as an estimate comparable to the standard deviation. The interquartile range (IQR), the difference between the third and first quartiles, is another robust measure of spread.

In regression, least squares minimizes squared residuals, so large residuals receive disproportionate influence. Alternatives include least absolute deviations, which minimizes absolute residuals; M-estimation, which uses a less rapidly increasing loss function; and quantile regression, which models conditional quantiles such as the median rather than the conditional mean. A robust method should not be used to hide genuine influential observations. Analysts must investigate whether an unusual value represents data error, fraud, a rare but important event, or a different subgroup.

Robustness can also be examined through sensitivity analysis. A responsible analysis may compare the mean and median, ordinary and robust regression, or results with and without a verified data error. If the substantive conclusion changes, that instability should be reported rather than concealed.

Permutation Tests: Building a Null Distribution from the Data

A permutation test evaluates a statistic by repeatedly rearranging labels or signs in ways permitted by the null hypothesis. Suppose two independent groups are compared using the difference in means, a difference in medians, or a rank statistic. Under the null hypothesis that group membership is exchangeable, the observed labels can be shuffled many times. For each shuffle, the statistic is recalculated. The resulting values form an empirical null distribution.

If the observed statistic is unusually extreme relative to this distribution, the null hypothesis is questioned. With B random permutations, a conservative Monte Carlo p-value is commonly calculated as

p = (1 + number of permuted statistics at least as extreme as the observed statistic) / (B + 1).

The added one avoids reporting a zero p-value merely because no sampled permutation was as extreme. If all possible permutations are enumerated, the test is exact conditional on the observed data and the exchangeability assumption. Random permutations provide an approximation whose precision improves with B.

The permutation scheme must reflect the design. In a paired experiment, signs of within-pair differences may be permuted rather than observations being freely mixed. In a blocked or clustered design, labels should be shuffled within appropriate blocks, or entire clusters should be resampled or permuted. Time-series observations generally cannot be freely permuted because temporal dependence destroys exchangeability. In machine learning, permutation tests must also preserve the train-test structure.

Permutation tests are attractive because the statistic can be chosen to match the practical question, including a complex model-performance difference. However, a permutation test does not prove that groups are identical in every respect; its validity depends on the null hypothesis and permissible rearrangements.

Bootstrap Inference

The bootstrap estimates sampling uncertainty by treating the observed sample as an approximation to the population. A nonparametric bootstrap repeatedly draws samples of size n with replacement from the observed n observations. For each resample, the statistic is computed. The empirical distribution of these bootstrap statistics approximates the sampling distribution.

The bootstrap can estimate a standard error, bias, or confidence interval for statistics such as a median, regression coefficient, prediction metric, or ratio. A basic bootstrap confidence interval is based on the estimated standard error, while a percentile interval uses bootstrap quantiles directly. The bias-corrected and accelerated (BCa) interval adjusts for bias and skewness and can perform better in some settings, although it requires careful implementation. A confidence interval is not a guarantee that the parameter lies inside the calculated range; it is a procedure intended to achieve a stated long-run coverage under relevant assumptions.

The bootstrap is not universally reliable. With a very small sample, the empirical population may not represent the population tails. It can perform poorly for extreme quantiles, maxima, non-smooth statistics, highly dependent observations, and parameters near boundaries. For time series, a block bootstrap preserves local dependence. For clustered data, resampling should generally occur at the cluster level. In stratified surveys, the design should be reflected in the resampling plan. A model-based or parametric bootstrap may be appropriate when a credible probability model is available.

A practical workflow is to define the statistic before resampling, choose a design-consistent resampling unit, generate a sufficiently large number of replicates, inspect the bootstrap distribution, calculate an appropriate interval, and perform sensitivity checks. The number of replicates reduces Monte Carlo error but cannot repair a biased sample or an inappropriate resampling design.

Cross-Validation and Resampling for Prediction

Cross-validation estimates how a predictive method may perform on unseen data. In k-fold cross-validation, observations are divided into k folds. The model is trained on k−1 folds and evaluated on the remaining fold; this is repeated until every observation has served as validation data. The average loss estimates predictive performance for data generated in a similar way. Repeated or stratified k-fold procedures can reduce variability or preserve class proportions.

Leave-one-out cross-validation uses n folds and trains n models, each leaving out one observation. It uses data efficiently but can be computationally expensive and may have high variance. A separate test set is preferable when sufficient data are available. In nested cross-validation, an inner loop selects hyperparameters and an outer loop estimates performance. This prevents optimistic bias caused by tuning a model on the same validation information used to report its performance.

Cross-validation is a data-analysis procedure, not merely a software option. All preprocessing that learns from data—imputation, scaling, feature selection, dimensionality reduction, and target encoding—must be fitted within each training fold. Otherwise, information from the validation fold leaks into the model. For time-dependent data, training must precede validation chronologically. For multiple records from the same person, all records should normally remain in one fold. The split must reflect the deployment setting.

Performance should be accompanied by uncertainty estimates and relevant metrics. Accuracy can be misleading in class-imbalanced problems; precision, recall, F1 score, area under the precision–recall curve, calibration, or cost-sensitive loss may be more appropriate. A small difference in cross-validated performance may not justify adopting a more complex or less interpretable model.

An Illustrative Case: Evaluating a Digital Rehabilitation Programme

Background and problem

A hospital introduces a mobile rehabilitation programme for patients recovering from knee surgery. Recovery time, measured in days until a clinically defined mobility milestone, is recorded for 34 patients using the programme and 31 patients receiving standard advice. The recovery times are right-skewed, and two programme users have unusually long recoveries because of unrelated complications. The research team wants to estimate whether the programme is associated with faster recovery and whether a predictive model can identify patients likely to require extended support.

Analysis

A comparison of means is strongly affected by the two long recoveries. The team first displays the distributions and reports medians, IQRs, and individual observations. Because the groups are independent and the scientific question concerns whether recovery tends to be faster, the Mann–Whitney test is suitable as a primary rank-based analysis. The team also reports a Hodges–Lehmann location estimate and a confidence interval obtained through a design-appropriate bootstrap. It does not describe the test as a pure median test without checking whether the group distributions have comparable shapes.

To assess the robustness of the conclusion, analysts compare the ordinary mean difference, a 20 percent trimmed mean difference, and a robust regression adjusted for age and baseline mobility. The two unusually long recoveries are clinically verified rather than deleted. Their inclusion is therefore part of the primary analysis, while an analysis excluding complications is clearly labelled as sensitivity analysis.

For prediction, the team develops a model for extended recovery using age, baseline mobility, comorbidities, and early app activity. All imputation, scaling, and feature selection occur inside the training folds. Because some patients contribute multiple app records, splitting is performed at the patient level. Nested cross-validation is used to tune the model and estimate performance. Calibration and recall are reported because missing a patient who needs additional support is more consequential than generating an extra follow-up alert.

Outcome and learning points

Suppose the rank-based analysis indicates a tendency toward shorter recovery in the programme group, while the mean-based estimate is less stable. The appropriate conclusion is not that the programme has been proven effective, but that the observed data provide evidence of an association whose magnitude should be interpreted with its interval and study design. If allocation was not randomized, unmeasured confounding remains possible.

The case illustrates five principles: identify the estimand; inspect the data before selecting a test; use robustness checks without deleting inconvenient observations; respect the sampling and dependence structure during resampling; and separate predictive validation from causal claims.

Limitations, Risks, and Professional Judgement

Nonparametric tests may have lower power than well-specified parametric tests and may answer a different question from the one originally intended. Rank procedures can lose information through ties and may be affected by unequal distributional shapes. Robust procedures can downweight observations that are scientifically important. A bootstrap cannot create information absent from a biased or tiny sample. Permutation tests fail when the proposed rearrangements violate exchangeability. Cross-validation can be optimistic when repeated measurements, temporal ordering, or preprocessing leakage is ignored.

Multiple testing is another important risk. Searching across many statistics, subgroups, model specifications, and resampling choices increases the chance of a seemingly impressive result by chance. The analysis plan should identify primary outcomes where possible, control multiplicity when appropriate, and disclose exploratory analyses. Reproducible code, fixed random seeds where practical, documentation of the resampling design, and reporting of sensitivity analyses improve credibility.

Ethically, robust methods must not be used to erase disadvantaged or unusual cases. Outliers may represent safety incidents, rare diseases, or groups poorly served by a system. In predictive analytics, subgroup performance should be assessed separately, and validation data must be protected from unauthorized use. Automated model selection does not remove responsibility for fairness, privacy, interpretability, or appropriate human oversight.

Emerging Computational Practice

Modern statistical software makes thousands of resamples and repeated model fits feasible. Parallel computing, automatic differentiation, and probabilistic programming support complex bootstrap and simulation workflows. Libraries for cross-validation can automate fold construction, but default settings may not understand clusters, time order, or leakage. Analysts should inspect the generated splits rather than assuming that a software default is valid.

Simulation is increasingly used to compare procedures under plausible data-generating conditions. For example, an analyst can simulate skewed distributions, contamination, unequal variances, or clustered observations and compare bias, coverage, power, and prediction error. Such simulations do not replace empirical evidence, but they make the consequences of methodological choices visible. Contemporary practice is moving toward transparent computational notebooks, preregistered analysis plans, and reporting that distinguishes sampling uncertainty from model uncertainty.

Best-Practice Workflow

A defensible workflow begins with the research question and estimand. Next, the analyst examines measurement scale, dependence, missingness, outliers, and the intended deployment or inference population. A method is selected by its assumptions and target, not by a desire to avoid all parametric structure. The primary analysis is complemented by an effect size and uncertainty interval, and important assumptions are checked through graphical and substantive diagnostics.

For resampling, the unit of resampling must match the design. Permutation schemes must preserve the null hypothesis; bootstrap schemes must preserve dependence and sampling structure; cross-validation splits must reproduce future use. Preprocessing and tuning must occur inside training data. Finally, analysts should report the number of replicates, randomization or fold procedure, performance metric, uncertainty method, sensitivity analyses, and limitations in language accessible to decision-makers.

Chapter Summary

Nonparametric methods use ranks or empirical reference distributions to reduce reliance on specified population forms. Mann–Whitney, Wilcoxon signed-rank, Kruskal–Wallis, Friedman, Spearman, and Kendall procedures address common independent, paired, multi-group, repeated-measures, and association questions. Their interpretation depends on the estimand, ties, distributional shape, and study design.

Robust statistics reduce sensitivity to outliers and assumption violations through medians, trimmed means, MAD, robust regression, and quantile regression. Robustness is distinct from being distribution-free, and unusual observations must be investigated rather than automatically removed. Permutation tests construct null distributions by valid rearrangements, while bootstrap methods approximate sampling uncertainty by resampling with replacement. Both require careful attention to exchangeability and dependence. Cross-validation estimates predictive performance, but leakage, inappropriate splitting, and poor metric selection can invalidate it. Across all methods, sound statistical judgement requires transparent assumptions, effect sizes, uncertainty, sensitivity analysis, and ethical attention to the consequences of decisions.

Key Terms

Rank: The position assigned to an observation after ordering the data.

Nonparametric method: A method that does not require a fully specified parametric population distribution.

Mann–Whitney U test: A rank-based test for comparing two independent groups.

Wilcoxon signed-rank test: A rank-based test for paired differences.

Kruskal–Wallis test: A rank-based test for comparing three or more independent groups.

Friedman test: A rank-based test for repeated or blocked measurements across several conditions.

Spearman correlation: Pearson correlation computed on ranks to measure monotonic association.

Kendall’s tau: An association measure based on concordant and discordant pairs.

Robustness: Relative stability of a procedure under departures from ideal assumptions.

Trimmed mean: A mean calculated after removing specified proportions from both tails.

Median absolute deviation: A robust scale measure based on absolute deviations from the median.

M-estimation: Robust estimation using a loss function designed to limit the influence of extreme residuals.

Permutation test: A test that constructs a null distribution by valid rearrangement of observations or labels.

Exchangeability: The condition that observations or labels may be rearranged without changing their joint distribution under a null hypothesis.

Bootstrap: Repeated sampling with replacement from observed data to approximate sampling uncertainty.

BCa interval: A bootstrap confidence interval adjusted for bias and acceleration.

Cross-validation: Repeatedly training and evaluating a model on separate data partitions.

Data leakage: Unauthorized transfer of information from validation or test data into model training.

Nested cross-validation: An outer validation loop combined with an inner tuning loop.

Probability of superiority: The probability that a randomly selected observation from one group exceeds one from another.

Review Questions

Short Answer Questions

1. Why can a rank-based method be preferable for ordinal data?

2. Distinguish robustness from being distribution-free.

3. What does exchangeability mean in a permutation test?

4. Why is the median less sensitive to extreme observations than the mean?

5. What is data leakage in cross-validation?

Long Answer Questions

1. Explain the assumptions, interpretation, and appropriate applications of the Mann–Whitney U, Wilcoxon signed-rank, Kruskal–Wallis, and Friedman tests.

2. Compare the bootstrap and permutation test, including their purposes, procedures, and assumptions.

3. Discuss robust location and scale measures and explain when each may be useful.

4. Describe how nested cross-validation prevents optimistic estimates of predictive performance.

5. Explain why dependence, clustering, and time ordering must influence a resampling design.

Analytical / Application Questions

1. A company compares customer waiting times under two service systems. The data are heavily right-skewed, contain several verified long waits, and are collected from the same branches over several days. Propose an analysis plan and justify the test, effect measure, robustness checks, and resampling strategy.

2. A classifier is tuned using feature selection before ten-fold cross-validation, producing an unusually high accuracy. Diagnose the methodological problem and redesign the validation workflow.

3. A hospital reports a significant Kruskal–Wallis result for four treatments but provides no pairwise comparisons or effect size. Explain what can and cannot be concluded, and recommend a complete reporting strategy.

22. Multiple Choice Questions with Answers

Question 1

Which interpretation is most appropriate for a Mann–Whitney U test when the two group distributions have different shapes?

A. It is always a test of equality of means.

B. It is evidence about whether one group tends to produce larger observations than the other.

C. It proves that the group medians are different.

D. It tests whether both groups are normally distributed.

Correct Answer: B. It is evidence about whether one group tends to produce larger observations than the other.

Question 2

Which procedure is most suitable for comparing three treatments measured repeatedly on the same participants?

A. Kruskal–Wallis test

B. Mann–Whitney U test

C. Friedman test

D. Independent permutation of all observations

Correct Answer: C. Friedman test

Question 3

Why is the median generally more robust than the mean?

A. It uses every numerical distance between observations.

B. It is unaffected by sample size.

C. It is less influenced by extreme observations.

D. It assumes the data are normally distributed.

Correct Answer: C. It is less influenced by extreme observations.

Question 4

In a permutation test comparing two independent groups, labels are shuffled because under the null hypothesis:

A. The observations are necessarily normally distributed.

B. Group labels are exchangeable under the specified null.

C. The sample sizes must be equal.

D. The statistic must be a mean.

Correct Answer: B. Group labels are exchangeable under the specified null.

Question 5

A bootstrap sample of size n is usually generated by:

A. Sampling n observations without replacement from a new population.

B. Permuting the original observations exactly once.

C. Sampling n observations with replacement from the observed sample.

D. Generating observations from a normal distribution regardless of the data.

Correct Answer: C. Sampling n observations with replacement from the observed sample.

Question 6

Which situation most clearly requires a special bootstrap design rather than an ordinary individual-observation bootstrap?

A. Independent observations with no grouping

B. A clustered sample in which several records come from each person

C. A data set with a numerical response

D. A data set containing a median

Correct Answer: B. A clustered sample in which several records come from each person

Question 7

A model’s feature scaling is fitted using the entire data set before cross-validation. This creates:

A. Underfitting

B. Data leakage

C. Exchangeability

D. A robust estimator

Correct Answer: B. Data leakage

Question 8

What is the principal purpose of nested cross-validation?

A. To guarantee zero prediction error

B. To remove the need for a test metric

C. To separate hyperparameter tuning from performance estimation

D. To ensure that all models are parametric

Correct Answer: C. To separate hyperparameter tuning from performance estimation

Question 9

Which statistic is generally most resistant to a single extremely large observation?

A. Arithmetic mean

B. Sample variance

C. Median

D. Least-squares slope

Correct Answer: C. Median

Question 10

A researcher obtains a significant Kruskal–Wallis test for four groups. What is the correct next conclusion?

A. Every pair of groups differs significantly.

B. At least one group differs, but further appropriate comparisons are needed to locate differences.

C. The group means are necessarily unequal.

D. The result proves a causal treatment effect.

Correct Answer: B. At least one group differs, but further appropriate comparisons are needed to locate differences.

Statistics and Probability for Data Science
Chapter 10 of 15

Statistics and Probability for Data Science

Chapter 11
Bayesian Statistics and Probabilistic Modelling

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

11. Bayesian Statistics and Probabilistic Modelling

Introduction and Context

Statistical inference is concerned with learning about uncertain quantities from data. In frequentist statistics, unknown parameters are treated as fixed but estimated through procedures whose long-run properties are studied. Bayesian statistics takes a different perspective: uncertainty about parameters is represented explicitly through probability distributions. Data then update that uncertainty. This makes Bayesian reasoning particularly suitable for data science, where analysts routinely combine historical information, expert knowledge, streaming observations, missing information, and complex predictive tasks.

Bayesian modelling is not merely a method for calculating an alternative confidence interval. It is a complete framework for specifying assumptions, learning from evidence, making predictions, and taking decisions under uncertainty. A Bayesian model has three central components: a prior distribution, a likelihood, and a posterior distribution. The prior describes knowledge or uncertainty before observing current data; the likelihood describes how the data arise under possible parameter values; and the posterior combines both sources of information.

The chapter develops these ideas from conjugate models to hierarchical models and modern computational methods. It also considers credible intervals, posterior prediction, Bayesian decision theory, Markov chain Monte Carlo (MCMC), variational inference, model criticism, and professional responsibilities associated with prior specification and probabilistic decision-making.

Learning Objectives

After completing this chapter, the learner should be able to:

1. Explain the logic of Bayesian inference and distinguish priors, likelihoods, posteriors, and posterior predictive distributions.

2. Construct and interpret Bayesian models for common data-generating processes.

3. Derive and use conjugate posterior distributions for binomial, Poisson, and normal models.

4. Distinguish credible intervals from confidence intervals and interpret them correctly.

5. Formulate hierarchical models and explain partial pooling.

6. Apply Bayesian decision theory using loss functions and posterior expected loss.

7. Explain the principles and diagnostics of MCMC and variational inference.

8. Evaluate prior sensitivity, computational convergence, predictive performance, fairness, and governance risks.

The Bayesian Framework: From Assumptions to Updated Beliefs

Let \(\theta\) denote an unknown parameter and \(y\) the observed data. Bayes’ theorem is

\[

p(\theta\mid y)=\frac{p(y\mid\theta)p(\theta)}{p(y)}.

\]

Here, \(p(\theta)\) is the prior distribution, \(p(y\mid\theta)\) is the likelihood, \(p(\theta\mid y)\) is the posterior distribution, and

\[

p(y)=\int p(y\mid\theta)p(\theta)d\theta

\]

is the marginal likelihood or evidence. In practice, the denominator often acts only as a normalising constant:

\[

p(\theta\mid y)\propto p(y\mid\theta)p(\theta).

\]

The prior is not necessarily subjective in a casual sense. It may represent previous experiments, domain knowledge, physical constraints, historical data, or a deliberately weakly informative assumption. A prior should be defensible, transparent, and assessed for sensitivity. A likelihood is a probability model for the observed data conditional on parameters. It is not a probability distribution over parameters. The posterior is the updated distribution after observing data.

A Bayesian model therefore has two layers. The data model describes observations, such as \(y_i\sim\text{Bernoulli}(p)\), while the parameter model describes uncertainty, such as \(p\sim\text{Beta}(\alpha,\beta)\). This separation is one reason Bayesian models can be extended naturally to multilevel and latent-variable settings.

Prior specification

A prior may be informative, weakly informative, or approximately non-informative. An informative prior meaningfully influences inference because credible prior knowledge exists. A weakly informative prior does not attempt to be neutral; instead, it rules out implausible values while allowing the data to dominate. For example, a prior that places almost all probability on realistic regression coefficients can improve computation and protect against extreme estimates.

A prior should be examined on the scale relevant to the scientific question. In regression, a normal prior on a coefficient may imply a very different distribution of predicted probabilities depending on the intercept and covariate scale. Prior predictive checking asks: if parameters are drawn from the prior and data are simulated from the model, do the simulated outcomes look plausible? This check should occur before fitting the model.

Likelihood and data-generating assumptions

The likelihood encodes assumptions about independence, sampling, measurement, missingness, and distributional form. If repeated observations are correlated but an independent likelihood is used, posterior uncertainty may be too small. If outliers are likely but a normal likelihood is imposed, parameter estimates and predictions can be distorted. Bayesian analysis does not remove the need for careful study design and appropriate probability models.

Posterior interpretation

A posterior probability has a direct probability interpretation conditional on the model and observed data. For example, \(P(\theta>0\mid y)=0.97\) means that, under the specified model, the posterior probability that \(\theta\) is positive is 0.97. This is different from saying that a fixed parameter has a 97% chance of being positive in a long-run repeated-sampling sense.

Conjugate Models: Exact Updating in Simple Settings

A prior is conjugate to a likelihood when the posterior belongs to the same distributional family as the prior. Conjugacy is valuable pedagogically and computationally because it provides transparent updating, although modern Bayesian modelling is not restricted to conjugate distributions.

Beta–binomial model

Suppose \(y\) successes are observed in \(n\) Bernoulli trials, with success probability \(p\):

\[

y\mid p\sim\text{Binomial}(n,p),\qquad p\sim\text{Beta}(\alpha,\beta).

\]

The posterior is

\[

p\mid y\sim\text{Beta}(\alpha+y,\beta+n-y).

\]

The prior mean is \(\alpha/(\alpha+\beta)\), and \(\alpha+\beta\) can be interpreted as a prior sample-size or concentration parameter, though this interpretation must be used carefully. The posterior mean is

\[

E[p\mid y]=\frac{\alpha+y}{\alpha+\beta+n}.

\]

For example, a prior \(\text{Beta}(2,2)\) and data of 7 successes in 10 trials produce a posterior \(\text{Beta}(9,5)\). The data shift the prior toward larger success probabilities without assigning probability one to any estimate.

Gamma–Poisson model

For count data, suppose

\[

y_i\mid\lambda\sim\text{Poisson}(\lambda),\qquad \lambda\sim\text{Gamma}(a,b),

\]

where \(b\) is a rate parameter. If \(S=\sum_i y_i\) and there are \(n\) observations, then

\[

\lambda\mid y\sim\text{Gamma}(a+S,b+n).

\]

The model is useful for event counts such as incidents per exposure period, provided that the Poisson assumptions are reasonable. Excess variation relative to the Poisson distribution may require a negative-binomial or hierarchical model.

Normal models

When observations are normally distributed with known variance, a normal prior for the mean is conjugate. Let

\[

y_i\mid\mu\sim N(\mu,\sigma^2),\qquad \mu\sim N(\mu_0,\tau_0^2).

\]

The posterior mean is a precision-weighted average of the prior mean and sample mean:

\[

\mu_n=\frac{\mu_0/\tau_0^2+n\bar y/\sigma^2}{1/\tau_0^2+n/\sigma^2}.

\]

Precision is the reciprocal of variance. A source with smaller variance receives greater weight. When both mean and variance are unknown, normal-inverse-gamma or related priors can provide conjugate forms, but robust likelihoods and hierarchical structures are often more appropriate in applied work.

Credible Intervals and Posterior Prediction

A 95% credible interval is an interval containing 95% posterior probability. It may be an equal-tail interval, with 2.5% posterior probability in each tail, or a highest posterior density interval, whose points have relatively high posterior density. For skewed or multimodal posteriors, these choices can differ substantially.

A credible interval is conditional on the model, prior, and observed data. It should not be interpreted as a confidence interval. A 95% confidence procedure has a long-run coverage property over repeated samples; it does not, in the standard frequentist interpretation, assign a 95% probability to the fixed parameter after the data are observed.

Parameter uncertainty and future-outcome uncertainty are different. The posterior predictive distribution is

\[

p(\tilde y\mid y)=\int p(\tilde y\mid\theta)p(\theta\mid y)d\theta.

\]

It incorporates both uncertainty about parameters and the inherent randomness of a future observation. For a Bernoulli process, one may draw a parameter from the posterior and then draw a future success or failure. For regression, posterior predictive simulation produces a distribution of plausible outcomes for new cases. Predictive intervals are usually wider than intervals for a conditional mean because they include irreducible observation noise.

Posterior predictive checks compare replicated data generated from the fitted model with observed data. Useful summaries may include means, variances, extreme values, zero counts, group differences, or temporal patterns. A model can have reasonable parameter estimates yet fail to reproduce important features of the data.

Hierarchical and Multilevel Modelling

Many data sets contain observations nested within groups: customers within regions, patients within hospitals, or transactions within accounts. A complete-pooling model assumes one common parameter, while a no-pooling model estimates every group separately. Hierarchical modelling provides partial pooling by allowing group-specific parameters to vary around a population distribution.

For group \(j\), a simple normal model is

\[

y_{ij}\sim N(\theta_j,\sigma^2),\qquad \theta_j\sim N(\mu,\tau^2).

\]

The group means are therefore related but not identical. Groups with little data are shrunk toward the population mean, while groups with substantial evidence retain more individual information. This shrinkage is not an arbitrary correction. It follows from modelling the fact that groups are exchangeable draws from a common population.

In a logistic multilevel model, for example,

\[

\text{logit}(p_{ij})=\alpha_j+x_{ij}^{T}\beta,\qquad \alpha_j\sim N(\alpha_0,\tau_\alpha^2).

\]

Hierarchical models improve estimation for small groups and allow group-level variation to be quantified. However, the assumed population distribution and exchangeability require substantive justification. A group that is structurally different from all others should not automatically be partially pooled with them.

Bayesian Decision Theory

Inference is often a step toward action. Bayesian decision theory combines a posterior distribution with a loss function. Let \(a\) be an action and \(\theta\) the unknown state. The posterior expected loss is

\[

\rho(a\mid y)=E[L(a,\theta)\mid y].

\]

The Bayes action minimises posterior expected loss. Under squared-error loss, the Bayes action is the posterior mean. Under absolute-error loss, it is a posterior median. Under a 0–1 classification loss, it is often the class with the highest posterior probability. Different losses can produce different decisions from the same posterior.

Decision analysis makes consequences explicit. In fraud detection, false positives may inconvenience many legitimate customers, whereas false negatives may create financial loss. A threshold chosen only to maximise accuracy ignores these asymmetric costs. Bayesian decision theory can also incorporate resource constraints, utility, safety requirements, and the value of additional information.

Computational Bayesian Inference

Exact posterior calculations are available only for some models. Complex models may contain nonlinear predictors, latent variables, nonconjugate priors, missing data, or thousands of parameters. Computational methods approximate posterior distributions.

Markov chain Monte Carlo

MCMC constructs a Markov chain whose stationary distribution is the target posterior. The Metropolis–Hastings algorithm proposes a new state and accepts it with a probability determined by the posterior density and proposal mechanism. Gibbs sampling draws each parameter from its conditional posterior when those conditional distributions are available. Hamiltonian Monte Carlo (HMC) uses gradients to explore continuous, correlated parameter spaces efficiently and is implemented in systems such as Stan.

An MCMC analysis should use multiple dispersed chains and assess convergence. Important diagnostics include trace plots, effective sample size, autocorrelation, and the split \(\hat R\) statistic. A value of \(\hat R\) close to 1 is necessary but not sufficient evidence of convergence. Divergent transitions, low effective sample sizes, excessive autocorrelation, and chains trapped in separate regions indicate problems with geometry, identifiability, or model specification.

Warm-up draws used for adaptation are normally discarded. Posterior summaries should be based on sufficiently many post-warm-up draws. Increasing the number of draws does not repair a fundamentally misspecified model or a chain that has not explored the posterior adequately.

Variational inference

Variational inference (VI) turns posterior approximation into an optimisation problem. A tractable family \(q(\theta)\) is selected and fitted to be close to the posterior, often by minimising Kullback–Leibler divergence. VI is usually faster and more scalable than MCMC, making it attractive for large data sets and iterative machine-learning workflows.

Its speed comes with risks. A restrictive approximation may underestimate posterior variance, miss multimodality, or distort dependence among parameters. Consequently, VI results should be validated through simulation, predictive checks, sensitivity analysis, and, where feasible, comparison with MCMC on a representative subset.

A Practical Bayesian Workflow

A defensible workflow begins with a clearly stated estimand: the quantity about which inference or prediction is required. The analyst then specifies the data-generating process, selects scales and transformations, assigns priors, and performs prior predictive checks. The model is fitted using exact computation, MCMC, VI, or another justified method. Computational diagnostics are examined before substantive interpretation.

The next stage is posterior and posterior predictive checking. Analysts should inspect whether the model reproduces relevant patterns, whether conclusions are sensitive to reasonable priors, and whether predictions are calibrated on appropriate validation data. Model comparison may use predictive criteria such as expected log predictive density, but it should not be reduced to selecting a model solely because it has the largest numerical score. Simpler models, interpretability, operational constraints, and fairness may matter as well.

Common mistakes include treating the prior as an afterthought, interpreting the likelihood as a posterior, reporting only posterior means, ignoring skewness, confusing parameter intervals with predictive intervals, failing to check convergence, and using a convenient conjugate model despite clear overdispersion or dependence. Another mistake is allowing observed outcomes to influence prior construction in a way that double-counts the data.

Applications in Data Science and Organisations

Bayesian methods are useful in A/B testing, risk analysis, demand forecasting, medical diagnosis, recommendation systems, credit assessment, reliability engineering, anomaly detection, and sequential experimentation. They support continuous updating as new evidence arrives and provide uncertainty distributions rather than single scores.

In product experimentation, a posterior distribution for a conversion-rate difference can answer questions such as the probability that a new design improves conversion by at least a practically meaningful amount. In forecasting, posterior predictive distributions can support inventory decisions under uncertainty. In reliability analysis, prior engineering knowledge can be combined with sparse failure data. In healthcare, hierarchical models can estimate hospital-level performance while avoiding unstable rankings based on small samples.

These applications require organisational discipline. Data provenance, versioned model specifications, documented priors, reproducible computation, monitoring for drift, and clear ownership of decisions are as important as mathematical correctness.

Illustrative Case Study: Bayesian Reliability Assessment

Background

A manufacturer monitors failures of a component used in industrial equipment. Historical engineering tests suggest that the monthly failure rate is usually low, but the current component design is new and only limited field data are available.

Situation and problem

During the first 20 component-months of observation, two failures occur. Management must decide whether to continue deployment, commission additional testing, or redesign the component. A raw failure rate of 10% may be unstable because it is based on little evidence.

Analysis and approach

Let \(p\) be the probability of failure per component-month. The reliability team uses a weakly informative prior \(p\sim\text{Beta}(1,19)\), whose mean is 0.05 but which allows considerable uncertainty. With two failures in 20 observations, the posterior is

\[

p\mid y\sim\text{Beta}(3,37).

\]

The posterior mean is \(3/40=0.075\). The decision should not rely on this mean alone. The team calculates the posterior probability that the failure rate exceeds the safety threshold of 0.10 and simulates the number of failures expected in the next 100 component-months. It also repeats the analysis under alternative plausible priors to determine whether the recommendation is prior-sensitive.

Posterior predictive checks are conducted by simulating failure counts under the fitted model. Engineers also assess whether failures are independent. If failures cluster by production batch or operating temperature, a simple binomial model is inadequate and a hierarchical or covariate-dependent model is required.

Decision and outcome

Suppose the posterior probability of exceeding 0.10 is material but not decisive, while the predicted upper-tail number of failures is unacceptable under the organisation’s safety policy. The appropriate response is not to declare the component safe because the posterior mean is below 0.10. Management commissions targeted testing under high-stress conditions and temporarily limits deployment. The additional evidence is then incorporated into an updated model.

Learning points

The case illustrates the distinction between an estimate and a distribution of uncertainty, the role of prior predictive reasoning, the importance of loss and safety thresholds, and the need to examine whether the likelihood reflects the physical failure process. Bayesian analysis supports a decision; it does not replace engineering judgement or regulatory review.

Limitations, Ethics, and Governance

Bayesian results are conditional on the model and prior. A poorly chosen prior can dominate when data are sparse, while a supposedly weak prior can still be informative on an unfamiliar scale. Likelihood misspecification, unmeasured confounding, selection bias, informative missingness, and measurement error remain serious threats.

Ethically, analysts must disclose priors that materially affect decisions and should not choose priors merely to obtain a desired result. Automated decisions based on posterior probabilities may reproduce historical discrimination if the data reflect unequal access or biased measurement. A well-calibrated model can still be unfair if errors are distributed unequally across groups. Sensitive applications require subgroup evaluation, human oversight, appeal mechanisms, privacy protection, and documentation of intended use.

In regulated environments, reproducibility includes preserving data versions, code, random seeds where relevant, model configurations, computational diagnostics, and decision thresholds. Probabilistic uncertainty should be communicated honestly. A narrow posterior produced by a biased or dependent sample is not evidence of genuine certainty.

Current Developments and Best Practice

Modern Bayesian systems increasingly combine probabilistic programming with automatic differentiation, GPU computation, scalable approximate inference, and simulation-based inference. Bayesian neural networks, Gaussian processes, deep generative models, and probabilistic programming languages extend uncertainty modelling to high-dimensional applications. Simulation-based inference is useful when the likelihood is difficult to evaluate but a simulator can generate data, although its validity depends on the simulator and the quality of diagnostic checks.

Best practice includes:

  • define the estimand and decision before fitting the model;
  • use priors that are scientifically defensible and conduct prior predictive checks;
  • model dependence, hierarchy, missingness, and measurement processes when relevant;
  • inspect convergence and effective sample size for MCMC;
  • validate variational approximations rather than assuming their uncertainty is exact;
  • use posterior predictive checks and out-of-sample evaluation;
  • conduct sensitivity analyses for priors, likelihoods, and influential observations;
  • report uncertainty, assumptions, limitations, and decision consequences;
  • maintain reproducible computational and governance records.

Chapter Summary

Bayesian statistics represents uncertainty about unknown quantities through probability distributions. A prior expresses information before current data, the likelihood describes the data-generating process, and Bayes’ theorem produces the posterior. Conjugate models provide exact updating in simple settings, while posterior predictive distributions support forecasting and model checking. Credible intervals describe posterior probability and differ conceptually from confidence intervals. Hierarchical models enable partial pooling across related groups, improving estimates for sparse groups while representing between-group variation. Bayesian decision theory links posterior uncertainty to actions through loss functions. Complex models require computational methods such as MCMC or variational inference, both of which demand diagnostic evaluation. Responsible Bayesian practice combines mathematical modelling with prior sensitivity, predictive validation, ethical governance, reproducibility, and explicit decision consequences.

Key Terms

Prior distribution: Probability distribution representing uncertainty about a parameter before observing current data.

Likelihood: Probability model for observed data conditional on parameter values.

Posterior distribution: Updated probability distribution for parameters after combining prior and likelihood.

Marginal likelihood: Probability of the observed data after averaging over the prior distribution.

Conjugacy: Property whereby prior and posterior distributions belong to the same family.

Credible interval: Interval containing a specified posterior probability for a parameter.

Posterior predictive distribution: Distribution of future or replicated observations conditional on observed data.

Precision: Reciprocal of variance; a measure of information concentration.

Prior predictive distribution: Distribution of possible data implied by the prior and likelihood before observation.

Hierarchical model: Model containing parameters that are themselves governed by higher-level probability distributions.

Partial pooling: Sharing information across groups while retaining group-specific variation.

Exchangeability: Assumption that group labels do not affect the joint probability structure, conditional on relevant information.

Loss function: Quantification of the cost associated with an action and the true state.

Bayes action: Action that minimises posterior expected loss.

MCMC: Simulation method that uses a Markov chain to approximate a target posterior distribution.

Hamiltonian Monte Carlo: Gradient-based MCMC method for exploring continuous posterior distributions.

Effective sample size: Approximate number of independent draws represented by correlated MCMC samples.

Variational inference: Approximation of a posterior through optimisation over a tractable distributional family.

Posterior predictive check: Comparison between observed data and data simulated from the fitted model.

Prior sensitivity analysis: Examination of how conclusions change under reasonable alternative priors.

Review Questions

Short Answer Questions

1. What are the roles of the prior, likelihood, and posterior in Bayesian inference?

2. Why is the posterior predictive distribution generally more uncertain than a distribution for a parameter alone?

3. State the posterior distribution in the beta–binomial model.

4. What is partial pooling, and why is it useful for small groups?

5. Name two diagnostics used to assess MCMC output.

Long Answer Questions

1. Explain Bayes’ theorem as a framework for statistical modelling, including the interpretation of the marginal likelihood.

2. Derive the beta–binomial posterior and discuss how prior concentration affects learning from data.

3. Compare credible intervals and confidence intervals, including the meanings of their probability statements.

4. Explain how hierarchical models differ from complete-pooling and no-pooling models.

5. Compare MCMC and variational inference in terms of computation, uncertainty representation, and diagnostic requirements.

Analytical / Application Questions

1. A team observes 12 successes in 20 trials and uses a Beta(2, 3) prior. Derive the posterior distribution and explain how you would report uncertainty about the success probability.

2. A hospital has unusually high performance based on only five cases, while another has average performance based on 2,000 cases. Explain how a hierarchical model could affect their estimates and why this may be preferable to ranking raw rates.

3. A fraud classifier has very different costs for false positives and false negatives. Describe how to use a posterior distribution and loss function to select an operational decision threshold.

22. Multiple Choice Questions with Answers

Question 1

Which expression correctly represents the Bayesian posterior, up to proportionality?

A. p(θ|y) ∝ p(θ)p(y|θ)

B. p(θ|y) ∝ p(θ)/p(y|θ)

C. p(θ|y) ∝ p(y)/p(θ)

D. p(θ|y) ∝ p(y|θ)/p(θ)

Correct Answer: A. p(θ|y) ∝ p(θ)p(y|θ)

Question 2

If p has a Beta(α, β) prior and y successes are observed in n binomial trials, what is the posterior?

A. Beta(α+n, β+y)

B. Beta(α+y, β+n−y)

C. Beta(α−y, β−n+y)

D. Beta(y, n−y)

Correct Answer: B. Beta(α+y, β+n−y)

Question 3

What does a 95% Bayesian credible interval mean, conditional on the model and data?

A. The parameter lies in the interval in 95% of repeated samples

B. The null hypothesis is false with probability 95%

C. The interval contains 95% posterior probability

D. The future observation lies in the interval with probability 95%

Correct Answer: C. The interval contains 95% posterior probability

Question 4

Why are posterior predictive intervals usually wider than intervals for a conditional mean?

A. They ignore parameter uncertainty

B. They include both parameter uncertainty and future observation noise

C. They always use a less informative prior

D. They are calculated from confidence rather than probability distributions

Correct Answer: B. They include both parameter uncertainty and future observation noise

Question 5

What is the principal effect of partial pooling in a hierarchical model?

A. It forces all groups to have identical estimates

B. It estimates groups independently with no shared information

C. It shrinks weakly informed group estimates toward a population distribution

D. It removes between-group variation from the model

Correct Answer: C. It shrinks weakly informed group estimates toward a population distribution

Question 6

Under squared-error loss, which quantity is the Bayes action?

A. Posterior mean

B. Posterior mode only

C. Prior median

D. Maximum likelihood estimate in every case

Correct Answer: A. Posterior mean

Question 7

Which finding most strongly indicates a possible MCMC problem?

A. Posterior draws have a high effective sample size

B. Multiple chains mix well and have R-hat near 1

C. Trace plots show chains exploring the same region

D. Chains remain in separate regions and show divergent transitions

Correct Answer: D. Chains remain in separate regions and show divergent transitions

Question 8

What is a major risk of variational inference compared with well-converged MCMC?

A. It cannot produce any posterior approximation

B. It may underestimate posterior uncertainty because of a restrictive approximation family

C. It always requires more computation than MCMC

D. It cannot be used with hierarchical models

Correct Answer: B. It may underestimate posterior uncertainty because of a restrictive approximation family

Question 9

In the reliability case, why should the team simulate future failures rather than report only the posterior mean failure rate?

A. Simulation removes all prior assumptions

B. Future decisions depend on predictive uncertainty and possible outcomes

C. The posterior mean is always mathematically invalid

D. Simulation converts a Bayesian model into a frequentist model

Correct Answer: B. Future decisions depend on predictive uncertainty and possible outcomes

Question 10

What is the purpose of a prior predictive check?

A. To assess whether data simulated before observing outcomes are plausible

B. To guarantee that the posterior has converged

C. To select the action with minimum posterior loss

D. To replace evaluation of the likelihood

Correct Answer: A. To assess whether data simulated before observing outcomes are plausible

Statistics and Probability for Data Science
Chapter 11 of 15

Statistics and Probability for Data Science

Chapter 12
Multivariate Statistical Analysis

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

12. Multivariate Statistical Analysis

Introduction and Context

Data science rarely studies variables in isolation. A customer’s purchase value may be related to age, income, browsing behaviour, and payment history; a patient’s diagnosis may depend on several laboratory measurements; and a machine’s failure risk may reflect temperature, vibration, pressure, and operating time. When several variables are observed for each unit, the data are multivariate.

Multivariate statistical analysis provides a systematic framework for understanding such data. It examines means, variances, covariances, correlations, dependence structures, latent dimensions, group membership, and similarity among observations. Its central challenge is that relationships among variables can be informative but also difficult to visualize and interpret, particularly when the number of variables is large.

This chapter develops the principal methods used in applied multivariate analysis: covariance and correlation structures, principal component analysis, factor analysis, clustering, discriminant analysis, and related dimensionality-reduction strategies. It also considers scaling, validation, interpretability, computational tools, and ethical use. These methods extend the ideas of univariate and bivariate statistics into settings where the joint distribution of variables matters.

Learning Objectives

After completing this chapter, the reader should be able to:

1. Distinguish covariance, correlation, dependence, and distance in multivariate data.

2. Assess how scaling, outliers, missing values, and multicollinearity affect analysis.

3. Explain and implement the logic of principal component analysis.

4. Interpret factor models and distinguish common factors from principal components.

5. Select and evaluate clustering methods for exploratory segmentation.

6. Apply discriminant analysis to supervised classification and understand its assumptions.

7. Compare dimensionality-reduction methods according to analytical purpose.

8. Communicate multivariate results without overstating patterns or implying unsupported causality.

The Geometry of Multivariate Data

Suppose that n observations are measured on p variables. The data matrix X has n rows and p columns. A row represents an observation and a column represents a variable. The sample mean vector is

x̄ = (x̄₁, x̄₂, …, x̄ₚ)′.

Unlike a single mean, a mean vector does not describe how variables vary together. That information is contained in the sample covariance matrix:

S = 1/(n − 1) (X − 1x̄′)′(X − 1x̄′).

The diagonal entries of S are sample variances, while the off-diagonal entries are covariances. A positive covariance indicates that two variables tend to be above or below their means together; a negative covariance indicates an opposing tendency. Covariance, however, depends on measurement units. Changing income from rupees to thousands of rupees changes its covariance with another variable even though the substantive relationship is unchanged.

The correlation matrix standardizes covariance:

Rᵢⱼ = Sᵢⱼ/(sᵢsⱼ).

Correlations lie between −1 and 1 and are therefore easier to compare across variables. Nevertheless, a correlation measures linear association, not causation, and a weak correlation can conceal nonlinear or subgroup-specific relationships.

Multivariate data can also be viewed geometrically. Each observation is a point in p-dimensional space, and each variable is a coordinate axis. Similarity can be represented by a distance. Euclidean distance is commonly defined as

d(x, y) = [Σⱼ(xⱼ − yⱼ)²]¹ᐟ².

Manhattan distance sums absolute coordinate differences. Mahalanobis distance additionally accounts for covariance:

D²(x) = (x − μ)′Σ⁻¹(x − μ).

Thus, a deviation in a highly variable direction may be less unusual than the same numerical deviation in a stable direction. Mahalanobis distance is useful for multivariate outlier detection, provided that the covariance matrix is estimated reliably.

Scaling and Preprocessing

Scaling is an analytical decision, not merely a software setting. If variables are measured in incomparable units, standardization is often appropriate:

zⱼ = (xⱼ − x̄ⱼ)/sⱼ.

Using the correlation matrix is equivalent to analysing standardized variables. However, standardization gives a low-variance variable the same potential influence as a high-variance variable. This may be desirable when variables are conceptually equally important, but inappropriate when measurement variance itself carries meaning.

Robust scaling, based on the median and interquartile range, can reduce the influence of extreme observations. Logarithmic or other transformations may be useful for highly skewed variables. Missing values require explicit treatment because deletion, imputation, or model-based approaches can produce different covariance structures. Imputation should be performed within the training data when predictive analysis is involved, so that information from the test set does not leak into model construction.

Principal Component Analysis: Rotating the Coordinate System

Principal component analysis (PCA) is an unsupervised method that replaces correlated variables with a smaller number of uncorrelated linear combinations called principal components. The first component is the direction in variable space along which the projected observations have maximum variance. Each subsequent component maximizes remaining variance subject to being orthogonal to earlier components.

If S is the covariance matrix, PCA solves the eigenvalue problem

Svₖ = λₖvₖ,

where vₖ is the kth eigenvector and λₖ is its eigenvalue. The kth component score for observation i is the projection

zᵢₖ = (xᵢ − x̄)′vₖ.

The eigenvalues measure the variance captured by the components. The proportion of total variance explained by component k is λₖ/Σλⱼ. If PCA is applied to a correlation matrix, the total variance equals p; if applied to a covariance matrix, variables with larger units or variances contribute more strongly.

PCA can be understood as a lossy compression method. Retaining the first q components produces an approximation to the original data. The discarded variance is a measure of reconstruction loss under squared-error criteria. PCA is therefore useful for visualization, noise reduction, compression, and constructing predictors with reduced collinearity.

Choosing the Number of Components

No single rule is universally correct. Common tools include a scree plot, cumulative explained variance, parallel analysis, and cross-validated predictive performance. The Kaiser rule, which retains eigenvalues greater than one, is easy to apply to a correlation matrix but can over- or under-retain components. A component should also be justified substantively: a mathematically strong component may have no meaningful interpretation.

Loadings describe the relationship between original variables and components. Large positive loadings indicate variables that increase with the component; large negative loadings indicate an opposing contribution. Sign is arbitrary: multiplying an eigenvector by −1 produces the same component. Analysts should therefore interpret relative patterns, not the sign alone.

PCA is not a causal model. It does not identify underlying mechanisms, and its components may be difficult to explain. It also assumes that linear combinations are useful and can be sensitive to outliers. Sparse PCA and robust PCA address some of these concerns by encouraging simpler loadings or reducing outlier influence.

Factor Analysis: Modelling Latent Constructs

Factor analysis has a different purpose from PCA. It seeks to explain observed correlations through a smaller number of unobserved latent factors. A common factor model is

X = μ + ΛF + ε,

where F is a vector of common factors, Λ is the loading matrix, and ε represents variable-specific error or uniqueness. Under the usual model, common factors explain covariance shared among variables, while uniqueness captures variance specific to an observed variable.

PCA decomposes total variance; factor analysis models common variance. Consequently, the number and interpretation of extracted dimensions may differ. Exploratory factor analysis (EFA) is used when the structure is uncertain. Confirmatory factor analysis (CFA), generally estimated within a structural equation modelling framework, tests a specified measurement model.

Before factor analysis, analysts examine whether correlations are adequate. The Kaiser–Meyer–Olkin statistic assesses sampling adequacy, while Bartlett’s test examines whether the correlation matrix differs from an identity matrix. These are aids rather than substitutes for substantive reasoning and adequate sample size.

Factor extraction may use principal-axis factoring or maximum likelihood. Rotation improves interpretability by seeking a simpler loading pattern. Orthogonal rotations, such as varimax, keep factors uncorrelated; oblique rotations, such as oblimin or promax, permit factor correlations and are often more realistic in social and behavioural applications. A factor loading is not automatically a validated scale: reliability, construct validity, cross-loadings, and replication must be examined.

Clustering: Discovering Groups Without Labels

Clustering methods assign observations to groups so that observations within a cluster are more similar than observations in different clusters. Because clusters are not known in advance, clustering is exploratory rather than inherently confirmatory. The result depends on the variables, scaling, distance measure, algorithm, and chosen number of clusters.

Centroid-Based and Hierarchical Methods

K-means clustering partitions observations into k groups by minimizing within-cluster squared Euclidean distance. The algorithm alternates between assigning observations to the nearest centroid and updating centroids. It is computationally efficient but requires k in advance, is sensitive to initialization and outliers, and works best for relatively compact, similarly shaped clusters.

Hierarchical agglomerative clustering begins with each observation as a separate cluster and successively merges clusters. The sequence is represented by a dendrogram. Linkage rules determine the distance between clusters: single linkage uses the nearest pair, complete linkage the farthest pair, average linkage the average pairwise distance, and Ward’s method seeks to minimize increases in within-cluster variance. Hierarchical methods provide a range of possible solutions but can be computationally expensive and irreversible once a merge occurs.

Density-based methods such as DBSCAN identify dense regions separated by areas of low density. They can find irregularly shaped clusters and label isolated observations as noise, but their results depend on neighbourhood parameters and may be difficult when cluster densities differ. Model-based methods assume that observations arise from a mixture of probability distributions and can provide probabilistic cluster membership, although distributional assumptions must be checked.

Evaluating Cluster Solutions

The silhouette coefficient compares within-cluster cohesion with separation from the nearest alternative cluster. Calinski–Harabasz and Davies–Bouldin indices provide additional internal criteria. These measures should not be treated as automatic evidence that a cluster is real. Stability under resampling, temporal validation, external variables, and domain interpretation are essential. A cluster that is mathematically distinct but operationally meaningless may have little value.

Discriminant Analysis: Classification with Group Structure

Discriminant analysis is a supervised multivariate method. Unlike clustering, it begins with observations whose group labels are known and develops rules for assigning new observations to groups.

Linear discriminant analysis (LDA) assumes, in its classical form, that each class follows a multivariate normal distribution and that all classes share a common covariance matrix. The discriminant function for class k is based on the class mean, common covariance matrix, and prior probability. The method seeks directions that maximize between-class variation relative to within-class variation. With class-specific covariance matrices, quadratic discriminant analysis (QDA) produces curved decision boundaries but requires more parameters and therefore more data.

The assumptions of normality and equal covariance are often approximate in practice. Their violation does not automatically invalidate classification, but performance should be assessed empirically. Regularized discriminant analysis shrinks covariance estimates toward simpler structures, which is particularly useful when variables are numerous or strongly correlated. In high-dimensional settings where p approaches or exceeds n, ordinary covariance estimation may be singular; shrinkage, feature selection, or dimension reduction becomes necessary.

Classification performance should be evaluated with a test set or cross-validation. Accuracy can be misleading under class imbalance, so analysts should examine sensitivity, specificity, precision, recall, balanced accuracy, and the confusion matrix. Posterior probabilities should be calibrated when decisions depend on risk thresholds.

Choosing and Combining Methods

The appropriate method depends on the analytical question. PCA is suitable when the goal is compact representation or visualization. Factor analysis is more appropriate when latent constructs and measurement error are central. Clustering is used to explore unknown groups, while discriminant analysis predicts known groups. These methods can be combined: PCA may reduce correlated predictors before classification, or factor scores may be used in a subsequent regression model.

Other dimensionality-reduction methods serve different purposes. Multidimensional scaling represents observations in a low-dimensional space while preserving pairwise distances as far as possible. Correspondence analysis is designed for categorical contingency tables. Kernel PCA captures certain nonlinear structures through implicit feature mappings. t-distributed stochastic neighbour embedding (t-SNE) and Uniform Manifold Approximation and Projection (UMAP) are useful for visual exploration of complex data, but their two-dimensional maps should not be treated as faithful global representations or as proof of natural clusters. Parameters can substantially affect apparent structure.

For predictive tasks, supervised methods such as partial least squares, regularized regression, tree-based models, or neural representation learning may outperform unsupervised components. Dimensionality reduction should therefore be selected according to the loss function and decision problem, not merely because a plot looks attractive.

An Illustrative Case: Segmenting and Classifying Retail Customers

Background

A fictional online retailer wants to understand customer behaviour and improve retention. For each customer, the analytics team has purchase frequency, average order value, days since last purchase, product-category diversity, discount usage, and customer-service contacts.

Situation and Problem

The variables have different units and are correlated. High purchase frequency is often associated with lower recency, while discount usage may be related to order value. Management wants both an exploratory segmentation and a model that identifies whether a newly observed customer belongs to a strategically important group.

Analysis and Approach

The team first inspects missingness, extreme values, and distributions. Monetary variables are log-transformed because of strong right skew, and robust standardization is used so that a few unusually large customers do not dominate the analysis. The correlation matrix shows substantial redundancy among frequency, recency, and order value.

PCA is applied for visualization and diagnostic purposes. The first component broadly represents purchasing intensity, while a second component contrasts discount dependence with product diversity. The team does not automatically call these components customer “needs”; they are descriptive statistical dimensions.

For segmentation, the team compares k-means solutions with three through six clusters and examines silhouette values, bootstrap stability, and managerial usefulness. A four-cluster solution is selected because it is reasonably stable and yields interpretable groups: high-value loyal customers, discount-sensitive frequent customers, occasional broad-category buyers, and inactive customers. The labels are descriptive rather than inherent truths.

Historical group labels from a validated campaign are then used to train an LDA classifier. Because covariance estimates are unstable with correlated inputs, the team uses standardized variables and compares LDA with a regularized alternative. Cross-validation indicates that the regularized model performs better for the smaller high-value class. Evaluation uses the confusion matrix, class-specific recall, and calibration rather than overall accuracy alone.

Outcome

The retailer develops different retention strategies for the four groups. The model is deployed only as a decision-support tool, and customer-facing interventions are monitored for differential error rates. Segment membership is periodically re-estimated because purchasing behaviour and market conditions change.

Learning Points

The case illustrates that preprocessing affects both clustering and classification; PCA can clarify structure without automatically defining business segments; clusters require stability and substantive validation; and a predictive classifier must be evaluated with metrics appropriate to class imbalance and business consequences.

Challenges, Risks, and Common Mistakes

A common mistake is to apply PCA, clustering, or factor analysis without examining scale and outliers. Another is to interpret correlation as causation or to treat a component or cluster as a naturally existing entity. Analysts may also overfit by selecting the number of dimensions or clusters after repeatedly inspecting the same evaluation data.

High dimensionality creates statistical difficulties. Covariance matrices become unstable, distances become less discriminating, and visualizations can conceal rather than reveal structure. The curse of dimensionality means that additional variables do not always add useful information. Regularization, feature screening based on domain knowledge, larger samples, and validation on new data are practical responses.

Cluster labels can be unstable, particularly near boundaries. Factor solutions may rotate into multiple plausible interpretations. Classification performance may degrade when the operational population differs from the training population. Data leakage is a serious risk when scaling, imputation, feature selection, or dimensionality reduction is performed before train-test separation.

Ethical and Professional Considerations

Multivariate methods can reproduce historical discrimination when sensitive attributes or their proxies are included. Clustering may create labels that influence access to credit, healthcare, employment, or services without a clear justification. Individuals may be classified into groups without knowing how the classification works or how to challenge it.

Responsible practice requires documenting variables, preprocessing decisions, model assumptions, validation results, and intended uses. Analysts should assess performance across relevant demographic groups, protect confidential data, minimize unnecessary attributes, and distinguish exploratory findings from decisions with legal or material consequences. Interpretability is not achieved merely by producing a two-dimensional plot; stakeholders must understand what the dimensions represent, how stable they are, and what uncertainty remains.

Technology and Emerging Developments

Modern statistical software provides covariance diagnostics, eigenvalue decomposition, factor extraction, clustering algorithms, and cross-validation workflows. Reproducible pipelines should record package versions, random seeds, preprocessing parameters, and model configurations. In production systems, monitoring should detect changes in distributions, cluster composition, covariance structure, and classification error.

Emerging work includes robust and sparse covariance estimation, probabilistic latent representations, nonlinear manifold learning, graph-based dimensionality reduction, and representation learning with neural networks. These methods can capture complex structure but often reduce transparency. For high-stakes applications, a slightly less flexible method with clear interpretation and reliable validation may be preferable to a more opaque representation.

Best Practices for Multivariate Analysis

A sound workflow normally includes the following principles:

  • Define the analytical purpose before selecting a method.
  • Inspect distributions, missingness, outliers, units, and correlations.
  • Choose covariance- or correlation-based analysis deliberately.
  • Fit preprocessing steps using training data only when prediction is involved.
  • Compare solutions using statistical evidence, stability, and domain meaning.
  • Validate components, clusters, and classifiers on new or resampled data.
  • Report uncertainty, assumptions, sensitivity analyses, and limitations.
  • Use visualizations as exploratory evidence rather than definitive proof.
  • Document decisions so that results can be reproduced and audited.

Chapter Summary

Multivariate statistical analysis studies several variables jointly and uses covariance, correlation, distance, and geometric representations to reveal structure. PCA transforms correlated variables into orthogonal components that maximize explained variance, whereas factor analysis models shared variation through latent constructs. Clustering explores unknown groups, while discriminant analysis classifies observations with known group labels. Scaling, outliers, missing data, covariance estimation, and dimensionality all strongly affect results. Method selection must follow the analytical objective, and apparent structure should be tested for stability, interpretability, and predictive or operational value. Ethical practice requires attention to fairness, transparency, privacy, uncertainty, and the consequences of classification.

Key Terms

Covariance: A measure of how two variables vary jointly.

Correlation matrix: A matrix of standardized pairwise associations among variables.

Mahalanobis distance: A covariance-adjusted distance measuring multivariate deviation.

Standardization: Transformation of a variable to have mean zero and standard deviation one.

Principal component: An orthogonal linear combination of variables ordered by explained variance.

Eigenvalue: The variance associated with a principal component or eigenvector direction.

Loading: The contribution or association of an observed variable with a component or factor.

Explained variance: The proportion of total variability represented by a component or reduced model.

Factor analysis: A model-based method explaining observed covariance through latent factors.

Uniqueness: Variance in an observed variable not explained by common factors.

Rotation: A transformation of factor axes intended to improve interpretability.

Clustering: Unsupervised assignment of observations to groups based on similarity.

Centroid: The mean position of observations assigned to a cluster.

Linkage: A rule defining distance between clusters in hierarchical clustering.

Silhouette coefficient: An index comparing within-cluster cohesion with separation.

Discriminant analysis: Supervised classification based on multivariate group distributions.

Linear discriminant analysis: Discriminant analysis using a common covariance matrix across classes.

Quadratic discriminant analysis: Discriminant analysis allowing class-specific covariance matrices.

Dimensionality reduction: Representation of data using fewer variables or dimensions.

Data leakage: Use of information during model development that would not be available at prediction time.

Review Questions

Short Answer Questions

1. Why is covariance dependent on measurement units, and how does correlation address this issue?

2. What does the first principal component maximize?

3. Distinguish total variance in PCA from common variance in factor analysis.

4. Why is scaling important before k-means clustering?

5. State one key difference between LDA and QDA.

Long Answer Questions

1. Explain the eigenvalue and eigenvector formulation of PCA and discuss methods for selecting the number of components.

2. Compare exploratory factor analysis with PCA in terms of purpose, variance decomposition, and interpretation.

3. Describe k-means, hierarchical clustering, and density-based clustering, including situations in which each may be appropriate.

4. Explain the assumptions of discriminant analysis and the consequences of covariance instability in high-dimensional data.

5. Develop a complete workflow for a multivariate analysis, from data preparation through validation and communication of results.

Analytical / Application Questions

1. A dataset contains income, age, transaction count, and account balance, measured in very different units and containing extreme incomes. Recommend a preprocessing and PCA strategy, and justify whether covariance or correlation should be used.

2. A clustering analysis produces six mathematically distinct customer groups, but the solution changes substantially under bootstrap resampling. How should the analyst respond before using the groups operationally?

3. A classifier achieves 96% accuracy when only 4% of cases belong to the important minority class. Explain why this result may be misleading and propose a more appropriate evaluation plan.

22. Multiple Choice Questions with Answers

Question 1

Which statement best describes the first principal component?

A. It is the variable with the largest original variance.

B. It is the linear combination that maximizes projected variance subject to a unit-length coefficient vector.

C. It is the factor that explains only measurement error.

D. It is the cluster centroid farthest from the global mean.

Correct Answer: B. It is the linear combination that maximizes projected variance subject to a unit-length coefficient vector.

Question 2

A researcher changes income from rupees to thousands of rupees before computing covariance. What changes?

A. The covariance changes in numerical value, while the correlation remains unchanged.

B. Both covariance and correlation necessarily become zero.

C. The correlation changes but covariance remains unchanged.

D. Neither covariance nor correlation changes.

Correct Answer: A. The covariance changes in numerical value, while the correlation remains unchanged.

Question 3

Why might an analyst choose factor analysis rather than PCA?

A. To guarantee that all original variables are independent.

B. To model shared covariance through latent constructs and separate it from variable-specific variance.

C. To ensure that clusters are spherical.

D. To eliminate the need for validation.

Correct Answer: B. To model shared covariance through latent constructs and separate it from variable-specific variance.

Question 4

Which clustering method can identify irregularly shaped dense groups and label isolated observations as noise?

A. K-means

B. Ward hierarchical clustering

C. DBSCAN

D. Linear discriminant analysis

Correct Answer: C. DBSCAN

Question 5

A dataset contains variables measured in dollars, counts, and days. If the analyst wants each variable to have comparable influence on Euclidean distance, the most appropriate first step is usually:

A. Standardization

B. Removing the variable with the smallest mean

C. Replacing all values with ranks without inspection

D. Applying QDA

Correct Answer: A. Standardization

Question 6

Which assumption distinguishes classical LDA from QDA?

A. LDA requires no group labels.

B. LDA assumes a common covariance matrix across classes, whereas QDA permits class-specific covariance matrices.

C. LDA is unsupervised, whereas QDA is supervised.

D. LDA requires all variables to be categorical.

Correct Answer: B. LDA assumes a common covariance matrix across classes, whereas QDA permits class-specific covariance matrices.

Question 7

A four-cluster solution has a high silhouette score but is unstable under resampling and cannot be explained to domain experts. What is the best conclusion?

A. The clusters are definitively valid because the silhouette score is high.

B. The analyst should report the clusters as causal types.

C. The solution requires further investigation and should not yet guide high-stakes decisions.

D. The number of clusters must automatically be increased.

Correct Answer: C. The solution requires further investigation and should not yet guide high-stakes decisions.

Question 8

Why can applying imputation and standardization to the full dataset before cross-validation create a problem?

A. It guarantees underfitting.

B. It can leak information from validation folds into the training process.

C. It makes covariance matrices diagonal.

D. It prevents any model from being trained.

Correct Answer: B. It can leak information from validation folds into the training process.

Question 9

Which statement about component signs in PCA is correct?

A. A component with negative loadings is always invalid.

B. The sign is arbitrary because multiplying an eigenvector by negative one gives the same direction.

C. Signs determine causality.

D. Signs are fixed by the measurement units.

Correct Answer: B. The sign is arbitrary because multiplying an eigenvector by negative one gives the same direction.

Question 10

Why can overall accuracy be misleading for a classifier when the minority class is rare?

A. Accuracy cannot be computed for supervised methods.

B. A model can obtain high accuracy by mostly predicting the majority class while missing minority cases.

C. Accuracy always penalizes majority-class predictions.

D. Rare classes automatically make covariance singular.

Correct Answer: B. A model can obtain high accuracy by mostly predicting the majority class while missing minority cases.

Statistics and Probability for Data Science
Chapter 12 of 15

Statistics and Probability for Data Science

Chapter 13
Time-Series and Forecasting Analytics

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

13. Time-Series and Forecasting Analytics

Introduction and Context

A time series is a sequence of observations recorded in chronological order. Examples include hourly electricity demand, daily website traffic, monthly sales, quarterly GDP, sensor readings, and annual rainfall. Time-series analytics differs from ordinary cross-sectional analysis because the order of observations contains information. A value observed today may depend on yesterday’s value, the time of year, a recent intervention, or a long-term change in the underlying system.

Forecasting analytics uses historical and contextual information to estimate future values and quantify uncertainty about those estimates. It supports inventory decisions, workforce planning, budgeting, maintenance, capacity management, financial risk assessment, and public policy. A forecast is not a prediction of an inevitable future; it is a conditional statement about what may occur if the data-generating conditions and assumptions remain reasonably stable.

Time-series work therefore combines statistical modelling, domain knowledge, data engineering, visual analysis, and evaluation. The analyst must establish the time scale, identify missing or irregular observations, distinguish signal from noise, avoid leakage from the future, and communicate uncertainty. This chapter develops the principal ideas of decomposition, smoothing, stationarity, autocorrelation, ARIMA modelling, forecast evaluation, anomaly detection, intervention analysis, and probabilistic forecasting.

Learning Objectives

By the end of this chapter, a student should be able to:

1. Explain the distinctive features of time-series data, including trend, seasonality, cycles, noise, and dependence.

2. Decompose a series and select appropriate smoothing and forecasting methods.

3. Assess stationarity using plots, transformations, autocorrelation, and formal tests.

4. Interpret autocorrelation and partial autocorrelation functions.

5. Build and diagnose ARIMA and seasonal ARIMA models.

6. Design time-aware validation schemes and evaluate forecasts using suitable measures.

7. Apply anomaly detection and intervention analysis responsibly.

8. Explain point forecasts, prediction intervals, and probabilistic forecasts.

9. Recognize practical, ethical, and organizational risks in forecasting projects.

The Structure of a Time Series

Let the observation at time t be denoted by y_t. A useful conceptual representation is

y_t = signal_t + irregular_t.

The signal may include several components. Trend is a persistent, long-run direction. It may be approximately linear, nonlinear, or subject to structural changes. Seasonality is a systematic pattern that repeats at a known and fixed frequency, such as higher retail demand every December or increased electricity consumption during working hours. Cyclical movement resembles long waves but does not necessarily have a fixed period; business cycles are a common example. Irregular variation consists of shocks, measurement error, and other movements not explained by the model.

Time series may be observed at regular intervals, such as every hour or month, or irregularly, as in some medical and financial records. Many standard methods require a regular time index. Resampling can create a regular grid, but aggregation may remove useful variation and imputation may introduce artificial dependence. These decisions should be documented rather than treated as routine preprocessing.

A series may also be univariate, containing only its own historical values, or multivariate, in which related variables are modelled jointly. A retailer may forecast sales using sales history, price, promotions, holidays, weather, and competitor information. Such models are often called dynamic regression or regression with errors that are themselves serially correlated.

Decomposition

In an additive decomposition,

y_t = T_t + S_t + R_t,

where T_t is trend, S_t is seasonal effect, and R_t is the remainder. This is appropriate when seasonal fluctuations have roughly constant magnitude. In a multiplicative decomposition,

y_t = T_t S_t R_t,

seasonal variation grows with the level of the series. Taking logarithms converts a multiplicative structure into an additive one:

log(y_t) = log(T_t) + log(S_t) + log(R_t).

Classical decomposition uses moving averages to estimate trend and seasonality. More flexible procedures, such as STL (Seasonal-Trend decomposition using Loess), allow smooth, evolving trend and seasonal components and are generally more robust to unusual observations. Decomposition is descriptive rather than automatically causal: a seasonal component indicates repetition, not the reason for it.

Smoothing and Baseline Forecasts

Smoothing methods reduce short-term noise to reveal level, trend, or seasonality. They are also forecasting models in their own right.

A moving average replaces each observation with the average of nearby observations. It is useful for visual exploration but can respond slowly to sudden changes. A weighted moving average gives greater weight to more recent observations.

Simple exponential smoothing (SES) is suitable for a series with no systematic trend or seasonality. Its updating equation is

l_t = αy_t + (1 − α)l_{t−1},

where l_t is the estimated level and 0 < α < 1. The next forecast is l_t. A large α reacts quickly to new information; a small α produces a smoother estimate.

Holt’s method extends exponential smoothing to trend by estimating level and slope. Damped-trend variants reduce the tendency of a linear trend to grow indefinitely. Holt–Winters methods add seasonality, using either additive or multiplicative seasonal effects. The choice depends on whether seasonal amplitude is approximately constant or increases with the level.

Simple benchmarks are essential. A naïve forecast sets the next value equal to the latest observation. A seasonal naïve forecast uses the observation from the corresponding previous season—for example, last December’s sales for this December. A sophisticated model should outperform a relevant benchmark, not merely produce an attractive fitted curve.

Stationarity and Dependence

A weakly stationary series has a constant mean, constant variance, and autocovariance that depends only on the lag between observations, not on calendar time. Stationarity does not mean that observations are independent. A stationary autoregressive process can exhibit strong serial dependence.

Trend and changing variance commonly violate stationarity. Transformations such as logarithms or the Box–Cox transformation can stabilize variance. Differencing removes changes in level:

Δy_t = y_t − y_{t−1}.

Seasonal differencing compares observations separated by a seasonal period m:

Δ_m y_t = y_t − y_{t−m}.

Over-differencing can destroy useful structure and create unnecessary noise, so differencing should be limited and justified.

The autocorrelation function (ACF) measures correlation between y_t and y_{t−k} at lag k. The partial autocorrelation function (PACF) measures the relationship at lag k after accounting for shorter lags. A slowly declining ACF may indicate non-stationarity or strong persistence. A sharp cutoff in the PACF can suggest an autoregressive structure, while a sharp cutoff in the ACF can suggest a moving-average structure; these are diagnostic clues, not mechanical rules.

Formal tests can supplement plots. The augmented Dickey–Fuller test uses a null hypothesis of a unit root, while the KPSS test typically uses stationarity as the null hypothesis. Their results must be interpreted with visual evidence and subject-matter understanding. A statistical test can be misleading in a short sample, in the presence of structural breaks, or when seasonal patterns have not been handled.

ARIMA and Seasonal ARIMA Models

The ARIMA(p,d,q) model applies an autoregressive moving-average model to a series differenced d times. In an autoregressive model, current values depend on previous values. In a moving-average model, current values depend on previous forecast errors. In lag-operator notation, a non-seasonal ARIMA model can be written as

φ(B)(1−B)^d y_t = c + θ(B)ε_t,

where B is the backshift operator, φ(B) represents autoregressive terms, θ(B) represents moving-average terms, and ε_t is an innovation or error.

The parameters p, d, and q describe the autoregressive order, differencing order, and moving-average order. Seasonal ARIMA, written SARIMA(p,d,q)(P,D,Q)_m, adds seasonal autoregressive, differencing, and moving-average terms for period m. For example, monthly data may require m = 12.

Model development generally proceeds through the following reasoning sequence:

1. Plot the series and inspect its time index, scale, outliers, trend, and seasonal behavior.

2. Establish a chronological training set and reserve later observations for evaluation.

3. Apply transformations or differencing only when justified.

4. Use ACF and PACF, domain knowledge, and information criteria to propose candidate models.

5. Estimate parameters using the training data.

6. Check residuals. They should have approximately zero mean, stable variance, little autocorrelation, and a distribution suitable for the intended use.

7. Compare with benchmarks and alternative models on a genuine future-like test period.

The Ljung–Box test can assess whether a group of residual autocorrelations is jointly inconsistent with white noise. However, a non-significant result is not proof that the model is correct. Residual plots, forecast performance, plausibility, and stability remain important.

ARIMA models are useful when serial dependence is central and the future can reasonably be related to the past through a stable stochastic process. They may perform poorly after a major policy change, product launch, technological disruption, or other structural break. Dynamic regression with ARIMA errors can incorporate known predictors such as holidays, prices, weather, or interventions.

Forecast Evaluation and Validation

Forecast evaluation must reproduce the information available at the time forecasts would have been produced. Randomly shuffling time-series observations usually causes leakage because training data can contain information from the future. A simple holdout reserves the last segment as a test set. For limited data, rolling-origin evaluation repeatedly trains on an expanding or moving window and forecasts one or more future periods.

Common point-forecast measures include:

  • MAE: the mean absolute error, easy to interpret in the original unit.
  • MSE: the mean squared error, which penalizes large errors strongly.
  • RMSE: the square root of MSE, expressed in the original unit.
  • MAPE: mean absolute percentage error, which is unstable or undefined when actual values are zero or near zero.
  • sMAPE: a symmetric-looking percentage measure, although its interpretation also requires care.
  • MASE: mean absolute scaled error, which compares performance with a naïve benchmark and is useful across series of different scales.

No single metric is universally best. A hospital may penalize under-forecasting demand more than over-forecasting; a supply chain may use a cost-weighted loss; a public agency may value calibration of prediction intervals. Evaluation should therefore reflect the decision being supported.

A point forecast alone is incomplete. A 30-day demand forecast of 10,000 units might be accompanied by an 80% prediction interval of 9,400–10,700 units and a 95% interval of 9,000–11,200 units. Prediction intervals include uncertainty from future innovations and, depending on the method, parameter estimation. They are wider than confidence intervals for an estimated mean because they concern future observations.

Probabilistic forecasts describe a predictive distribution rather than only one expected value. They can be assessed through interval coverage, interval width, calibration, and proper scoring rules such as the logarithmic score and continuous ranked probability score. A well-calibrated 90% interval should contain the realized value approximately 90% of the time over many comparable forecasts, although sampling variability is expected.

Anomaly Detection and Intervention Analysis

An anomaly is an observation that is unusually inconsistent with an appropriate model or reference pattern. In time series, anomaly detection must account for trend, seasonality, changing variance, and autocorrelation. A high sales value during a seasonal peak may be normal, whereas a moderate value during an otherwise stable period may be anomalous.

Useful approaches include examining decomposition residuals, robust z-scores, prediction-interval violations, rolling medians, exponentially weighted control charts, and isolation-based machine-learning methods. The method should match the purpose. A fraud-monitoring system may prioritize rapid detection, while a maintenance system may prioritize low false-alarm rates.

An anomaly can be:

  • a point anomaly, affecting one observation;
  • a contextual anomaly, unusual only in a particular season or operating condition; or
  • a collective anomaly, where a sequence is unusual even though individual values appear ordinary.

An alert is not automatically an error. It may represent a genuine event, such as a campaign, outage, cyberattack, epidemic, or weather shock. Automatically deleting anomalies can remove the most valuable information in the series.

Intervention analysis explicitly models an event that changes a series. A pulse intervention represents a temporary shock; a step intervention represents a persistent level shift; a ramp or slope-change intervention represents gradual change. Intervention variables may enter a regression with ARIMA errors. This approach helps estimate the timing, magnitude, and persistence of an intervention while controlling for seasonality and serial dependence. Causal interpretation requires careful design: a before-and-after pattern alone does not prove that the intervention caused the change.

Applied Case: Forecasting Regional Pharmacy Demand

Background

This illustrative case concerns a regional pharmacy chain with 35 stores. The organization must forecast weekly demand for prescription medicines and selected over-the-counter products. Stockouts harm patients and reduce trust, while excessive inventory increases expiry and storage costs.

Situation and Problem

Historical data consisted of weekly unit demand for three years, together with store, product, price, promotion, holiday, and stock-availability fields. A preliminary dashboard showed a gradual upward trend, strong winter seasonality, occasional promotional spikes, and several weeks with recorded demand close to zero. The operations team had been using the previous week’s demand as its forecast.

Analysis

The analytics team first separated true low demand from stockout-censored demand. A week with zero recorded sales while the product was unavailable was not treated as evidence of zero customer need. The team aggregated demand by product-store-week, created a regular weekly index, and marked public holidays and promotions.

Plots and seasonal summaries showed that respiratory medicines had winter peaks, while some chronic medicines exhibited a stable trend with modest seasonality. A logarithmic transformation was considered for products whose variance increased with demand. Seasonal naïve forecasts were used as a benchmark because the annual pattern was important.

For a chronic medicine, a dynamic regression with holiday and availability variables and ARIMA errors performed better than the benchmark. For a highly seasonal respiratory product, a seasonal exponential-smoothing model produced more accurate short-horizon forecasts. A product with intermittent demand was handled separately; an ordinary ARIMA model was unsuitable because most weeks had zero demand.

The team used rolling-origin validation. At each forecast origin, only information available up to that week was used. MAE was reported for operational interpretability, while a cost-weighted metric penalized under-forecasting more heavily. Prediction intervals were translated into reorder policies rather than presented as purely statistical outputs.

Approach and Solution

The final system used a model-selection layer based on product characteristics, benchmark comparisons, and recent validation performance. Forecasts were generated weekly and reviewed for implausible negative values, abrupt unexplained changes, and unusually wide intervals. Promotion calendars were supplied in advance where available. Anomaly alerts were routed to pharmacists and planners, who could annotate events rather than silently override the model.

Outcome

The organization achieved a more transparent forecasting process and could distinguish demand changes from data-quality problems. The principal improvement was not simply a lower average error; it was better alignment between forecast uncertainty and inventory decisions. Managers could identify products requiring additional safety stock and could investigate events that models could not explain.

Learning Points

The case illustrates five principles: data quality precedes model sophistication; seasonal benchmarks are necessary; validation must respect time; business costs should influence evaluation; and human review is most valuable when it explains exceptional events rather than replacing the model arbitrarily.

Technology, Automation, and Contemporary Practice

Time-series workflows are increasingly implemented through reproducible pipelines. Data platforms can automate ingestion, calendar joins, feature creation, model training, backtesting, monitoring, and alert delivery. Libraries for statistical forecasting, gradient-boosted trees, state-space models, and deep learning allow analysts to compare diverse methods.

Machine-learning models can use lagged values, rolling statistics, calendar variables, prices, weather, and other predictors. Gradient boosting and neural networks may perform well with many related series and nonlinear effects, but they require careful feature construction and time-aware validation. Deep sequence models can be powerful when large, stable datasets are available; they are not automatically superior to simpler statistical models.

A growing practice is global forecasting, in which one model is trained across many related series while learning series-specific behavior through identifiers or embeddings. Forecast reconciliation ensures that forecasts at different organizational levels add up consistently—for example, product forecasts should aggregate to store and regional totals. Automated forecasting should include monitoring for data drift, forecast bias, interval miscalibration, missing updates, and changes in the data-generating process.

Risks, Limitations, and Professional Governance

Forecasts inherit weaknesses in the data. Missing values, revised historical records, changes in product definitions, survivorship bias, and stockout censoring can distort conclusions. A model may appear accurate during a stable period and fail during a crisis. Structural breaks, policy changes, and competitor actions are difficult to infer from historical patterns alone.

Common mistakes include random train-test splitting, leakage through future-derived features, excessive differencing, ignoring seasonality, selecting models only by in-sample fit, reporting MAPE with zero-valued data, and presenting narrow intervals as certainty. Another mistake is to treat an anomaly as an error without investigating its operational meaning.

Forecasting also involves governance. Sensitive applications such as staffing, credit, healthcare, and public safety require attention to privacy, fairness, accountability, and the consequences of error. A forecast that systematically underestimates demand in a disadvantaged community can produce unequal service. Users should know the forecast horizon, data cutoff, model version, uncertainty range, and appropriate override procedure. Decisions with material consequences should not rely on an unreviewed automated forecast.

Best-Practice Workflow

A defensible forecasting project usually follows this sequence:

1. Define the decision, horizon, frequency, units, and cost of forecast errors.

2. Audit timestamps, missingness, duplicates, revisions, outliers, availability, and aggregation choices.

3. Visualize the series and investigate trend, seasonality, variance, breaks, and relationships with external variables.

4. Establish naïve and seasonal naïve benchmarks.

5. Create chronological validation sets and select metrics linked to the decision.

6. Fit a small set of interpretable candidate models before considering more complex alternatives.

7. Diagnose residuals and inspect forecast stability and plausibility.

8. Produce prediction intervals or full predictive distributions.

9. Monitor accuracy, bias, calibration, drift, and operational outcomes after deployment.

10. Record assumptions, interventions, model versions, and human decisions.

Current Developments and Emerging Directions

Important developments include probabilistic forecasting at scale, conformal prediction for distribution-free uncertainty calibration, hierarchical and grouped forecast reconciliation, causal forecasting around interventions, and models that combine statistical structure with machine learning. Foundation models and large neural architectures are being explored for time-series representation and cross-domain transfer, but their value depends on data quality, calibration, interpretability, and computational cost.

Another important direction is decision-focused forecasting, where models are judged by the quality of decisions they support rather than by error metrics alone. Forecasts may be integrated with optimization systems for inventory, staffing, energy dispatch, or transport planning. This integration increases the importance of transparent assumptions and sensitivity analysis: an uncertainty range should be connected to a decision rule, not displayed as decorative information.

Chapter Summary

Time-series analytics studies observations whose chronological order and dependence carry information. Trend, seasonality, cycles, and irregular variation can be explored through decomposition and smoothing. Stationarity is important for many stochastic models and may be approached through transformations and differencing. ACF and PACF describe serial dependence and help guide ARIMA and SARIMA specification, while residual diagnostics and benchmark comparisons remain essential.

Forecast evaluation must imitate real information flow through holdout or rolling-origin validation. MAE, RMSE, MASE, and other measures should be selected according to the decision context. Forecast uncertainty is represented through prediction intervals or predictive distributions and assessed through calibration and proper scoring rules. Anomaly detection must distinguish errors from meaningful events, and intervention analysis can represent temporary or permanent changes without automatically establishing causality. Effective professional practice combines statistical modelling with data governance, domain expertise, monitoring, and responsible communication.

Key Terms

Time series: Chronologically ordered observations of one or more variables.

Trend: Persistent long-term movement in a series.

Seasonality: A pattern that repeats at a known calendar or operational frequency.

Cycle: A long-term fluctuation without necessarily fixed periodic length.

Decomposition: Separation of a series into trend, seasonal, and remainder components.

Stationarity: Stability of distributional properties, especially mean, variance, and autocovariance, over time.

Differencing: Subtracting an earlier observation from a later one to remove level changes.

Autocorrelation: Correlation between observations separated by a specified lag.

PACF: Correlation at a lag after shorter-lag relationships have been controlled.

Exponential smoothing: Forecasting based on weighted averages that emphasize recent observations.

ARIMA: A model combining autoregression, differencing, and moving-average error structure.

SARIMA: ARIMA extended with seasonal autoregressive, differencing, and moving-average terms.

Residual: The observed value minus the fitted or forecast value.

Naïve forecast: A forecast that uses a recent observation, commonly the last value.

Rolling-origin evaluation: Repeated time-ordered training and forecasting using successive forecast origins.

Prediction interval: A range intended to contain a future observation with stated probability.

Anomaly: An observation or sequence inconsistent with an appropriate expected pattern.

Intervention analysis: Modelling the effect of a specified event or policy change on a time series.

Forecast reconciliation: Adjusting forecasts so that related hierarchical series aggregate consistently.

Calibration: Agreement between stated predictive probabilities or interval coverage and observed frequencies.

Review Questions

Short Answer Questions

1. Distinguish trend, seasonality, cyclical movement, and irregular variation.

2. When is a multiplicative decomposition more appropriate than an additive decomposition?

3. What is the purpose of differencing in an ARIMA model?

4. Why is a seasonal naïve forecast a useful benchmark?

5. Define a prediction interval and distinguish it from a confidence interval.

Long Answer Questions

1. Explain the process of developing and diagnosing an ARIMA or SARIMA model.

2. Discuss how stationarity can be assessed using plots, transformations, autocorrelation, and formal tests.

3. Compare simple exponential smoothing, Holt’s method, and Holt–Winters methods.

4. Explain why time-series forecast evaluation should use chronological holdout or rolling-origin validation.

5. Discuss the professional and ethical risks of deploying automated forecasts in healthcare, staffing, or public services.

Analytical / Application Questions

1. A monthly sales series has increasing variance, strong annual seasonality, and a gradual upward trend. Propose a modelling workflow and justify the transformation, decomposition, benchmark, validation design, and evaluation measures.

2. A demand-monitoring system flags a value as anomalous during a holiday week. Explain how you would determine whether it is a data error, a contextual anomaly, or a genuine demand event.

3. A retailer introduces a permanent price reduction and observes a level shift in sales. Design an intervention-analysis strategy and identify what evidence would be needed before making a causal claim.

22. Multiple Choice Questions with Answers

Question 1

Which situation most strongly supports using a multiplicative decomposition?

A. Seasonal fluctuations remain approximately constant as the series level changes

B. Seasonal fluctuations become larger as the level of the series increases

C. The series contains no seasonal pattern

D. All observations are independent

Correct Answer: B. Seasonal fluctuations become larger as the level of the series increases

Question 2

What is the main purpose of differencing a non-stationary time series?

A. To create additional observations

B. To remove all random variation

C. To reduce level-related non-stationarity

D. To guarantee normally distributed residuals

Correct Answer: C. To reduce level-related non-stationarity

Question 3

A seasonal naïve forecast for monthly sales in March would normally use:

A. The average of all previous months

B. The sales value from the previous March

C. The sales value from February only

D. The median sales value for the entire year

Correct Answer: B. The sales value from the previous March

Question 4

Which residual pattern most clearly suggests that a fitted forecasting model is inadequate?

A. Residuals fluctuate around zero with little autocorrelation

B. Residuals have a stable variance and no visible structure

C. Residuals show repeated autocorrelation at seasonal lags

D. Residuals are expressed in the original measurement units

Correct Answer: C. Residuals show repeated autocorrelation at seasonal lags

Question 5

Why is random shuffling generally inappropriate when creating training and test sets for time-series forecasting?

A. It always reduces the sample size

B. It can allow future information to enter model training

C. It prevents the calculation of MAE

D. It guarantees that seasonal patterns disappear

Correct Answer: B. It can allow future information to enter model training

Question 6

Which measure is especially problematic when actual values can be zero or near zero?

A. MAE

B. RMSE

C. MASE

D. MAPE

Correct Answer: D. MAPE

Question 7

A single unusually high observation that is abnormal only because it occurred outside the normal seasonal period is best described as a:

A. Contextual anomaly

B. Seasonal naïve forecast

C. Unit root

D. Damped trend

Correct Answer: A. Contextual anomaly

Question 8

What does intervention analysis primarily attempt to model?

A. The effect of a specified event or policy change on a series

B. The random ordering of observations

C. The removal of all seasonal components

D. The conversion of a univariate series into a cross-sectional dataset

Correct Answer: A. The effect of a specified event or policy change on a series

Question 9

If a forecasting system reports a 90% prediction interval, calibration would require that:

A. Every future value must fall inside the interval

B. Approximately 90% of comparable future observations fall inside intervals over time

C. The interval width must remain constant

D. The point forecast must equal the lower bound

Correct Answer: B. Approximately 90% of comparable future observations fall inside intervals over time

Question 10

Which practice best protects against forecasting leakage?

A. Using randomly shuffled observations for validation

B. Using features calculated with data available only after the forecast origin

C. Constructing features using only information available at each forecast origin

D. Selecting the model with the best in-sample fit only

Correct Answer: C. Constructing features using only information available at each forecast origin

Statistics and Probability for Data Science
Chapter 13 of 15

Statistics and Probability for Data Science

Chapter 14
Statistical Learning and Model Evaluation

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

14. Statistical Learning and Model Evaluation

Introduction and Context

Statistical learning provides the bridge between statistical inference and machine learning. Its central concern is not merely whether a model describes observed data, but whether it can make reliable predictions or decisions for new cases. This distinction changes how models are constructed, assessed, interpreted, and governed.

A model fitted to historical data may appear highly accurate while failing in practice because it has memorised noise, learned from information that would not be available at prediction time, or been evaluated on data that are too similar to the training records. Conversely, a slightly less complex model may perform more reliably because it captures stable relationships rather than accidental patterns. Statistical learning therefore requires a disciplined treatment of loss, uncertainty, validation, generalisation, and the consequences of errors.

For data scientists, model evaluation is also a decision problem. The appropriate metric depends on the cost of false positives and false negatives, the prevalence of the outcome, the quality of probability estimates, and the intended operational use. In high-stakes settings, evaluation must additionally consider subgroup performance, fairness, explainability, robustness, privacy, and human oversight.

Learning Objectives

By the end of this chapter, students should be able to:

1. Explain empirical risk, population risk, loss functions, and generalisation error.

2. Interpret the bias–variance trade-off and relate it to model complexity.

3. Distinguish validation, test, cross-validation, bootstrap, and time-aware evaluation.

4. Select suitable regression and classification metrics for a stated decision context.

5. Explain regularisation, feature selection, calibration, and model interpretability.

6. Identify leakage, overfitting, dataset shift, and other evaluation failures.

7. Design an uncertainty-aware and ethically responsible evaluation framework.

8. Apply these ideas to a realistic data-science case.

From Inference to Prediction: Risk and Loss

In classical inference, an analyst may ask whether a coefficient differs from zero, estimate a population parameter, or construct a confidence interval. Statistical learning often asks a related but distinct question: how well will a fitted function perform on future observations drawn from a target population?

Let an observation be represented by predictors X and response Y. A prediction rule is written as f(X). A loss function L(Y, f(X)) quantifies the consequence of a prediction. The population risk is

R(f) = E[L(Y, f(X))],

where the expectation is taken over the data-generating distribution. Because this distribution is unknown, it is estimated using a sample. The empirical risk is

R_n(f) = (1/n) Σ L(y_i, f(x_i)).

Empirical risk minimisation chooses a model that performs well on observed data. However, minimising empirical risk without controlling complexity can produce a model that fits random variation. The practical objective is low population risk, often called good generalisation.

The loss function embodies a decision context. Squared-error loss, (y − ŷ)^2, heavily penalises large errors and is common in regression. Absolute-error loss, |y − ŷ|, is less sensitive to extreme observations. In binary classification, zero–one loss records whether a class is correctly predicted, while log loss evaluates the quality of predicted probabilities:

−[y log(p) + (1 − y) log(1 − p)].

A model assigning probability 0.99 to an event that does not occur receives a much larger penalty than a model assigning probability 0.60. Thus, accuracy and probability quality are not interchangeable.

Important terminology

A parameter is a quantity describing a model or population that is estimated from data. A hyperparameter is a setting chosen during model development, such as a tree depth or regularisation strength. Training data are used to estimate model parameters; validation data support model or hyperparameter selection; test data provide a final, ideally untouched, estimate of performance. A prediction target is the outcome the model is intended to estimate. A decision threshold converts a predicted probability or score into an action or class.

The Bias–Variance Trade-off

Prediction error can be understood through the balance between bias and variance. Bias is systematic error caused by an overly restrictive model. For example, a linear model may have high bias when the true relationship is strongly nonlinear. Variance is sensitivity to the particular sample used for training. A highly flexible model may change substantially when the training sample changes.

For squared-error prediction, expected test error can be expressed conceptually as:

Expected error = irreducible noise + bias² + variance.

Irreducible noise arises from randomness or unmeasured influences and cannot be eliminated merely by choosing another algorithm. Increasing model complexity generally reduces training error and may reduce bias, but often increases variance. At first, this improves test performance; beyond an appropriate level, overfitting causes test error to rise.

Underfitting occurs when a model is too simple to represent important structure. Overfitting occurs when it captures noise, outliers, or sample-specific regularities. The best model is therefore not necessarily the one with the lowest training error or the largest number of parameters. It is the model with an appropriate expected performance on future data, subject to computational, interpretive, and operational constraints.

The trade-off is not a fixed property of an algorithm. It depends on sample size, noise, feature quality, model class, regularisation, and the similarity between training and deployment populations. More data can reduce variance, but additional data from the wrong population may not improve deployment performance.

Controlling Complexity: Regularisation and Feature Selection

Regularisation modifies the fitting objective by adding a penalty for model complexity. In linear regression, ridge regression minimises

Σ(y_i − ŷ_i)^2 + λ Σ β_j²,

where λ controls the strength of the penalty. Ridge shrinks coefficients toward zero and is especially useful when predictors are numerous or correlated. Lasso regression uses an absolute-value penalty:

Σ(y_i − ŷ_i)^2 + λ Σ |β_j|.

Because the absolute-value penalty can set some coefficients exactly to zero, lasso can perform embedded feature selection. Elastic net combines ridge and lasso penalties and can be useful when correlated predictors occur in groups.

The penalty parameter must be selected using training and validation procedures, not by inspecting test performance repeatedly. Predictors should generally be standardised before penalised regression when their scales differ; otherwise, the penalty affects variables unevenly.

Feature selection may be filter-based, wrapper-based, or embedded. Filter methods rank variables using criteria such as correlation or mutual information before model fitting. Wrapper methods evaluate subsets according to model performance. Embedded methods, such as lasso or tree-based selection, perform selection during training. Feature selection can improve efficiency and interpretability, but selecting variables using the full dataset before cross-validation causes leakage and produces optimistic estimates. Selection must occur within each training fold.

Regularisation is not a substitute for sound data design. A leaked variable, a biased sample, or an incorrectly defined target cannot be repaired by tuning λ.

Validation as a Design Problem

A random train–test split is appropriate only when observations are reasonably independent and identically distributed and when future cases resemble randomly selected current cases. In many applications, these assumptions are false.

A basic holdout procedure divides data into training and test sets. When data are limited, k-fold cross-validation divides the training data into k folds, fits the model on k−1 folds, and evaluates it on the remaining fold. The process is repeated so that each observation is used for validation once. The mean score estimates expected performance, while variation across folds indicates instability.

Stratified cross-validation preserves the approximate class proportion in each fold and is useful for imbalanced classification. Grouped cross-validation keeps records from the same person, household, organisation, or experiment in one fold, preventing related observations from appearing in both training and validation sets. Time-series evaluation must respect temporal order: models are trained on earlier periods and tested on later periods. Randomly mixing future observations into training can create an unrealistic and invalid estimate.

Nested cross-validation separates hyperparameter selection from performance estimation. An inner loop selects the model or hyperparameters; an outer loop estimates performance. This is valuable when many alternatives are considered and data are limited. Bootstrapping, which repeatedly samples observations with replacement, can estimate variability, confidence intervals, or optimism, although its assumptions must be considered carefully.

A robust evaluation pipeline includes preprocessing inside the resampling procedure. Imputation, scaling, encoding, feature selection, and dimensionality reduction must be learned from the training portion of each fold and then applied to its validation portion. This prevents information from the validation data entering model construction.

Choosing Metrics That Match the Decision

Regression

Mean squared error (MSE) is the average squared prediction error, while root mean squared error (RMSE) returns the measure to the response scale. RMSE gives substantial influence to large errors. Mean absolute error (MAE) is easier to interpret and more robust to outliers. Mean absolute percentage error can be misleading when actual values are near zero. R-squared measures the proportion of sample variation explained relative to a baseline, but it is not a universal measure of predictive accuracy and can be negative on test data.

Metrics should be reported with uncertainty, such as confidence intervals or fold-to-fold variation. A small difference in average RMSE may not justify choosing a more complex or less interpretable model.

Classification

A confusion matrix contains true positives, true negatives, false positives, and false negatives. Accuracy is the proportion of correct classifications, but it can be deceptive under class imbalance. Precision is TP/(TP+FP), and recall or sensitivity is TP/(TP+FN). Specificity is TN/(TN+FP). The F1 score is the harmonic mean of precision and recall and is useful when both matter, although it ignores true negatives and probability calibration.

The receiver operating characteristic (ROC) curve displays sensitivity against false-positive rate across thresholds; its area under the curve (ROC-AUC) measures ranking ability across thresholds. Precision–recall curves are often more informative when the positive class is rare. Neither AUC directly specifies the operational threshold or the costs of errors.

A cost-sensitive evaluation may define expected cost as

C = c_FP P(FP) + c_FN P(FN) + c_TP P(TP) + c_TN P(TN),

with costs assigned according to the application. Threshold selection should follow the decision objective, not an automatic preference for 0.5.

Ranking, probability, and operational metrics

When a model prioritises cases, metrics such as precision at k, recall at k, lift, or gains may be appropriate. When probabilities support resource allocation, risk communication, or triage, calibration is essential. A model is calibrated if, among cases assigned probability p, approximately p proportion experience the event. Calibration can be assessed using reliability diagrams, calibration intercept and slope, and proper scoring rules such as log loss or the Brier score.

Discrimination and calibration answer different questions. A model may rank high-risk cases correctly but systematically overestimate their absolute risk. Conversely, a calibrated model may provide useful probabilities even with modest discrimination. Recalibration methods include Platt scaling and isotonic regression, but they require separate validation data or careful cross-validation.

Uncertainty, Stability, and Statistical Comparison

A single test score conceals uncertainty. Sources include finite sample size, sampling variation, random initialisation, hyperparameter choices, and changes in the deployment population. Report means with intervals or distributions across resamples where feasible. When comparing models, evaluate paired differences on the same folds or cases rather than comparing unrelated averages.

Prediction uncertainty can be separated conceptually into aleatoric uncertainty, arising from inherent randomness, and epistemic uncertainty, arising from limited knowledge or data. Prediction intervals in regression describe uncertainty around a future observation, whereas confidence intervals describe uncertainty about an estimated parameter or mean response. They should not be confused.

For probabilistic machine learning, uncertainty estimates should be tested for calibration and sharpness. A narrow interval that frequently misses the true value is not useful. In high-risk applications, abstention or referral to a human may be preferable when uncertainty is high or the input is outside the training distribution.

Explainability and Responsible Evaluation

Explainability has several meanings. A transparent model, such as a small decision tree or a regularised linear model, can be understood directly. Post-hoc methods explain predictions from complex models. Global explanations describe average model behaviour; local explanations describe an individual prediction. Feature importance, partial dependence, accumulated local effects, and Shapley-based methods can be informative, but each has assumptions and possible failure modes.

An explanation is not necessarily a causal explanation. A high feature importance may reflect correlation, proxy information, or data collection practice rather than a variable’s causal influence. Explanations can also be unstable when correlated features compete for importance. They should therefore be checked for consistency, plausibility, and sensitivity to perturbations.

Responsible evaluation includes subgroup analysis. Overall accuracy can conceal poor performance for a minority group. Analysts should compare relevant error rates, calibration, coverage, and threshold effects across groups, while recognising that fairness criteria may conflict mathematically and that group labels may be incomplete or sensitive. The choice of fairness criterion must be connected to the social and institutional context.

Privacy, data minimisation, access control, documentation, and secure handling of sensitive attributes are part of professional model evaluation. In regulated settings, records should support traceability of data sources, model versions, decisions, validation results, and changes after deployment. An evaluation that ignores foreseeable harm is statistically incomplete, even if its numerical score is high.

A Practical Evaluation Workflow

A sound workflow begins by defining the prediction target, prediction time, eligible population, and intended action. The analyst then specifies the loss and metrics before examining results. Data are audited for missingness, duplicates, leakage, sampling bias, temporal structure, and shifts in measurement.

Next, a simple baseline is established. Examples include predicting the training mean in regression, the majority class in classification, or a well-calibrated historical rate. Candidate models are then fitted through a reproducible pipeline. Resampling reflects the anticipated deployment process, and all preprocessing is nested within training folds.

The analyst reports primary and secondary metrics, uncertainty, subgroup results, calibration, computational cost, and operational constraints. Thresholds are selected using validation data and documented. The untouched test set is used once, or as sparingly as possible, for final confirmation. Before deployment, stress tests examine missing inputs, distribution shift, adversarial or unusual cases, and plausible changes in costs.

After deployment, evaluation continues through monitoring of data drift, prediction drift, calibration, performance where labels become available, subgroup outcomes, and human override patterns. A model is not finished when it is deployed; it becomes part of a socio-technical system that must be reviewed over time.

Applied Case: Predicting Hospital Readmission

Background

The following is an illustrative case. A hospital wishes to identify adult patients who are likely to be readmitted within 30 days after discharge. The intended use is to offer additional follow-up support, not to deny treatment.

Situation and problem

An initial team trains a gradient-boosting model on five years of electronic health-record data. The reported accuracy is 92%, and the team recommends deployment. However, only 8% of patients are readmitted. A model that predicts “no readmission” for everyone would achieve 92% accuracy, so the reported result provides little evidence of usefulness.

Further inspection identifies a serious leakage variable: a discharge-planning code entered after clinicians had already arranged follow-up for patients considered high risk. This code would not be available at the intended prediction time for all patients. The original random split also places multiple admissions from the same patient in both training and test sets.

Analysis and revised strategy

The team first defines the prediction time as the point at which discharge planning begins and removes variables recorded afterward. It uses a grouped, temporal split so that patient records do not cross partitions and later periods are evaluated as future data. A logistic regression with regularisation, a calibrated gradient-boosting model, and a historical-risk baseline are compared.

Because the intervention team can contact only 15% of discharged patients, recall at the top 15% of ranked cases becomes an operational metric. Precision at 15%, calibration, subgroup recall, and expected intervention cost are also reported. Cross-validation is performed within the development period, with imputation and feature selection fitted separately within each fold. The final test period remains untouched until the design is fixed.

The model’s probabilities are recalibrated on a validation period. A threshold is selected according to the relative costs of missed high-risk patients, unnecessary follow-up, and staff capacity. Cases with unusual patterns or low-confidence predictions are referred for manual review rather than treated as automatically high or low risk.

Outcome

The revised evaluation produces lower overall accuracy than the original report but gives a more credible estimate of deployment performance. It reveals that performance varies across age and language-access groups, prompting additional data-quality review and targeted monitoring. The hospital decides to run a prospective pilot with human oversight rather than immediately automate decisions.

Learning points

The case illustrates that an apparently strong metric can be invalid because of imbalance, leakage, dependence between observations, or mismatch between evaluation and deployment. It also shows why ranking, calibration, capacity constraints, subgroup analysis, and prospective monitoring are often more relevant than accuracy alone.

Common Failure Modes and Best Practices

Frequent errors include repeatedly tuning against the test set, selecting features before cross-validation, using random splits for temporal data, reporting only accuracy, ignoring the baseline, and interpreting association as causation. Other failures include treating AUC as a complete evaluation, presenting unstable feature explanations as facts, and deploying probability estimates without calibration.

Best practice is to pre-specify the target and evaluation plan, use leakage-resistant pipelines, preserve an honest test set, compare against simple baselines, report uncertainty, and align metrics with decisions. Evaluation should include calibration, subgroup analysis, robustness checks, and documentation. Simpler models should be preferred when they provide comparable performance with lower operational and interpretive risk. Finally, deployment should include monitoring, version control, clear ownership, and a process for model withdrawal or revision.

Current Developments

Contemporary evaluation increasingly addresses distribution shift, foundation models, generative AI, and automated machine-learning systems. In shifting environments, static test sets may become obsolete; rolling-origin evaluation, drift detection, and continual recalibration become important. For generative systems, evaluation must consider factuality, task success, abstention, toxicity, privacy leakage, and robustness to prompts, rather than relying on a single similarity score.

Automated model-selection platforms can accelerate experimentation but also increase the risk of hidden multiple comparisons and test-set overuse. Reproducibility therefore requires recording data versions, search spaces, random seeds where relevant, preprocessing, and selection criteria. Uncertainty-aware AI is also gaining importance: systems should communicate confidence, recognise out-of-distribution inputs, and support escalation when automated predictions are unreliable.

Chapter Summary

Statistical learning connects prediction with statistical reasoning through loss functions, risk, generalisation, and uncertainty. The bias–variance trade-off explains why excessive flexibility produces overfitting, while regularisation and carefully designed feature selection control complexity. Valid evaluation depends on separating training, validation, and test roles; using cross-validation appropriately; preventing leakage; and respecting groups and time.

No metric is universally best. Regression, classification, ranking, probability, and operational decisions require different measures. Calibration complements discrimination, while uncertainty intervals and stability analysis qualify reported scores. Explainability, subgroup analysis, privacy, fairness, documentation, and monitoring extend evaluation beyond numerical performance. A responsible data scientist evaluates not only whether a model predicts, but whether it remains reliable, interpretable, appropriate, and safe in its intended context.

Key Terms

Empirical risk: Average loss measured on observed training data.

Population risk: Expected loss over the target data-generating population.

Loss function: Rule that quantifies the consequence of a prediction error.

Generalisation: Ability of a model to perform well on new relevant observations.

Bias: Systematic prediction error caused by restrictive assumptions or model structure.

Variance: Sensitivity of a fitted model to changes in the training sample.

Overfitting: Learning sample-specific noise that harms performance on new data.

Regularisation: Penalisation of model complexity during fitting.

Hyperparameter: Model-development setting selected rather than directly estimated from data.

Data leakage: Inappropriate information flow from validation, test, or future data into training.

Cross-validation: Resampling procedure for estimating performance or selecting models.

Calibration: Agreement between predicted probabilities and observed event frequencies.

Discrimination: Ability to rank cases according to their relative outcome risk.

Precision: Proportion of predicted positive cases that are actually positive.

Recall: Proportion of actual positive cases correctly identified.

Dataset shift: Change in the distribution of data between development and deployment.

Aleatoric uncertainty: Uncertainty arising from inherent randomness in outcomes.

Epistemic uncertainty: Uncertainty arising from limited knowledge or data.

Explainability: Ability to communicate or analyse how a model produces predictions.

Baseline model: Simple reference model used for meaningful performance comparison.

Review Questions

Short Answer Questions

1. Distinguish empirical risk from population risk.

2. What is the purpose of a loss function?

3. Explain why accuracy can be misleading for an imbalanced classification problem.

4. What is calibration, and how does it differ from discrimination?

5. Why must preprocessing be performed within cross-validation folds?

Long Answer Questions

1. Explain the bias–variance trade-off and discuss how regularisation influences it.

2. Compare holdout validation, k-fold cross-validation, nested cross-validation, and bootstrap evaluation.

3. Discuss the strengths and limitations of RMSE, MAE, accuracy, F1 score, ROC-AUC, precision–recall measures, and log loss.

4. Explain how temporal structure, repeated individuals, and dataset shift affect evaluation design.

5. Develop a responsible evaluation framework for a high-stakes predictive model, including uncertainty, fairness, explainability, and monitoring.

Analytical / Application Questions

1. A fraud model has 99.5% accuracy but detects only 20% of fraudulent transactions. Which additional metrics and evaluation design would you use, and why?

2. A hospital model is trained using random cross-validation on five years of records, with several admissions per patient. Identify the likely sources of optimistic bias and propose a revised validation strategy.

3. A model ranks customers accurately but assigns probabilities that are systematically too high. Explain the operational risks and recommend methods for assessing and improving calibration.

22. Multiple Choice Questions with Answers

Question 1

Which quantity represents the expected loss of a prediction rule over the target population?

A. Training error

B. Population risk

C. Validation accuracy

D. Regularisation strength

Correct Answer: B. Population risk

Question 2

A model has very low training error but much higher test error. Which explanation is most appropriate?

A. It is underfitting because its variance is too low

B. It is overfitting sample-specific variation

C. Its irreducible error has disappeared

D. Its test set must be larger than its training set

Correct Answer: B. It is overfitting sample-specific variation

Question 3

Which method can set some linear-model coefficients exactly to zero?

A. Ridge regression

B. Ordinary least squares

C. Lasso regression

D. Principal component scoring

Correct Answer: C. Lasso regression

Question 4

Why is random cross-validation inappropriate for many time-series problems?

A. It always produces too few observations

B. It prevents the use of numerical predictors

C. It can allow future information to influence evaluation of earlier periods

D. It cannot calculate classification metrics

Correct Answer: C. It can allow future information to influence evaluation of earlier periods

Question 5

A classifier is used to select the 10% of cases with the highest predicted risk. Which metric is especially relevant?

A. Precision at 10%

B. Training loss only

C. R-squared

D. Mean absolute error

Correct Answer: A. Precision at 10%

Question 6

A model assigns a probability of 0.8 to a group of cases. What does good calibration imply?

A. The model classifies exactly 80% of those cases correctly

B. Approximately 80% of those cases experience the event

C. The model has an ROC-AUC of 0.8

D. The model has no false positives

Correct Answer: B. Approximately 80% of those cases experience the event

Question 7

Which action is an example of data leakage?

A. Scaling predictors using parameters learned from each training fold

B. Using a discharge code entered after the prediction time as a predictor

C. Comparing a model with a majority-class baseline

D. Reporting performance separately by subgroup

Correct Answer: B. Using a discharge code entered after the prediction time as a predictor

Question 8

Why should patient records be kept within the same fold in grouped cross-validation?

A. To increase the number of model parameters

B. To ensure every fold has identical sample sizes

C. To prevent highly related records from appearing in both training and validation data

D. To guarantee perfect calibration

Correct Answer: C. To prevent highly related records from appearing in both training and validation data

Question 9

Which statement best distinguishes a confidence interval from a prediction interval?

A. A prediction interval concerns a future observation and generally includes outcome noise

B. A confidence interval always has greater width

C. A prediction interval estimates only a model coefficient

D. They are identical under all regression models

Correct Answer: A. A prediction interval concerns a future observation and generally includes outcome noise

Question 10

Why should a model’s explanation not automatically be interpreted as a causal explanation?

A. Explanations cannot be computed for any model

B. Feature importance may reflect correlation or proxy information rather than causal influence

C. Causal relationships are always unrelated to prediction

D. Only accuracy metrics can reveal causation

Correct Answer: B. Feature importance may reflect correlation or proxy information rather than causal influence

Statistics and Probability for Data Science
Chapter 14 of 15

Statistics and Probability for Data Science

Chapter 15
Responsible Statistical Practice, Governance and Emerging Trends

Post Graduate Diploma in Data Science
Statistics and Probability for Data Science   •   Post Graduate

15. Responsible Statistical Practice, Governance and Emerging Trends

Introduction and Context

Statistical analysis is often presented as a technical activity: collect data, estimate parameters, test hypotheses, and communicate results. In professional data science, however, statistical work is also an institutional activity. A model may influence credit decisions, medical treatment, employment, public services, insurance premiums, or the allocation of scarce resources. Consequently, the quality of a statistical result depends not only on mathematical validity but also on how data were obtained, transformed, documented, protected, interpreted, monitored, and governed.

Responsible statistical practice connects statistical reasoning with reproducibility, privacy, fairness, transparency, accountability, and risk management. It asks questions that extend beyond “Is the estimate statistically significant?” These include: Who generated the data? Which people are represented or excluded? Can another analyst reproduce the result? What assumptions support the model? How might the output cause harm? What happens when the population changes? Who is authorized to approve deployment or suspend a system?

This chapter develops a governance-oriented view of statistical practice. It begins with reproducible workflows and data lineage, then examines missing data, privacy, fairness, transparency, model risk, drift, and regulatory controls. It concludes by evaluating synthetic data, causal artificial intelligence, automated experimentation, and scalable probabilistic systems. The central argument is that statistical competence at postgraduate level includes the ability to design trustworthy analytical systems, not merely to calculate accurate predictions.

Learning Objectives

By the end of this chapter, students should be able to:

1. Design a reproducible statistical workflow using appropriate software, documentation, version control, and testing.

2. Diagnose missing-data mechanisms and select defensible treatment strategies.

3. Explain the relationship among privacy, fairness, transparency, data lineage, and accountability.

4. Establish controls for model risk, distributional drift, and responsible deployment.

5. Evaluate synthetic data, causal AI, automated experimentation, and scalable probabilistic systems critically.

6. Apply governance principles to organizational and regulatory decision-making.

7. Identify limitations, ethical risks, and trade-offs in contemporary statistical practice.

Statistical Practice as a Governed System

A statistical product is better understood as a lifecycle than as a single model. The lifecycle usually includes problem formulation, data acquisition, data preparation, exploratory analysis, model development, validation, deployment, monitoring, review, and retirement. Errors introduced early can be concealed by sophisticated modelling later. For example, an apparently accurate fraud model may simply learn that a particular neighbourhood was investigated more heavily in the past. The model can reproduce institutional practice rather than underlying fraud risk.

Governance provides the structures through which analytical decisions are authorized, recorded, challenged, and revised. It includes policies, roles, controls, standards, review procedures, and evidence. Statistical governance is therefore not synonymous with bureaucracy. Its purpose is to preserve the connection between an analytical claim and the evidence supporting it.

A useful distinction is between validity, reliability, and responsibility. Validity concerns whether a method answers the intended question. Reliability concerns whether the process produces stable and reproducible results. Responsibility concerns whether the use of the result is ethically defensible, legally permissible, and appropriately accountable. A result can possess one property without possessing the others.

Reproducible Workflows and Data Lineage

Reproducibility means that an independent analyst can obtain substantially the same results using the same inputs, procedures, and computational environment. Replicability is related but often refers to obtaining consistent findings with new data or an independently implemented analysis. Both are important. A notebook that runs only on its author’s computer is not a robust professional workflow.

A reproducible workflow normally separates raw data, processed data, analysis code, configuration, outputs, and documentation. Raw data should be preserved as an immutable reference, subject to lawful retention and privacy requirements. Transformations should be represented as executable code or clearly recorded operations rather than hidden spreadsheet edits. Random seeds, software versions, package dependencies, parameter settings, and data snapshots should be recorded where they affect results.

Version control systems allow analysts to track changes to code and documentation. Data versioning or cryptographic checksums can establish which dataset was used. Continuous integration can run unit tests, schema checks, and statistical validation whenever code changes. Containers or environment specifications reduce the risk that library updates silently alter results. A strong workflow also produces a results manifest containing the analysis date, data source, sample definition, exclusions, model specification, evaluation metrics, and responsible personnel.

Data lineage is the documented history of data as they move from origin to analytical output. It identifies sources, transformations, joins, aggregations, access rights, and destinations. Lineage is essential when a result is challenged. An organization should be able to answer: Which source records contributed to this estimate? Which transformations were applied? Which version of the code produced it? Who approved the release?

Reproducibility does not mean that every dataset should be publicly released. Confidentiality may require restricted access, de-identification, secure enclaves, or synthetic demonstration data. The goal is reproducible reasoning and controlled verifiability, not indiscriminate disclosure.

Missing Data: Statistical Treatment and Governance

Missingness is not merely an inconvenience in data cleaning. It may carry information about the process that generated the data. Three standard concepts are useful. Data are missing completely at random (MCAR) when missingness is unrelated to observed and unobserved values. Data are missing at random (MAR) when missingness may depend on observed variables but, conditional on them, not on the missing value itself. Data are missing not at random (MNAR) when missingness depends on unobserved values or other unmeasured factors.

These categories are assumptions about a data-generating process, not labels that can be established mechanically from the dataset. A missing income value may be approximately MAR after accounting for occupation and age, but it may be MNAR if people with very high or very low incomes are less willing to report them.

Common treatments include complete-case analysis, single imputation, multiple imputation, model-based methods, and explicit missingness indicators. Complete-case analysis is simple but can reduce power and create bias unless its assumptions are defensible. Mean imputation distorts variability and relationships and should rarely be used for inferential analysis. Multiple imputation represents uncertainty by creating several plausible completed datasets, analysing each, and combining estimates using appropriate rules. Sensitivity analysis examines how conclusions change under alternative assumptions about unobserved values.

A responsible workflow records the amount and pattern of missingness, the reason for each exclusion, the imputation model, variables used to predict missing values, and the effect of the decision on results. Missingness can also create fairness problems. If a service is less accessible to a disadvantaged group, that group may have systematically incomplete records; deleting incomplete cases then removes the group from analysis.

Privacy, Confidentiality, and Statistical Disclosure

Privacy concerns the appropriate use of information about persons, whereas confidentiality concerns obligations to protect information entrusted to an organization. Removing names is not sufficient anonymization. Records may be re-identified by combining quasi-identifiers such as age, location, occupation, and dates with external data.

Privacy-preserving practice begins with purpose limitation and data minimization: collect and retain only information justified by a legitimate analytical purpose. Access should follow role-based permissions, and sensitive attributes should be protected through encryption, secure storage, auditing, and controlled sharing. Aggregation and suppression may reduce disclosure risk, but they can also reduce analytical value.

Differential privacy provides a formal approach to limiting the influence of any one individual on a released statistical output. Informally, a differentially private mechanism produces outputs whose distributions are similar whether or not a particular person’s record is included. The privacy parameter, commonly written as epsilon, controls a privacy–utility trade-off: stronger privacy generally introduces more noise and reduces precision. Privacy budgets must be managed across repeated queries because privacy loss can accumulate.

Privacy is not the same as fairness. A dataset can be securely protected yet support discriminatory decisions. Conversely, fairness auditing may require access to sensitive attributes that should not be used directly in prediction. Governance must therefore specify who may access protected variables, for what purpose, under what controls, and for how long.

Fairness and Transparency in Statistical Decision Systems

Fairness is context-dependent. Group fairness compares outcomes or error rates across defined groups. Examples include demographic parity, equal opportunity, equalized odds, and calibration. These criteria are not generally equivalent, and mathematical incompatibility can arise when base rates differ across groups. Individual fairness asks whether similar individuals are treated similarly, but it depends on a defensible definition of similarity. Procedural fairness considers whether people received consistent processes, explanations, opportunities to appeal, and human review.

Fairness assessment should examine the complete decision pipeline rather than only model predictions. Sampling, measurement, labels, feature construction, thresholds, human overrides, and access to remedies can each generate unequal outcomes. A model may have equal accuracy across groups but still be unfair if the target label reflects unequal historical enforcement.

Transparency has several layers. Technical transparency concerns model structure, data, assumptions, and performance. Process transparency concerns who developed, reviewed, approved, and monitored the system. User transparency concerns whether affected persons receive understandable information about the decision and available recourse. Transparency does not always require publishing source code; in some settings, security, privacy, or intellectual property considerations limit disclosure. It does require sufficient information for legitimate scrutiny.

Useful documentation includes a data sheet describing dataset origin, composition, collection procedures, limitations, and intended uses, and a model card describing purpose, training data, evaluation populations, metrics, known limitations, and prohibited uses. Explanations should distinguish correlation from causation and should not present post hoc feature-attribution methods as complete causal explanations.

Model Risk, Validation, and Drift

Model risk is the possibility of adverse consequences because a model is incorrect, misused, poorly implemented, or applied outside its intended context. A model with high predictive accuracy can still create serious risk if its output is used for a different decision than the one for which it was validated.

A model risk management framework typically classifies models by materiality and maintains an inventory. Each model should have an owner, defined purpose, input and output specifications, validation evidence, limitations, approval status, and review schedule. Independent validation should challenge the development team’s choices, examine data quality, test assumptions, reproduce results, and evaluate performance across relevant subgroups.

Validation should include discrimination, calibration, stability, robustness, sensitivity, and operational performance. For probabilistic predictions, calibration is especially important: among cases assigned a probability of 0.7, approximately 70 percent should experience the event under an appropriate reference population. Confidence intervals and uncertainty estimates should accompany point estimates where decisions depend on precision.

Drift occurs when the relationship between a model and its operating environment changes. Covariate drift involves a change in input distributions. Label or concept drift involves a change in the outcome process or in the relationship between inputs and outcomes. Drift monitoring can compare distributions using summary statistics, population stability measures, divergence measures, or statistical tests, but practical significance matters more than a mechanically chosen p-value in very large datasets.

Monitoring should track data quality, missingness, subgroup performance, calibration, latency, alert rates, user overrides, and adverse outcomes. An alert is not automatically evidence that retraining is appropriate. The organization should investigate whether the change reflects a temporary event, measurement failure, population shift, policy change, or model deterioration. Predefined thresholds for review, rollback, retraining, and retirement make responses less arbitrary.

A Governance Framework for Responsible Statistical Work

A practical governance framework can be organized around six questions:

1. Purpose: What decision or knowledge claim is the analysis intended to support, and what uses are prohibited?

2. Provenance: Where did the data come from, under what authority, and through which transformations?

3. Method: Are the statistical assumptions, estimands, validation procedures, and uncertainty measures appropriate?

4. Impact: Who may benefit, bear risk, be excluded, or be misclassified?

5. Control: Who approves, monitors, audits, explains, and can suspend the system?

6. Change: How will the system respond to new data, drift, errors, regulation, or changed objectives?

These questions can be implemented through an analytical impact assessment, model documentation, data protection assessment, peer review, pre-registration for high-stakes experiments, and a controlled change-management process. Governance should be proportionate to risk. A dashboard used for internal exploration does not require the same approval process as an automated medical triage system, although both require data quality and security controls.

Roles should be explicit. Data owners authorize use and define stewardship requirements. Data scientists develop analyses. Independent validators challenge methods. Domain experts assess substantive meaning. Legal, privacy, and ethics specialists interpret obligations. Business owners accept residual risk. Senior governance committees approve high-impact systems. A responsible culture also protects analysts who raise concerns.

Applied Case: Illustrative Credit-Limit Review System

Background

A fictional digital bank, Meridian Finance, develops a system to recommend credit-limit changes for existing customers. The stated objective is to reduce default while offering suitable limits to customers with stable repayment capacity.

Situation and Problem

The development dataset contains transaction history, repayment records, employment information, and customer-service contacts. Performance is strong overall, but a review finds that applicants from two regions receive lower recommended limits. Income is missing more frequently in these regions, and the historical outcome label—“default”—is influenced by collection intensity and prior limit reductions. Executives request rapid deployment because a competitor has introduced a similar product.

Analysis

The team first maps data lineage and discovers that regional codes were copied from an old branch-management system. A missingness analysis shows that income reporting depends on application channel and region. Complete-case analysis would disproportionately exclude customers in the affected regions. The team therefore develops multiple-imputation scenarios and reports uncertainty rather than a single completed value.

Fairness analysis compares approval rates, false-negative rates, calibration, and average recommended limits across groups. The differences cannot be interpreted without considering repayment history, access to credit, and the label-generation process. The team finds that collection activity is a problematic proxy: customers with more aggressive collection intervention are more likely to receive the default label even when their underlying repayment capacity is comparable.

An independent validation team reproduces the pipeline from version-controlled code. It identifies leakage from a variable recorded after a prior limit decision and removes it. The model is calibrated separately across relevant segments, and a conservative threshold is selected using cost estimates for false approvals and false denials. Customers receive an explanation of the principal factors, a route for human review, and a correction mechanism for inaccurate data.

Approach and Governance Solution

Meridian classifies the system as high impact. Deployment is staged, with a silent evaluation period before recommendations affect customers. Monitoring covers drift, missingness, calibration, subgroup error rates, complaints, overrides, and adverse outcomes. A model card records intended use, excluded uses, training population, limitations, and review dates. The bank also establishes a rollback rule and requires reapproval after material changes to data sources or decision thresholds.

Outcome

The revised system produces slightly lower aggregate short-term savings than the original model but improves calibration and reduces unexplained regional disparities. More importantly, the bank can trace recommendations to source data, explain decisions, and investigate complaints. The system is approved for limited deployment subject to quarterly review rather than unrestricted automation.

Learning Points

The case illustrates that governance can improve statistical quality rather than merely restrict innovation. It also shows that fairness cannot be repaired by changing a threshold alone when labels, missingness, and historical decisions are themselves biased. Independent validation, documented lineage, uncertainty analysis, human recourse, and monitoring are mutually reinforcing controls.

Emerging Statistical Technologies and Their Strategic Evaluation

Synthetic Data

Synthetic data are artificially generated records designed to preserve selected statistical properties of real data without directly reproducing the original records. They may support software testing, method development, education, or controlled data sharing. Generative models can capture complex dependencies, but synthetic data are not automatically private. A model may memorize rare records, and utility may be poor for minority subgroups or tail events.

Evaluation should compare marginal distributions, correlations, conditional relationships, subgroup representation, downstream analytical utility, and disclosure risk. Synthetic data should not be used to conceal inadequate data collection or to make unsupported claims about real-world performance. For high-stakes use, synthetic data are generally a supplement for development and testing, not a substitute for validation on appropriately governed real data.

Causal AI

Predictive models estimate what is likely; causal methods seek to estimate what would happen under an intervention. Causal AI combines causal graphs, potential-outcomes reasoning, machine learning, and domain knowledge. Its value lies in questions such as: What would be the effect of increasing a treatment? Which policy should be implemented? For whom might an intervention help or harm?

Causal conclusions require assumptions about treatment assignment, confounding, interference, measurement, and transportability. A sophisticated algorithm cannot identify an effect that the data and design do not support. Randomized experiments, natural experiments, longitudinal data, instrumental variables, difference-in-differences, and causal graphs each offer different identification strategies with different weaknesses. Governance should require explicit statements of the estimand, intervention, target population, assumptions, and sensitivity to unmeasured confounding.

Automated Experimentation

Digital platforms can run many A/B tests, adaptive experiments, bandit algorithms, and sequential decision procedures. Automation can accelerate learning, but uncontrolled experimentation creates risks: repeated peeking can inflate false-positive rates, simultaneous tests can conflict, and short-term engagement may harm long-term welfare. Experiment registries, pre-specified primary outcomes, stopping rules, guardrail metrics, randomization checks, and correction for multiplicity are essential.

Adaptive experimentation can allocate more users to promising alternatives, but the resulting estimates require methods that account for the adaptive design. Ethical review remains necessary when interventions affect vulnerable users, prices, access, or safety. The ability to run an experiment is not evidence that it should be run.

Scalable Probabilistic Systems

Modern organizations increasingly use probabilistic programming, Bayesian hierarchical models, distributed computation, streaming data, and simulation-based inference. These systems can represent uncertainty, partial pooling, latent variables, and complex dependence more realistically than simple point-prediction pipelines. They are useful for demand forecasting, risk analysis, experimentation, reliability, and real-time decision support.

Scale introduces new governance problems. Approximate inference may fail silently; distributed data may have inconsistent definitions; posterior results may depend on prior choices and computational diagnostics; streaming systems may change while being monitored. Responsible deployment requires convergence checks, posterior predictive checks, prior sensitivity analysis, reproducible infrastructure, monitoring of approximation error, and clear communication of uncertainty to decision-makers.

Challenges, Limitations, and Common Mistakes

Several recurring mistakes weaken responsible statistical practice. Treating a dashboard as a neutral description ignores choices about definitions and exclusions. Treating a fairness metric as a universal definition of justice ignores context and competing criteria. Removing sensitive attributes from a model does not remove their proxies. Publishing an explanation generated after deployment does not necessarily reveal how the model actually made its decision. Retraining automatically after drift may entrench temporary anomalies or amplify feedback loops.

Other problems arise from organizational incentives. Teams may optimize a measurable proxy rather than the real objective, suppress negative findings, or prioritize launch speed over validation. Governance documents can become ceremonial if no person owns the decision or if monitoring alerts have no response plan. Statistical uncertainty may be hidden because leaders prefer a definitive number. Ethical review can also become detached from technical development if it occurs only after the model is complete.

No framework eliminates uncertainty or value judgments. Fairness standards can conflict, privacy protection can reduce utility, and transparency can increase gaming or disclosure risk. The appropriate response is not to claim perfect neutrality but to make assumptions, trade-offs, and accountability visible.

Best Practices for Professional Implementation

A mature statistical organization should:

  • define the decision, estimand, intended population, and prohibited uses before modelling;
  • preserve raw data appropriately and maintain complete lineage for transformations;
  • use version control, tested code, pinned environments, and reproducible computational records;
  • report missingness, uncertainty, sensitivity analyses, and subgroup performance;
  • minimize data collection and protect access through security, privacy, and retention controls;
  • conduct independent validation for material or high-impact models;
  • document data and models with limitations, assumptions, and known failure conditions;
  • monitor drift, calibration, data quality, fairness indicators, complaints, and operational outcomes;
  • provide meaningful explanations, human review, correction, and appeal where decisions affect people;
  • establish approval, change-control, rollback, retirement, and incident-response procedures; and
  • treat governance as a continuous learning process supported by technical and domain expertise.

Chapter Summary

Responsible statistical practice extends statistical validity into a lifecycle of reproducibility, privacy, fairness, transparency, accountability, and monitoring. Reproducible workflows depend on versioned code, controlled environments, documented assumptions, and data lineage. Missing data require reasoning about the generating process and sensitivity to assumptions. Privacy protection involves minimization, access control, disclosure assessment, and, where appropriate, differential privacy. Fairness must be assessed across data, labels, models, decisions, and opportunities for appeal rather than reduced to one metric.

Model governance addresses risk through inventories, ownership, independent validation, documentation, approval, monitoring, and controlled change. Drift monitoring distinguishes changing inputs from changing relationships and links alerts to defined responses. Synthetic data, causal AI, automated experimentation, and scalable probabilistic systems offer substantial strategic value, but each introduces assumptions and new forms of risk. The professional responsibility of a data scientist is therefore to build systems that are not only accurate, but also traceable, contestable, appropriately limited, and fit for their social and organizational context.

Key Terms

Reproducibility: The ability to obtain substantially the same results using the same data, code, and computational conditions.

Replicability: The ability to obtain consistent findings through an independent implementation or new data.

Data lineage: The documented origin, transformation history, movement, and use of data.

MCAR: Missingness unrelated to observed or unobserved values.

MAR: Missingness dependent on observed information after conditioning on relevant variables.

MNAR: Missingness related to unobserved values or factors not adequately represented in the data.

Multiple imputation: A method that creates several plausible completed datasets and combines the resulting analyses.

Differential privacy: A formal privacy guarantee limiting the effect of any individual record on a released output.

Fairness: The context-dependent requirement that statistical decisions and their processes avoid unjustified disadvantage and provide appropriate recourse.

Calibration: Agreement between predicted probabilities and observed event frequencies.

Model risk: The possibility of harm arising from model error, misuse, implementation failure, or inappropriate application.

Drift: Change over time in input distributions, outcomes, or the relationship between inputs and outcomes.

Model card: Documentation describing a model’s purpose, data, performance, limitations, and appropriate uses.

Data sheet: Documentation describing a dataset’s origin, composition, collection, intended uses, and limitations.

Synthetic data: Artificially generated data designed to reproduce selected properties of real data.

Causal inference: The estimation of effects produced by interventions rather than mere associations.

Estimand: The precisely defined quantity or causal effect that an analysis seeks to estimate.

Automated experimentation: The use of software systems to design, assign, monitor, or adapt experiments.

Probabilistic programming: Computational modelling that represents uncertainty through probability distributions and inference algorithms.

Review Questions

Short Answer Questions

1. Distinguish reproducibility from replicability.

2. Why can complete-case analysis create unfair outcomes?

3. What is data lineage, and why is it important during model review?

4. Explain the purpose of calibration monitoring.

5. State two limitations of synthetic data.

Long Answer Questions

1. Explain how a reproducible statistical workflow can be implemented from data acquisition through deployment.

2. Compare MCAR, MAR, and MNAR, and discuss suitable responses to each situation.

3. Discuss the relationship among privacy, fairness, and transparency in high-impact statistical systems.

4. Develop a model risk governance framework for an organization using predictive models in customer decisions.

5. Explain the assumptions and governance requirements of causal AI and automated experimentation.

Analytical / Application Questions

1. A hospital prediction model has stable overall accuracy but substantially worse calibration for older patients after a change in referral policy. Diagnose possible causes and propose a monitoring and response plan.

2. An organization wants to release synthetic employee data for research. Design an evaluation covering utility, subgroup representation, disclosure risk, and appropriate limitations.

3. A digital platform runs hundreds of adaptive experiments and selects the variant with the highest short-term engagement. Analyse the statistical and ethical risks and recommend controls.

22. Multiple Choice Questions with Answers

Question 1

Which practice most directly supports reproducibility in a statistical workflow?

A. Replacing all missing values with the mean

B. Recording code, software versions, data snapshots, and random seeds

C. Removing all sensitive variables before analysis

D. Selecting the model with the highest training accuracy

Correct Answer: B. Recording code, software versions, data snapshots, and random seeds

Question 2

A variable is missing more often for users applying through a particular channel, and that channel is observed. Which missingness assumption may be reasonable if no additional dependence remains after conditioning on the channel?

A. MCAR

B. MAR

C. MNAR

D. Structural missingness only

Correct Answer: B. MAR

Question 3

What is the principal purpose of differential privacy?

A. To guarantee that a model is fair across all groups

B. To prevent any statistical estimation from being performed

C. To limit the influence of an individual record on a released output

D. To remove all measurement error from a dataset

Correct Answer: C. To limit the influence of an individual record on a released output

Question 4

Why is removing a protected attribute from a model insufficient to guarantee fairness?

A. Models cannot operate without protected attributes

B. Other variables may act as proxies, and unfairness may arise in labels or processes

C. Protected attributes are always required for calibration

D. Removing variables necessarily increases discrimination

Correct Answer: B. Other variables may act as proxies, and unfairness may arise in labels or processes

Question 5

Which situation best illustrates concept drift?

A. The proportion of missing values increases because a data-entry field changed

B. The distribution of customer ages changes but the outcome relationship remains constant

C. The relationship between observed inputs and default risk changes after a major economic shift

D. A database table is renamed without changing its records

Correct Answer: C. The relationship between observed inputs and default risk changes after a major economic shift

Question 6

What should an organization do when a drift-monitoring alert is triggered?

A. Automatically retrain the model without investigation

B. Ignore it unless overall accuracy reaches zero

C. Investigate the cause and assess whether review, recalibration, rollback, or retraining is appropriate

D. Delete the historical monitoring records

Correct Answer: C. Investigate the cause and assess whether review, recalibration, rollback, or retraining is appropriate

Question 7

Which statement about synthetic data is most accurate?

A. Synthetic data are automatically anonymous and risk-free

B. Synthetic data can be useful for development but require utility and disclosure-risk evaluation

C. Synthetic data always preserve minority-group relationships accurately

D. Synthetic data remove the need for validation on real data

Correct Answer: B. Synthetic data can be useful for development but require utility and disclosure-risk evaluation

Question 8

What distinguishes a causal question from a predictive question?

A. A causal question concerns the effect of an intervention

B. A causal question never requires assumptions

C. A predictive question always uses randomized experiments

D. A predictive question cannot use probability

Correct Answer: A. A causal question concerns the effect of an intervention

Question 9

Which control is most appropriate for automated experimentation on a platform where repeated testing may inflate false positives?

A. Use only the experiment with the largest sample mean

B. Allow continuous peeking without a stopping rule

C. Pre-specify outcomes and stopping rules and account for multiplicity

D. Remove all control groups

Correct Answer: C. Pre-specify outcomes and stopping rules and account for multiplicity

Question 10

A model card should primarily communicate which information?

A. Only the model’s source code

B. Purpose, training context, performance, limitations, and appropriate uses

C. Only the names of the developers

D. A guarantee that the model will remain accurate indefinitely

Correct Answer: B. Purpose, training context, performance, limitations, and appropriate uses

Statistics and Probability for Data Science
Chapter 15 of 15