
Link the selections of a replenishing rotating panel
Source:R/rotation-program.R
rotation_program.RdA rotating panel that replenishes is drawn as a series of executions: a
start-up master against the first frame vintage, then one refreshment
selection against each later vintage. rotation_program() records which
samples make up the program, when each entered, and which components are
live at each occasion, so that execute() can materialize an occasion
across all of them.
Arguments
- selections
A named list of executed
tbl_sampleobjects, one per selection. Each must be complete, unmodified and a single replicate.- entry_period
Integer vector of entry periods, named to match
selections. Required with a data-framescheduleand omitted with ansvyplan_schedule.- schedule
A data frame declaring which components are active at which occasion, or an
svyplan_schedulefromsvyplan::design_schedule().- through
Last period to register from an
svyplan_schedule, or a period and a subround,c(period = p, subround = s). Required for that route and unused with a data-frame schedule.
Value
A rotation_program, an object whose fields are internal.
execute() with period returns an occasion of it, a list of samples
with one element per active selection.
Details
Selections
selections is a named list of executed samples, one per selection of
units from a frame. A selection may be partitioned, drawn with panels
so that it carries .panel and a frozen assignment, or whole, drawn
without panels. A whole selection has one implicit panel numbered 1
covering all its rows. Activating it is not a subsample, so its weights
are unchanged.
Entry periods
With a data-frame schedule, entry_period names the period at which each
selection's vintage enters the program. It is declared rather than
inferred from first activity because a selection may be drawn early and
held in reserve. An svyplan_schedule already records every entry
period, so it supplies this field and redundant entry_period input is
refused.
Schedule
schedule is a data frame with selection (a name from selections),
integer panel, integer period, an optional integer subround and an
optional logical active, read as a panels schedule is (see
panel_assignment). A combination left out is inactive. For a program
of one selection the selection column may be omitted. Activity need not
be contiguous: a 4-8-4 rotation deliberately leaves and re-enters.
The schedule is completed to the full grid only after the registry is known, because a selection's available panels come from its own receipt rather than from the schedule.
Planning schedules
An svyplan_schedule registers the program as of through. Exactly the
selections of plan$selections entering by then must be
supplied, under the names the plan gives them (startup, period_2,
...). Later selections remain planned but unfielded. The executed
receipts determine realized panel and issue counts, which are checked
against the plan.
The program's occasions are the plan's periods and subrounds, so a plan
with horizon = 8 and subrounds = 3 has 24. through = 2 registers
through the last subround of period 2, and
through = c(period = 2, subround = 1) through its first.
execute(program, period = 2, subround = 1) materializes one occasion.
Each selection is drawn with the number of panels the plan gives it in
plan$selections$panels. With
subrounds = 3, a selection after the start-up has one panel per
subround and is drawn with panels = 3. Drawn whole, it is refused
(samplyr_error_program_plan_panels).
What an occasion returns
execute(program, period = p, subround = s) returns a collection of
samples with separate receipts, one per live selection, each carrying its
own exact activation factor, of class rotation_occasion. It is not
row-bound and its weights are not combined. A program materializes one
occasion at a time.
Overlap between selections is unknown, not assumed absent
A program records when its selections are live. It does not record how they relate. Whether a unit could have been drawn into more than one selection depends on facts no receipt carries: whether it was in the population at each vintage, what chance it would have had in a draw it was not selected into, and whether the draws were independent of one another. Two executions with identical inclusion probabilities can be independent or identical depending on how they were seeded and coordinated, and nothing stored can tell them apart.
So the weights of an occasion are valid within a selection, and combining them across selections is left to the analyst, who may know things the program does not.
The common case where that knowledge is easy is a refreshment selection drawn from an entrant register, a frame holding only units that entered the population since the previous vintage. No unit can appear on both frames, so the selections are disjoint by construction, each unit belongs to exactly one, and the component weights are already the right ones for the combined live set. A refresher drawn from the whole population at a later vintage is the other case: a unit present at both times had two chances of selection, and combining then needs a union probability, which is a multi-frame problem rather than a scheduling one.
See also
execute() for drawing a master and materializing an occasion,
panel_assignment for partitioning one execution into rotation groups.
Other panels, rotation and periods:
panel_assignment,
stack_periods(),
subrounds()
Examples
frame_1 <- data.frame(id = 1:200, value = rnorm(200))
# Two groups, each live for two of the three occasions.
startup_schedule <- data.frame(
panel = rep(1:2, times = 3),
period = rep(1:3, each = 2),
active = c(TRUE, TRUE, TRUE, FALSE, FALSE, TRUE)
)
startup <- sampling_design() |>
draw(n = 40) |>
execute(frame_1, seed = 1, panels = startup_schedule)
# A refreshment selection drawn from the entrants of a later vintage.
entrants <- data.frame(id = 201:260, value = rnorm(60))
period_2 <- sampling_design() |>
draw(n = 12) |>
execute(entrants, seed = 2)
program <- rotation_program(
selections = list(startup = startup, period_2 = period_2),
entry_period = c(startup = 1, period_2 = 2),
schedule = rbind(
transform(startup_schedule, selection = "startup"),
data.frame(
selection = "period_2", panel = 1, period = 1:3,
active = c(FALSE, TRUE, TRUE)
)
)
)
program
#> ── Rotation Program ────────────────────────────────────────────────────────────
#>
#> ℹ 2 selections over 3 periods
#> • startup: 40 rows, 2 panels, enters at period 1, live in periods 1 to 3
#> • period_2: 12 rows, 1 panel, enters at period 2, live in periods 2 and 3
#>
execute(program, period = 2)
#> ── Rotation Occasion: period 2 ─────────────────────────────────────────────────
#>
#> • startup: 20 rows, panel 1
#> • period_2: 12 rows, panel 1
#> ℹ Weights are valid within a selection and are not combined.
#>