Sampling Plan Template (Statistics, Survey Design, R and Python)
Target population, frame and unit; probability and non-probability designs; bias sources; margin of error with finite population correction; seeded stratified sampling in R and Python
사용법: Use before collecting survey or inspection data to define the population, frame and unit, choose a sampling design and size the sample. Work through the decision flow, compute n with the margin-of-error formula and FPC, then fill the plan table and record the seed before drawing. Main pitfall: assuming a large sample is representative when the frame or selection process is biased.
미리보기
Sampling Plan: [Your study population and question]
A working sampling plan for your own survey, study or quality check: it defines the target population, the sampling frame and the unit, chooses a probability or non-probability design, lists the bias risks, and sizes the sample with a margin-of-error calculation, with seeded R and Python code that draws a stratified sample. It is for methods students, thesis writers planning data collection and analysts who must defend how their data were chosen. It speeds up learning by making you answer the same five questions in the same order for every study, so the logic of "who could have been in my data" becomes automatic. The worked examples use fictional data; replace them with your own. Source basis: classic survey sampling texts (Cochran 1977, Kish 1965, Lohr 2021) and the NIST/SEMATECH e-Handbook, written in original words.
Document control
| Field | Value |
|---|---|
| Course or project | [Course code and title, or study name] |
| Learner or analyst | [Your name] |
| Data set | [Sampling frame file name and date, e.g. residence_list_2026-02-01.csv] |
| Software and versions | R 4.5.1 (base and stats); Python 3.14 with numpy 2.5.4, pandas 3.1.0, scipy 1.18.1 |
| Date | YYYY-MM-DD |
| Version | [0.1] |
What a sampling plan decides
Almost every statistical method assumes that the data are a random sample from some population. A sampling plan is where you make that assumption true, or at least honest. It answers five questions:
- Who or what do I want to describe? (target population)
- Which list or procedure can I actually draw from? (sampling frame)
- What is one "case"? (sampling unit and observation unit)
- How are cases chosen? (design: probability or not, and which one)
- How many do I need, and how many will I invite? (sample size and expected response)
The diagram shows where each kind of error enters. Each step loses or distorts part of the population, and only one of these errors (sampling error) is measured by a standard error or a confidence interval. The others must be handled by design and described in your limitations.
| Use this template when | Not the right tool when |
|---|---|
| You will survey or measure a subset of a defined group | You will measure every unit (a census): then document coverage and nonresponse only |
| You must justify representativeness to a supervisor, examiner or client | You randomise units to treatments in an experiment (use academic/stats-experiment-design for allocation) |
| You plan a quality-control inspection of items from production | The question is purely about power for a hypothesis test (use academic/stats-power-sample-size) |
Population, frame and unit
| Term | Plain meaning | Lakemoor example | My study |
|---|---|---|---|
| Target population | The whole group your conclusions are about | All students enrolled at Lakemoor University in spring term | [ ] |
| Study population | The part of it you can realistically reach | Students enrolled on the census date with a university email | [ ] |
| Sampling frame | The actual list or procedure used to draw the sample | Registry export of 4,000 enrolled students with faculty and email | [ ] |
| Sampling unit | What is drawn from the frame | One student (or, in a cluster design, one seminar group) | [ ] |
| Observation unit | What is measured | One student's questionnaire | [ ] |
| Undercoverage | In population, missing from frame | Students who enrolled after the census date | [ ] |
| Overcoverage | In frame, not in population | Students who withdrew but are still listed | [ ] |
A frame is good when every member of the target population appears exactly once and you have the information needed to stratify or contact them. Duplicates (one person listed twice) give that person a double chance of selection; missing groups get zero chance, and no sample size can fix a zero.
Probability sampling designs
In a probability sample, every unit in the frame has a known, non-zero chance of being selected, and chance alone (a seeded random number generator, not the researcher) makes the selection. That known chance is what lets you compute standard errors, confidence intervals and design weights.
| Design | How it works | When it fits | Strength | Limit |
|---|---|---|---|---|
| Simple random sampling (SRS) | Every possible sample of size n is equally likely | Complete list, fairly homogeneous population | Simplest analysis; the textbook formulas assume it | Small subgroups may get very few cases by chance |
| Systematic | Random start between 1 and k, then every k-th unit, with | Ordered lists, production lines, queues | Easy in the field; spreads the sample over the list | Bias if the list has a cycle that matches k (periodicity) |
| Stratified | Split the frame into groups (strata), take a random sample in each | Known subgroups that differ on the outcome, or that you must report separately | More precise than SRS when strata differ; guarantees each group is present | Needs the stratum variable in the frame; unequal allocation needs weights |
| Cluster | Randomly select whole groups (classes, branches, days), measure everyone in them | No list of individuals but a list of groups exists; travel costs matter | Cheap and practical | Less precise than SRS of the same n because people in a cluster are alike (design effect) |
| Multistage | Sample clusters, then sample units inside the chosen clusters, possibly in more stages | Large or national surveys | Balances cost and precision | Complex weights and variance estimation; needs survey software |
Two technical terms appear in every design. The inclusion probability is the chance that unit is selected. The design weight is its inverse, : the number of population units each sampled unit "stands for". In SRS all weights are equal, so they can be ignored for means and proportions. In a stratified design with proportional allocation (each stratum sampled at the same fraction), weights are also equal. With disproportionate allocation (for example, oversampling a small faculty so it can be analysed on its own), the weights differ and must be used for whole-population estimates. Neyman (1934) showed that, for a fixed total n, the most precise allocation samples more heavily from strata that are larger and more variable.
For cluster designs, the precision loss is summarised by the design effect. With clusters of average size and intraclass correlation (how alike people in the same cluster are):
If students per seminar group and , then deff : a cluster sample of 400 students carries about as much information as a simple random sample of 200.
Non-probability designs and their limits
Non-probability samples are chosen by convenience, judgement or self-selection. They are fast and sometimes the only option (pilot studies, hard-to-reach groups, early product research), but the inclusion probabilities are unknown, so the usual standard errors describe only chance variation within an unknown selection process.
| Design | How it works | Legitimate use | Main limit |
|---|---|---|---|
| Convenience | Whoever is easy to reach (a lecture class, a shopping street) | Pilot testing of a questionnaire | The sample mirrors the access route, not the population |
| Voluntary response (self-selected) | People opt in, for example an online poll link | Gathering opinions, not estimating prevalence | People with strong views or free time are over-represented |
| Quota | Fill set numbers per group (e.g. 50% women), by any method within groups | Fast market research matched on a few variables | Matches the quota variables only; selection inside groups is uncontrolled |
| Purposive (judgement) | Researcher picks typical or extreme cases | Qualitative studies, expert panels | Generalisation rests on the researcher's judgement |
| Snowball (respondent-driven) | Participants recruit further participants | Hidden or hard-to-reach populations | Networks over-represent connected people; independence fails |
The honest rule for reporting a non-probability sample: describe who took part, compare their profile with known population figures where possible, and present uncertainty statements with an explicit caveat. A large non-probability sample can be precisely wrong: more cases shrink the standard error but do not remove selection bias.
Choosing a design
Start at the top and answer each question about your frame. The first question is the most important: without a complete list of units, simple random, systematic and stratified designs are not possible, and the choice is between sampling groups (clusters) and a non-probability design with stated limits. When several designs are possible, prefer the one that guarantees the subgroups you must report and keeps the analysis as simple as the question allows.
Bias sources to plan against
Bias is a systematic difference between what the sample tells you and the population truth. It does not shrink when the sample grows, which is why it matters more than random error in large studies.
| Bias | What happens | Lakemoor or Harbour City example | Design action |
|---|---|---|---|
| Selection bias | The way units enter the sample is related to the outcome | Surveying library use by approaching students inside the library | Use a probability design from a complete frame |
| Coverage bias | Part of the population is missing from the frame | Using a residence-hall list to study all students misses commuters | Choose a better frame or combine frames; report the excluded group |
| Nonresponse bias | People who answer differ from those who do not | Stressed students are less likely to complete a stress survey | Reminders, short questionnaire, compare respondents with frame data, weighting |
| Measurement bias | Answers are systematically wrong | Students over-report study hours to a lecturer | Anonymous collection, neutral wording, validated scales |
| Survivorship bias | Only units that "survived" a process are observed | Studying graduates' study habits ignores those who dropped out | Sample before the filtering event, or include the lost cases |
Survivorship bias has a classic story: in the Second World War, the statistician Abraham Wald pointed out that the bullet holes on returning aircraft showed where planes could be hit and still return, so armour belonged where the returning planes had no holes. The planes that did not return were the missing data.
Response rate. Plan for it. If you expect 40% of invited students to respond and need 351 completes, invite . A higher invitation number does not cure nonresponse bias; it only protects the sample size.
Sample size and margin of error for a proportion
Plain language first. The margin of error (MOE) is half the width of a 95% confidence interval. It says how far the sample percentage is likely to be from the population percentage because of chance alone, assuming a probability sample and no other bias. It shrinks with the square root of the sample size n: to halve the MOE you need about four times as many cases. When the sample is a large share of a finite population (more than about 5%), a finite population correction (FPC) makes the MOE smaller, because you have already seen much of the population.
Formula. For a proportion estimated from a simple random sample of size from a population of size :
To plan the sample size for a target margin , first ignore the population size, then correct:
| Symbol | Meaning |
|---|---|
| Expected proportion; use 0.5 when unknown, because is largest there (the safe choice) | |
| Target margin of error, as a proportion (0.05 = 5 percentage points) | |
| Normal quantile; 1.96 for 95% confidence | |
| Population (frame) size | |
| Sample size for an infinite population | |
| Sample size after the finite population correction; round up | |
| deff | Design effect; multiply by it for cluster designs |
The full planning chain is: , then FPC, then multiply by the design effect, then divide by the expected response rate. For hypothesis tests and comparisons between groups, the question is power rather than margin of error: see academic/stats-power-sample-size.
The chart shows how the MOE for falls as the sample grows from a population of 4,000, with and without the FPC. The curves are close for small samples and separate once n is a large fraction of N.
Worked example A: a stratified sample of Lakemoor students
Setting. The Lakemoor University (fictional) student union wants to pilot a library-use questionnaire with 40 students from a frame of 400 students living in the two residence halls. The frame lists each student's faculty: ARTS 120, SCI 160, BUS 80, ENG 40. Faculties are expected to use the library differently, and the union wants every faculty present, so a stratified design with proportional allocation is chosen.
Step 1: allocation by hand. The sampling fraction is . Proportional allocation gives each stratum 10% of its size: ARTS , SCI 16, BUS 8, ENG 4. Total 40. Each sampled student represents students, so every design weight is 10.
Step 2: draw the sample with a seed. A seed makes the random draw reproducible: anyone running the script gets the same students. Record the seed in the plan before drawing, so nobody can re-draw until a "nicer" sample appears.
# Sampling frame: 400 Lakemoor University students (fictional)
frame <- data.frame(
student_id = sprintf("LU%03d", 1:400),
faculty = rep(c("ARTS", "SCI", "BUS", "ENG"), times = c(120, 160, 80, 40))
)
n_total <- 40
N_h <- table(frame$faculty)
n_h <- round(n_total * N_h / sum(N_h)) # proportional allocation
print(n_h)
set.seed(2026)
idx <- unlist(lapply(names(n_h), function(h) {
rows <- which(frame$faculty == h)
rows[sample.int(length(rows), n_h[[h]])]
}))
smp <- frame[idx, ]
smp$weight <- as.numeric(N_h[smp$faculty] / n_h[smp$faculty])
print(table(smp$faculty))
print(head(smp[smp$faculty == "ENG", ], 4), row.names = FALSE)
# Sample size for a proportion, margin 0.05, with finite population correction
z <- qnorm(0.975); p <- 0.5; e <- 0.05; N <- 4000
n0 <- z^2 * p * (1 - p) / e^2
n_fpc <- n0 / (1 + (n0 - 1) / N)
cat(sprintf("n0 = %.1f, n with FPC = %.1f -> %d\n", n0, n_fpc, ceiling(n_fpc)))
moe <- function(n, N, p = 0.5) z * sqrt(p * (1 - p) / n) * sqrt((N - n) / (N - 1))
cat(sprintf("MOE at n = 200: %.4f (no FPC %.4f)\n", moe(200, N), z * sqrt(0.25 / 200)))
ARTS BUS ENG SCI
12 8 4 16
ARTS BUS ENG SCI
12 8 4 16
student_id faculty weight
LU397 ENG 10
LU395 ENG 10
LU372 ENG 10
LU363 ENG 10
n0 = 384.1, n with FPC = 350.6 -> 351
MOE at n = 200: 0.0675 (no FPC 0.0693)
import numpy as np, pandas as pd
from scipy import stats
frame = pd.DataFrame({
"student_id": [f"LU{i:03d}" for i in range(1, 401)],
"faculty": np.repeat(["ARTS", "SCI", "BUS", "ENG"], [120, 160, 80, 40]),
})
n_total = 40
N_h = frame["faculty"].value_counts().sort_index()
n_h = (n_total * N_h / N_h.sum()).round().astype(int)
print(n_h.to_dict())
rng = np.random.default_rng(2026)
parts = [g.sample(n=n_h[h], random_state=rng) for h, g in frame.groupby("faculty")]
smp = pd.concat(parts)
smp["weight"] = smp["faculty"].map(N_h / n_h)
print(smp["faculty"].value_counts().sort_index().to_dict())
print(smp[smp["faculty"] == "ENG"].head(4).to_string(index=False))
z = stats.norm.ppf(0.975); p = 0.5; e = 0.05; N = 4000
n0 = z**2 * p * (1 - p) / e**2
n_fpc = n0 / (1 + (n0 - 1) / N)
print(f"n0 = {n0:.1f}, n with FPC = {n_fpc:.1f} -> {int(np.ceil(n_fpc))}")
moe = lambda n: z * np.sqrt(p * (1 - p) / n) * np.sqrt((N - n) / (N - 1))
print(f"MOE at n = 200: {moe(200):.4f} (no FPC {z*np.sqrt(0.25/200):.4f})")
{'ARTS': 12, 'BUS': 8, 'ENG': 4, 'SCI': 16}
{'ARTS': 12, 'BUS': 8, 'ENG': 4, 'SCI': 16}
student_id faculty weight
LU394 ENG 10.0
LU382 ENG 10.0
LU369 ENG 10.0
LU366 ENG 10.0
n0 = 384.1, n with FPC = 350.6 -> 351
MOE at n = 200: 0.0675 (no FPC 0.0693)
Step 3: read the output. Both languages allocate 12, 8, 4 and 16 students and give every student a weight of 10. The selected IDs differ (R picks LU397, LU395, LU372, LU363 among engineers; Python picks LU394, LU382, LU369, LU366). That is not an error: R and numpy use different random number generators, so the same seed number gives different streams. The design is the same; the draw is reproducible only within one language and version. Record the language, version and seed in the plan.
Step 4: size the main survey by hand. For the full survey of all 4,000 students, the union wants a 95% MOE of 5 percentage points with unknown, so :
.
FPC: , rounded up to 351 completed questionnaires. With an expected response rate of 40%, invite students.
The second output line shows the gain from the FPC at : the MOE is 6.75 points instead of 6.93 points. At this sampling fraction (5%) the correction is small; it matters more for small populations such as one residence hall or one bakery's daily output.
Interpretation and report sentence. "A stratified random sample of 40 students (proportional allocation by faculty, seed 2026, R 4.5.1) was drawn from the residence-hall list of 400 students; all design weights equal 10. The main survey requires 351 completed responses for a 95% margin of error of ±5 percentage points (N = 4,000, finite population correction applied), and 878 invitations at an expected 40% response rate."
Worked example B: Brightwell Bakery loaf inspection (half solved)
Setting. Brightwell Bakery (fictional) bakes 2,400 loaves per day on one line. Quality control will weigh 60 loaves per day. The loaves come off the line in trays of 8, and position 1 of every tray sits nearest the oven door, where loaves bake slightly lighter.
| Decision | Answer |
|---|---|
| Target population | All loaves baked that day |
| Frame | The production sequence 1 to 2,400 |
| Sampling unit | [ ] |
| Systematic interval | [ ] |
| Random start | A random integer between 1 and [ ] |
| Periodicity risk | The tray cycle is 8. Is a multiple of 8? [ ] If so, every sampled loaf sits in the same tray position, and the sample is [ ] |
| Fix | [Suggest a design that avoids the problem] |
| FPC for a mean: | [ ] (round to 3 decimals) |
Exercise C: Harbour City Library user survey
Harbour City Library (fictional) wants to estimate the percentage of its 12,000 registered card holders who would use an evening opening, with a 95% margin of error of ±4 percentage points. Nothing is known about the likely percentage. Past surveys had a 40% response rate. The frame is the card-holder database.
Tasks: (a) compute and the FPC-corrected ; (b) how many card holders should be invited? (c) name one group in the target population "people who might use an evening opening" that is not in the frame, and the type of bias it causes; (d) if the library instead hands questionnaires to visitors at the desk during the day, name the design and its main bias.
Plan table to fill in
| Item | My plan |
|---|---|
| Research question and main estimate | [e.g. percentage of students using the library weekly] |
| Target population | [ ] |
| Sampling frame (source, date, size N) | [ ] |
| Known undercoverage and overcoverage | [ ] |
| Sampling unit and observation unit | [ ] |
| Design and reason (path through the decision flow) | [ ] |
| Strata or clusters, with sizes | [ ] |
| Allocation (proportional, equal, Neyman) and resulting weights | [ ] |
| Target precision (MOE or power) | [e.g. ±5 points at 95%; or see academic/stats-power-sample-size] |
| Sample size: , FPC, design effect, final n | [ ] |
| Expected response rate and invitations | [ ] |
| Random procedure (software, version, seed) | [ ] |
| Main bias risks and actions (from the bias table) | [ ] |
| Nonresponse follow-up (reminders, comparison with frame) | [ ] |
| Ethics and data protection (consent, contact data handling) | [ ] |
| Example: Design and reason | Stratified by faculty with proportional allocation: complete registry list, faculties expected to differ, each faculty must be reported |
Common mistakes and misconceptions
| Mistake or misconception | Why it is wrong | Correct statement |
|---|---|---|
| "A big sample is representative." | Size reduces random error only; a biased selection stays biased at any n. | Representativeness comes from the selection process (probability design, good frame), not from n. |
| "The sample must be 10% of the population." | Precision depends mainly on n, not on the fraction; 400 people give similar precision from 4,000 or 4 million. | Size from the MOE or power formula; the FPC adjusts for large fractions. |
| Reporting a margin of error for a convenience or opt-in sample | The formula assumes known inclusion probabilities. | Describe the sample, compare with population figures, and caveat any uncertainty statement. |
| Ignoring weights after disproportionate stratification | Oversampled strata pull the overall estimate toward themselves. | Use design weights for population estimates. |
| Analysing a cluster sample as if it were SRS | People in a cluster are alike; standard errors come out too small. | Account for clustering (design effect, cluster-robust or survey methods, or mixed models). |
| Re-drawing until the sample "looks right" | Turns a random sample into a judgement sample. | Fix and record the seed before drawing; draw once. |
| Treating the respondents as the sample | Nonresponse can be selective. | Report the response rate and compare respondents with the frame. |
| Using "because it gives a smaller n" without evidence | Under-sizes the study if the true p is near 0.5. | Use 0.5 unless prior data justify another value. |
Self-test questions
- What is the difference between the target population and the sampling frame? Give a Lakemoor example of a gap.
- Why does a stratified sample with proportional allocation not need weights for a whole-population proportion, while an equal allocation of 10 per faculty (ARTS 120, SCI 160, BUS 80, ENG 40) does? Give the four weights.
- A cluster sample uses seminar groups of 26 students with . What is the design effect, and what effective sample size do 520 students give?
- Halving the margin of error requires multiplying the sample size by about how much? Why?
- Name the bias: a study of successful bakeries' habits based only on bakeries still open after five years.
- A probability survey of n = 351 reports 42% weekly library use with a 95% MOE of ±5 points. A student says, "there is a 95% chance the true value is between 37% and 47%." What is the more accurate statement?
My notes and next steps
| Item | My entry |
|---|---|
| Confidence with frames and coverage (1 to 5) | [ ] |
| Confidence choosing a design (1 to 5) | [ ] |
| Confidence with the MOE and FPC formulas (1 to 5) | [ ] |
| Questions still open | [ ] |
| Mistakes to copy into my error log (academic/stats-error-log) | [ ] |
| Next step | [Size comparisons with academic/stats-power-sample-size, then build the codebook] |
| Review again on | YYYY-MM-DD |
Sources and further reading
Based on standard survey sampling theory as presented in the texts below, written in original words; the margin of error and finite population correction formulas are standard results.
- Cochran, W. G. (1977). Sampling Techniques (3rd ed.). Wiley.
- Kish, L. (1965). Survey Sampling. Wiley (design effect).
- Lohr, S. L. (2021). Sampling: Design and Analysis (3rd ed.). CRC Press.
- Neyman, J. (1934). On the two different aspects of the representative method: the method of stratified sampling and the method of purposive selection. Journal of the Royal Statistical Society, 97(4), 558–625 (with discussion; optimal allocation).
- Horvitz, D. G., and Thompson, D. J. (1952). A generalization of sampling without replacement from a finite universe. Journal of the American Statistical Association, 47(260), 663–685 (inverse-probability weights).
- Groves, R. M., Fowler, F. J., Couper, M. P., Lepkowski, J. M., Singer, E., and Tourangeau, R. (2009). Survey Methodology (2nd ed.). Wiley (total survey error).
- NIST/SEMATECH e-Handbook of Statistical Methods, sections 7.2.2.2 and 7.2.4.2 Sample sizes required, https://www.itl.nist.gov/div898/handbook/ (accessed 2026-10-25). Public domain.
- Further reading: de Smith, M. J., Statistical Analysis Handbook (2024 edition, statsref.com); Diez, Çetinkaya-Rundel and Barr, OpenIntro Statistics (chapter on sampling principles).
Answer key
Worked example B. Sampling unit: one loaf. . Random start between 1 and 40. Yes, 40 is a multiple of 8 (), so every sampled loaf has the same tray position and the sample is biased (all light, if the start falls on position 1, or never including the light position otherwise). Fix: a simple random sample of 60 positions, a stratified sample with tray position as strata, or an interval that is not a multiple of 8 (for example with a check that it covers the day). FPC: .
Exercise C. (a) ; , round up to 572. (b) invitations. (c) People who do not hold a card (for example residents who stopped visiting because of the current hours): coverage bias, likely missing exactly those who want evening hours. (d) A convenience sample of daytime visitors: selection bias, because people who can visit in the day are less likely to need evening hours; a margin of error would not be meaningful.
Self-test.
- The target population is who you want to describe; the frame is the list you draw from. Example: target = all enrolled students; frame = residence-hall list, which misses commuters (undercoverage).
- With proportional allocation every student has the same inclusion probability (0.10), so all weights are equal and cancel. With 10 per faculty, inclusion probabilities differ, giving weights ARTS 12, SCI 16, BUS 8, ENG 4.
- deff ; effective sample size .
- About four times, because the MOE is proportional to , and .
- Survivorship bias.
- "The procedure used produces intervals that contain the true value in about 95% of repeated samples; this interval is 37% to 47%." The 95% describes the method, not a probability for this one interval, and it covers sampling error only, not nonresponse or coverage bias (see academic/stats-confidence-intervals).
Revision history
| Version | Date | Author | Change summary |
|---|---|---|---|
| 0.1 | YYYY-MM-DD | [Your name] | First draft |
| 0.2 | YYYY-MM-DD | [Your name] | Example: Switched from convenience to stratified design after supervisor review |
| 1.0 | YYYY-MM-DD | [Your name] | Frozen before drawing the sample (seed recorded) |
관련 템플릿
Statistical Analysis Plan Template (Statistics, Thesis or Project)
Statistical analysis plan for a thesis or project: estimands, hypotheses, sample size, primary model, pre-set assumption fallbacks, missing data, multiplicity, sensitivity, deviations log
학술Sampling Distributions and CLT Concept Card Template (Statistics, R and Python)
Sampling distributions concept card: population vs sample, standard error, Central Limit Theorem and when n is large enough, SE of a proportion and a difference in means, origin of the t distribution, seeded R and Python simulation with a Vega-Lite chart
학술Pre-Analysis Plan Template (Economics and Finance, AEA RCT Registry, OSF)
Registry fields, hypotheses, design, randomisation, power and MDE, outcomes, estimation, multiple testing, heterogeneity, exclusions, ethics, deviations log