How execute() partitions a sample into panels with panels, where
panel_stage puts the assignment, what a rotation schedule declares, and
how execute(master, period = p) weights the occasion it materializes.
Details
Subrounds and rotation groups
panels takes three forms.
panels = | Declares | Occasions | A certainty unit is in |
12 | rotation groups | declared later | every occasion |
| a schedule | rotation groups | as scheduled | every occasion |
subrounds(12) | subrounds | one per subround | one subround |
Rotation groups are for a sample interviewed again, where a unit selected
with certainty stays in every occasion. subrounds() is for a sample spread
over the subrounds of one period and visited once, such as the months of
a yearly survey, where a certainty unit belongs to one subround like any
other. A count that keeps certainty units apart says so with
samplyr_message_panel_certainty.
How units are assigned
Assignment is randomized with fixed quotas. Within each selection stratum
of the assignment stage the assignment units are ordered, cut into
consecutive blocks of 2 * panels, given a fixed quota per panel inside
each block, and permuted within their block. Every unit therefore carries
each panel with probability 1 / panels, and panel sizes within a pool
differ by at most one. It is a partition of the selected sample, not an
additional probability-sampling phase. It changes no inclusion probability
and no .weight, so the combined sample is analyzed with the stored
weights. A unit whose later stages found nothing to sample, kept by
on_empty, is assigned too. It has no row in the sample, but it holds
a panel as it does when the later stages are drawn after the
assignment, and its pool is split over every unit drawn.
Blocking is what preserves order. Units adjacent in the control order of
the assignment stage's draw() fall in the same block, so every panel
inherits the same spread over that order. A pool holding fewer than
2 * panels units is a single block, still assigned, with no block-level
order left to preserve.
Panels are assigned once. .panel is carried forward by a stage
continuation, and redeclaring panels on a sample that already carries an
assignment is an error.
Assignment below the first stage
Panels are assigned at stage 1 by default, and every unit below inherits
its ancestor's panel, so whole primary units rotate. panel_stage moves
the assignment to a lower stage, which retains the primary units and
rotates the units inside them: the address-panel design, in which selected
areas stay in the survey and households rotate within them. A pool is then
the assignment stage's strata inside each realized parent and never
crosses a parent, so pools are smaller and small_pool matters more.
Under a with-replacement assignment stage the assignment unit is the realized draw, the unit the estimator uses, so one population unit selected twice may take two different panels. A parent selected twice likewise gives two separate populations of households, and a household reached under both hits is assigned once for each.
Assigning below the first stage is not a default and should not be treated as one. Holding the parent fixed while its members rotate can bias cross-sectional estimates over time, and a unit that cannot move between parents is balanced for net change but not for gross change.
Certainty units
Under a count or a schedule, certainty units are labeled from their own
pools and consume no rotating quota. Under subrounds() they are
assigned with the other units of their stratum, so each belongs to one
subround and the subrounds stay even. Under a count or a schedule, a
certainty unit is in the sample at every occasion, since a schedule that
rotated it out would drop the very units the certainty stratum exists to
enumerate. Certainty counts only at the assignment
stage, in both directions: a certainty primary unit does not make the
units below it permanent when panel_stage names a lower stage, and a
certainty selection below the assignment stage does not keep its
assignment unit in every occasion. A unit selected with probability one inside
a rotating parent is absent from the occasions that parent sits out.
Rotation schedules and occasions
Passing a schedule to panels instead of a count declares which panels are
active at which occasion, and lets execute(master, period = p) materialize
one of them. A schedule is a data frame with an integer panel column, an
integer period column, an optional integer subround column and an
optional logical active column, and a combination left out is inactive.
Each (period, subround) pair is one occasion, subround is 1 where the
column is absent, and occasions follow the order of their pairs:
schedule <- data.frame(
panel = rep(1:4, times = 3),
period = rep(1:3, each = 4),
active = c(TRUE, TRUE, FALSE, FALSE,
FALSE, TRUE, TRUE, FALSE,
FALSE, FALSE, TRUE, TRUE)
)
master <- execute(design, frame, seed = 1, panels = schedule)
period_2 <- execute(master, period = 2)Periods number from 1 without gaps, and so do the subrounds of each
period, whose number may differ from one period to the next. A panel
appears once per occasion. Other columns are accepted and ignored, so an
svyplan schedule table can be passed as it stands, and its wave, the
place of an interview in the rotation pattern, is not read as time. A
table with a wave column and no period is refused for that reason.
The schedule is read at the master draw, because the block size follows
from it. A schedule whose leanest occasion activates r of the k panels
blocks at k * ceiling(2 / r) rather than at the worst case 2k, which
keeps more of the assignment order while still leaving two units per block
in the take.
Materializing occasion t is a probability subsample rather than a filter: a
two-phase sample whose second phase is the activation, with the blocks as
phase-2 strata and their frozen quotas as phase-2 population counts. It
multiplies .weight by the inverse of the activation probability. That
probability is the block's frozen quota for the active panels over the
block size, so it is exact rather than nominal, and it is generally not
k / r. Permanent certainty units are activated at every occasion with
probability one and their weights are untouched.
A materialized occasion is a sample in its own right, with its own integrity
record, so frame_summary() and the weight diagnostics work on it. It
retains the master as its first phase. as_svydesign() exports it by
ultimate clusters, or through survey::twophase() with the activation as
the second phase when method is given. Its
receipt records the master's execution, so replay_design() rebuilds the
master and materializes the occasion again.
The schedule states which groups are live when. It does not replenish the
sample: every panel comes from the frame vintage the master was drawn from,
and the panels of later periods are a fresh execute() against a later
frame. For an svyplan_schedule, execute() takes the startup activity
and checks its panel parameters before assignment. A gradual launch has
one whole startup selection and needs no partition.
Windows of several occasions
execute(master, period = 1) on a schedule with subrounds, and
execute(master, period = 1:4) on any schedule, pool several occasions
into one sample, such as a quarter written as three monthly subrounds, a
moving window, or a year of quarters. Each row carries the occasion it
was observed at in .period and .subround, and totals estimate the
average over the window of each occasion's total.
Each occasion enters as its own sample. A row's weight is the unit's
weight at that occasion, as execute(master, period = p, subround = s)
gives it, divided by the number of occasions in the window. Each
occasion then counts equally however many panels it holds, and the
window's total is the average of its occasions' totals. A unit has a row
at every occasion of the window at which it is active, so a unit kept for
two quarters of a year has two, and a permanent unit has one at each
occasion. Pooling the rows with one weight per unit would count each
occasion by its number of rows instead, which gives the average only
when every occasion holds the same number of panels.
The master leaves every pool a unit in each reporting period, not at each
occasion, so a small pool can miss an occasion of a period. Its occasions
in that period are then read together. Its units take their chance of
being in any of the period's active panels, times the period's share of
the window's occasions, which collapses the pool's occasions into one
weighting cell. The cell estimates the period's average when the pool
misses each occasion of the period with the same chance. That needs a
period whose occasions hold the same number of panels, none of them
twice. Labels cover rotation groups before subrounds, so it also needs
each rotation group to hold its panels alike at every subround of the
period, counting a panel at its first subround and at its subround in the
period. A schedule whose panels keep one subround and whose groups hold
as many panels at each subround meets this.
Otherwise the window is refused (samplyr_error_panel_small_pool).
A window is exported by ultimate clusters, with a unit's rows in one
cluster (as_svydesign()). It needs a master whose stages are all
drawn. It has no receipt of its own, so write_design() refuses it and
the master's receipt gives it again, and stack_periods() takes whole
periods in which each unit has one row, and single occasions.
The activation is a second phase whose strata are the quota blocks, and within a block the quotas fix how many units share each set of occasions. The export therefore crosses the strata with the block and the occasions of the window a unit is active at. A cell holding one unit is joined with the cell of the same occasions in the next block of its pool, as in the collapsed-strata estimator. A unit still alone in its cell falls back to the units of its stratum active at as many occasions. Where a primary unit spans several blocks, as a retained one does, its cell is its set of occasions.
Merged blocks and fall-back cells mix units whose activation multipliers
differ, and an ordinary variance reads the difference as sampling spread.
The export therefore calibrates on each stratum's total of the units'
multipliers. The weights do not move, and the variance becomes the
ratio-adjusted collapsed-strata estimator (Hansen, Hurwitz and Madow,
1953; Wolter, 2007, section 2.5). An empty primary unit, a zero row,
enters with a zero total and the multiplier of its cell. Units still
alone in their cell after the fall-back share one stratum. A single such
unit joins the cell of its stratum whose units are active at the nearest
number of occasions, so the window itself makes no stratum of one unit. A stratum the design leaves with one unit is treated by
survey.lonely.psu, as for any sample, and the export names it when it
warns (samplyr_warning_lonely_psu). as_svrepdesign() calibrates its
replicates the same way.
A collapsed stratum overstates the variance by the spread between the totals of the cells it joins, so the window's variance is close where each stratum holds at least as many units as panels and few cells are merged, and overstates where strata hold fewer units than panels. It also keeps the master's ultimate-cluster reading, which overstates where the first stage takes a large share of its units.
Reporting periods
A schedule whose fieldwork splits a reporting period, such as months
inside a quarter, names the split in subround, subround = 1:3 for the
months of each quarter. An svyplan_schedule built with subrounds
carries it. A schedule whose every period has one subround assigns as one
without subrounds.
Panels with the same visits in every period form a rotation group, and their subround tells them apart. The assignment then checks pools per period rather than per occasion. A pool needs more units than the groups the leanest period leaves inactive. Fifteen monthly panels kept in every quarter form one group, so a stratum needs one unit rather than the eleven a check per occasion asks. Labels cover the groups first and the subrounds second, so the first units of a pool go to distinct groups and spread over the months.
A period is materialized whole, execute(master, period = p), as a window
of its occasions. A single occasion,
execute(master, period = p, subround = s), may then hold none of the
units of a small pool, and is refused (samplyr_error_panel_small_pool), since that occasion gives
such a stratum no estimate. A window of whole periods, such as a year of
monthly occasions, needs a unit of each pool in each period only. A window
that starts or ends inside a period, such as months 2 to 4 of a quarterly
design, needs one in the occasions it covers in each period. The guarantee
is per period, so a small stratum can make such a window refused while
every period materializes.
Cohorts in retained primary units
In most rotating household surveys the rotation group is a set of primary
units, and a unit's households are drawn when its group enters, from a
listing updated then, and kept for a run of visits. These households are
a cohort. When its visits end, the primary unit either leaves or takes a
new cohort of households from a new listing. A schedule states this with
an optional visit column, the interview number of the row's cohort, NA
where a panel is inactive. A new cohort opens where visit is 1. Without
the column each panel takes one cohort, at its first active occasion. A
cohort column, which an svyplan schedule carries, is optional and only
restates the visits. Within a panel it must change exactly where visit
is 1, and one that does not is refused (samplyr_error_schedule_visit).
A materialized occasion carries
.visit, the interview number within the unit's cohort, which is what
conditioning and attrition follow. Agencies measure rotation group bias
by the month in sample, svyplan's wave, instead. The two agree once
every cohort opened at its first interview, and differ for the start-up
panels of an immediate start, which enter later in their life.
The stages below the panels are then drawn where cohorts open, with
execute(master, listing, period = p, subround = s) (see execute()), from the full
listing of the primary units. A new cohort in a primary unit leaves out
the units its earlier cohorts drew, as rotating surveys do, and draws from
the rest. Each of the M units of the listing then has the chance n / M of a single draw, so the stage's weight and population count are
those of the whole listing, and every cohort estimates the whole
population. That holds exactly for simple random sampling on a listing
that only loses the units drawn before, and for the first-order chances
of systematic sampling. Units built since the earlier cohorts are
weighted the same way, which approximates their larger chance. A rate
frac and an allocation across strata are sized on the whole listing
too, so each cohort takes the same share of a pool as n does, rather
than a share of the units left. A take above the units left takes all of
them, and the draw says so (samplyr_warning_census).
A schedule with several cohorts per panel therefore needs the stage
below the panels to name its units with cluster_by() and draw them by
"srswor" or "systematic", and refuses drawing that stage up front,
since every cohort would then hold the same units
(samplyr_error_cohort_stages). A listing already cut of the units
drawn before is refused (samplyr_error_cohort_listing), since its
weights could not count them back. A listing that holds only units
earlier cohorts drew in some pool, a primary unit or a stratum within
one, is refused too (samplyr_error_cohort_exhausted), since the draw
would leave that pool out of every total. Permanent units are active
at every occasion outside the rotation, keep the units drawn under them at
the first occasion drawn, and have no visit.
A listing that lacks only some of the units drawn before is drawn, and
the missing units are read as gone from the population. The draw warns
(samplyr_warning_cohort_listing) for the units of each primary unit's
latest cohort, the last one executed, so each departure is reported
once. A unit of an older cohort that goes missing later does not warn.
It may have left the population or been cut from the listing, and
samplyr cannot tell which. A workflow that must stop on the warning can
turn it into an error with a calling handler, which keeps the warning
as the error's parent.
withCallingHandlers(
execute(master, listing, period = 5, seed = 5),
samplyr_warning_cohort_listing = function(w) {
rlang::abort(conditionMessage(w), parent = w)
}
)An occasion reads each active panel's current cohort, and is exported by
ultimate clusters from its own rows (as_svydesign()) as soon as those
cohorts are drawn. Its periods stack with stack_periods() for change
between them. The master is never complete when a panel takes
several cohorts, as rotating surveys never complete. Its frame digest
records every cohort drawn so far, keyed by the occasion
each opened at, so frame_summary() reports the stages below the panels
by cohort and replay_design() checks every cohort's draw.
The digest of a later cohort records the draw as it was made. A pool's
N counts the units left after the exclusion, and its chances are
those of a draw from them. Its n_excluded counts the units left out,
so N + n_excluded is the listing that the weights and .fpc_k
count, and chance * N / (N + n_excluded) is the chance a weight
inverts. summary() shows both, as in N_h 8 of 10 listed.
Pools too small for a schedule
Subrounds activate one subround per occasion, so a stratum with fewer
units than subrounds would leave a subround without any of its units. It
is refused, and small_pool = "permanent" is refused with subrounds(),
since a unit active in every subround is not visited once.
A pool of m units leaves panels - m panels empty, so an occasion activating
r of them selects nothing from that pool when m <= panels - r. Those
units would have inclusion probability zero in that occasion rather than a
small weight, which biases the occasion's estimator. small_pool = "error",
the default, refuses such an assignment before any panel is drawn and names
the pools. "permanent" activates them at every occasion with probability one
and warns with samplyr_warning_panel_small_pool, which is exact but
changes the operational design: occasion sizes, overlap and repeated
interviewing all increase. With reporting periods the rule counts groups
per period instead, as described above. It matters only with a schedule,
since a panel
count declares no occasion to protect, and it governs positivity only. A pool
with a single active unit is still assigned, and is marked as carrying no
within-block variance estimate. An svyplan_schedule refuses
"permanent", and selection-certainty units
(samplyr_error_plan_certainty), because its overlap describes a fully
rotating life.
Under horizon_policy = "continuing", an svyplan_schedule lists the
interviews owed after its horizon, and the master's schedule includes
them. The check counts those occasions too, since every occasion of the master
must stand on its own, so the last of them, with few groups active, set
how many units a pool needs. "truncate_lives" ends the lives at the
horizon and drops those occasions from the check.
Weights of a subset of panels
Weights are not adjusted for panel membership. They reflect the full-sample
inclusion probability and are valid for the combined sample. A subset of
the panels is a simple random subsample without replacement within each
block, but its conditional probability is the block's realized quota over
the block size, not 1 / panels, so multiplying one panel's weights by
panels is not generally valid for population inference. The block sizes
and realized quotas are recorded with the sample and written to the design
file by write_design(), because they are what such a subset has to be
computed against. joint_expectation() with period reads how two
occasions overlap from the same record.
References
Hansen, M. H., Hurwitz, W. N., and Madow, W. G. (1953). Sample Survey Methods and Theory, vol. 1, section 9.15. Wiley.
Wolter, K. M. (2007). Introduction to Variance Estimation, 2nd ed., section 2.5. Springer.
See also
execute(), rotation_program() for programs of several
selections, stack_periods() for stacking materialized periods.
Other panels, rotation and periods:
rotation_program(),
stack_periods(),
subrounds()
