Validate and subset row-wise selection-kernel contexts and prepare small argument lists for native selected-normal backends.
selection_context_validate(context, n_samples = NULL, required = character())
selection_context_subset_rows(context, rows)
selection_context_subset_observations(context, idx)
selection_native_static_args(selection_spec)
selection_native_kernel_args(
selection_spec,
S,
alpha = NULL,
phack_kind = NULL,
kernel_mode = NULL
)
selection_row_arg(x, n, name)selection context list.
optional expected number of posterior/sample rows.
character vector of fields that must be present.
row indices or logical row mask.
observation indices.
selection backend specification or context list.
number of rows for row-wise native arguments.
optional p-hacking severity values.
optional p-hacking form indicators.
optional selection-kernel mode indicators.
scalar or row-wise vector.
required row count.
argument name used in errors.
selection_context_validate(),
selection_context_subset_rows() and
selection_context_subset_observations() return the context list with
every field validated (integer codes as integer vectors, scalars expanded to
one value per row) and its native cache reset by the subsetting functions;
the native argument helpers return lists of prepared native arguments.
Context validation checks row-wise posterior fields, observation
fields, and compiled selection-bin metadata together. Custom row-wise
fields may be listed in a character vector named row_fields; row
subsetting rejects undeclared fields that otherwise look row-wise.
The built-in vector_rule field accepts the integer codes 0
(product), 1 (best one-sided p-value), and 2 (best two-sided
p-value), with one value or one value per posterior row.
Native argument helpers accept either an augmented context or a bare
selection_backend_spec() object, using compiled step,
phacking, and data fallbacks where available.
Spec-level kernel_mode is the union of branch kernels (a capability
flag). Row routing uses branch_kernel_mode or an explicit per-row
vector; the per-row kernel_mode (and phack_kind) of a context
take precedence over the branch metadata, and an explicit argument over
both. Branches with kernel mode 0 carry no selection kernel and
never compete for a route, so a specification whose active branches all
share one kernel routes on that kernel. When two or more different
active kernels coexist, their bitwise union names a third kernel rather
than a route, and passing it is an error unless bias_indicator can
map each row to a branch.
The built-in row fields, each of length one or one per posterior row, are
omega (a numeric matrix of non-negative weights with one row per
posterior row and one column per selection bin), alpha (the
p-hacking severity, in [0, 1)), the integer codes phack_kind (0 to 2),
kernel_mode (0 to 3), vector_rule (0 to 2), and
bias_indicator (the index of the branch of each row, from 1 to the
number of branches), and the logical use_normal. The observation
fields share one length: obs_bin (the integer selection bin of each
observation, from 1 to the number of bins), yi (finite effect sizes)
and sei (positive standard errors). A fractional or missing integer
code is an error, never rounded or truncated onto another code.
Native caches are reused only when effective static geometry and complete
row-routing inputs are unchanged. Explicit segments take precedence over
p-value cuts; cuts are validated only when segments must be derived.