Skip to contents

Design Specification

Build a sampling design step by step.

sampling_design()
Create a sampling design
stratify_by()
Define stratification
cluster_by()
Define sampling units (clusters)
draw()
Specify how units are selected
add_stage()
Define a new stage in multi-stage designs

Execution

Execute designs and validate frames.

execute()
Execute a sampling design
validate_frame()
Validate a frame against a design
execution-conditions
Conditions raised during execution

Panels and Rotation

Longitudinal designs: split an executed master into panels, materialize the wave each panel is scheduled for, and assemble the waves.

rotation_program()
Link the cohorts of a replenishing rotating panel
stack_waves()
Stack materialized waves into a long unit-wave table
as.data.frame(<rotation_wave>)
Row-bind a rotation wave for fieldwork, not for estimation

Indirect Sampling and Overlapping Frames

Estimate for a population other than the one that was sampled, by following links to it or by combining frames that overlap on it. Both transform an executed sample and neither changes the draw.

share_weights()
Share design weights with a linked target population
complete_links()
Assert that a link table is the complete population register
weighted_links()
Weight links by their importance rather than counting them
complete_weighted_links()
Assert that a weighted link table is the complete population register
extend_links()
Eliminate target clusters by extending links across them
stack_frames()
Stack samples selected from overlapping frames
overlap_probabilities()
Declare that overlap values are inclusion probabilities
overlap_weights()
Declare that overlap values are design weights
exante_probabilities()
Selection probabilities a design would give a register, without drawing
exante_overlaps()
Resolve overlap probabilities from the designs, instead of stating them
as.data.frame(<frame_stack>)
Row-bind a frame stack for inspection, not for estimation
summary(<frame_stack>)
Summarize a frame stack
as_svydesign(<frame_stack>)
Export overlapping frames to survey's dual-frame estimator
as_svrepdesign(<frame_stack>)
Export overlapping frames to a combined replicate-weight design

Reference topics

Cross-cutting contracts several functions share. Each is the canonical description; the function pages link here rather than restate it.

selection-methods
Selection methods
sample-columns
Columns generated on an executed sample
frame-input-grammar
The frame input grammar shared by every public frame-valued verb

Survey Export

Convert samples to survey/srvyr objects for analysis.

as_svydesign()
Convert a tbl_sample to a survey design object
as_svrepdesign()
Convert a tbl_sample to a replicate-weight survey design
as_survey_design(<tbl_sample>)
Convert a tbl_sample to a srvyr tbl_svy object
as_survey_rep(<tbl_sample>)
Convert a tbl_sample to a srvyr replicate-weight tbl_svy object

Diagnostics

Summarize and inspect sampling results.

summary(<tbl_sample>)
Summarize a tbl_sample
frame_summary()
Summarize the population structure recorded with a sample
joint_expectation()
Compute pairwise joint expectations from a sample
design_effect() effective_n()
Design effect and effective sample size
varcomp()
Variance components from an executed sample

Serialization

Save, share, and restore designs as JSON files.

write_design() read_design()
Write a sampling design to a file
design_json()
Convert a sampling design to JSON
replay_design()
Replay an execution receipt
as.list(<sampling_design>)
Convert a sampling design to a list

Helpers

Sorting and class checks.

serp()
Serpentine sorting for implicit stratification
bound()
Controlled count bounds for balanced sampling
is_sampling_design()
Test if object is a sampling_design
is_tbl_sample()
Test if object is a tbl_sample
as_tbl_sample()
Coerce to a tbl_sample
get_design()
Get the design specification stored on a sample
get_stages_executed()
Get the executed stage numbers stored on a sample
print(<sampling_design>) tbl_sum(<tbl_sample>) print(<rotation_program>) print(<rotation_wave>) print(<frame_stack>) print(<shared_sample_design>) print(<frame_stack_design>) print(<samplyr_overlap_spec>) print(<samplyr_exante_overlap_spec>)
Print methods for samplyr objects
`[`(<tbl_sample>)
Subset a tbl_sample preserving class

Extension API

For packages built on the frame digest. The digest list structure is internal and versioned, so pin a minimum samplyr version.

digest
Frame digest internals
get_frame_digest()
Read the frame digest of an executed sample
exante_digest()
Resolve a design's full ex-ante digest from a frame, without drawing

Datasets

Survey frames derived from public data, for learning and testing.

samplyr-datasets
Sampling frames
bfa_eas
Burkina Faso enumeration areas
bfa_eas_variance
Stratum variances for Burkina Faso EAs
bfa_eas_cost
Stratum costs for Burkina Faso EAs
zwe_eas
Zimbabwe enumeration areas for demographic, health, and child-indicator surveys
ken_enterprises
Synthetic Kenya establishment frame