STATHARBOR ANALYTICS · INTRODUCTION TO STATISTICS · CHAPTER 2
Data Collection and Sampling
Reliable data are the foundation of statistical inference. How you collect data affects the conclusions you can draw. This chapter covers basic principles of study design, sampling and the common pitfalls that can undermine analyses.
Why Sampling?
In most situations it is impractical or impossible to measure an entire population. Instead, we take a sample and use it to make inferences about the population. A sampling frame is a list or procedure that defines the population of interest. Ideally, each member of the population has a known, non-zero probability of being selected.
Sampling Methods
Simple random sampling (SRS): Each unit in the population has an equal chance of being selected. SRS yields unbiased estimates of population means and proportions.
Stratified sampling: The population is divided into strata (e.g. age groups). Random samples are drawn from each stratum. Stratification can increase precision when strata differ.
Cluster sampling: The population is divided into clusters (e.g. households, schools). A random sample of clusters is selected, and all units within selected clusters are observed. Clustering is efficient when clusters are naturally defined and travel costs are high.
Systematic sampling: Every th unit from a list is selected. If the list has no hidden order, systematic sampling approximates SRS.
Bias and Non-Response
Selection bias: When the sampling method systematically excludes some parts of the population. For example, telephone surveys may under-represent people without landlines.
Non-response bias: If individuals who do not respond differ systematically from those who do, estimates can be biased. Follow-ups and weighting can mitigate non-response.
Measurement error: Poorly designed questions and inaccurate instruments introduce error. Pre-testing questionnaires and calibrating instruments reduce measurement error.
Example: Estimating Average Study Hours
Suppose you wish to estimate the average number of hours per week that university students spend studying. The population is all students at your university. To obtain a simple random sample, you could:
Worked example
Obtain a list of all registered students (the sampling frame).
Use software to randomly select 200 student IDs.
Send a survey asking respondents to report their study hours.
R code to draw a simple random sample of student IDs:
# Suppose students is a vector of all student IDs
set.seed(123)
sample_size <- 200
sample_ids <- sample(students, sample_size)
Python code using NumPy:
import numpy as np
np.random.seed(123)
sample_size = 200
sample_ids = np.random.choice(students, size=sample_size, replace=False)
Julia code using Random:
using Random
Random.seed!(123)
sample_size = 200
sample_ids = rand(RandomSampler(students), sample_size)
Once the sample is selected, collect the study hours data. The sample mean provides an unbiased estimate of the population mean. The standard error quantifies uncertainty due to sampling.
Exercises
Practice
Describe how you would design a stratified sample to estimate average commuting times in a city with distinct neighbourhoods. Which strata would you choose and why?
Simulate a simple random sample of 100 numbers from 1 to 10 000 in R, Python or Julia. Compute the sample mean and compare it to the population mean.
Explain why cluster sampling might be preferred over simple random sampling in a survey of high-school students’ dietary habits.
Discuss the potential sources of bias in an online poll about voting intentions. How could you attempt to correct for them?
References
Lohr SL. Sampling: Design and Analysis. 2nd ed. Brooks/Cole; 2010.
Kish L. Survey Sampling. New York: Wiley; 1965.
Valliant R, Dever JA, Kreuter F. Practical Tools for Designing and Weighting Survey Samples. New York: Springer; 2013.