Skip to contents

Return the capabilities of a sampling method. Works for built-in methods and methods added via register_method().

Usage

method_spec(name, dispatcher = NULL)

Arguments

name

Method name (character string), as used by the sondage dispatchers (e.g. "brewer", "cube", "srs").

dispatcher

Optional sampling entry point. One of "equal_prob_wor", "equal_prob_wr", "unequal_prob_wor", "unequal_prob_wr", or "balanced_wor". Required when name is available through more than one entry point, as with "srs" and "systematic". Values must match exactly.

Value

A list with elements dispatcher (the sampling entry point), type ("wor", "wr", or "balanced"), fixed_size (logical), variance_family (one of "srs", "pps_brewer", "poisson", "wr", "unsupported", or NULL for a registered method that did not declare one; see register_method()), supports_prn (logical), supports_aux (logical), supports_strata (logical), supports_spread (logical), and probabilities (where the method sits in the first-order probability taxonomy: "exact" for every built-in except "sps" and "pareto", which honor pik to a documented approximation and report "approximate"; for a registered method the declared tier, "unknown" when the author did not establish one), plus sample_fn and joint_fn (the registered implementation functions for a registered method, NULL for built-ins, whose implementations are internal dispatch paths). Returns NULL if the method is unknown. The aux/strata/spread capabilities are only TRUE for balanced methods. An ambiguous built-in name without dispatcher is an error rather than silently selecting one variant.

Examples

method_spec("brewer")
#> $dispatcher
#> [1] "unequal_prob_wor"
#> 
#> $type
#> [1] "wor"
#> 
#> $fixed_size
#> [1] TRUE
#> 
#> $variance_family
#> [1] "pps_brewer"
#> 
#> $supports_prn
#> [1] FALSE
#> 
#> $supports_aux
#> [1] FALSE
#> 
#> $supports_strata
#> [1] FALSE
#> 
#> $supports_spread
#> [1] FALSE
#> 
#> $probabilities
#> [1] "exact"
#> 
#> $sample_fn
#> NULL
#> 
#> $joint_fn
#> NULL
#> 
method_spec("cube")
#> $dispatcher
#> [1] "balanced_wor"
#> 
#> $type
#> [1] "balanced"
#> 
#> $fixed_size
#> [1] TRUE
#> 
#> $variance_family
#> [1] "pps_brewer"
#> 
#> $supports_prn
#> [1] FALSE
#> 
#> $supports_aux
#> [1] TRUE
#> 
#> $supports_strata
#> [1] TRUE
#> 
#> $supports_spread
#> [1] FALSE
#> 
#> $probabilities
#> [1] "exact"
#> 
#> $sample_fn
#> NULL
#> 
#> $joint_fn
#> NULL
#> 
method_spec("srs", dispatcher = "equal_prob_wr")
#> $dispatcher
#> [1] "equal_prob_wr"
#> 
#> $type
#> [1] "wr"
#> 
#> $fixed_size
#> [1] TRUE
#> 
#> $variance_family
#> [1] "wr"
#> 
#> $supports_prn
#> [1] FALSE
#> 
#> $supports_aux
#> [1] FALSE
#> 
#> $supports_strata
#> [1] FALSE
#> 
#> $supports_spread
#> [1] FALSE
#> 
#> $probabilities
#> [1] "exact"
#> 
#> $sample_fn
#> NULL
#> 
#> $joint_fn
#> NULL
#> 
method_spec("systematic", dispatcher = "equal_prob_wor")
#> $dispatcher
#> [1] "equal_prob_wor"
#> 
#> $type
#> [1] "wor"
#> 
#> $fixed_size
#> [1] TRUE
#> 
#> $variance_family
#> [1] "srs"
#> 
#> $supports_prn
#> [1] FALSE
#> 
#> $supports_aux
#> [1] FALSE
#> 
#> $supports_strata
#> [1] FALSE
#> 
#> $supports_spread
#> [1] FALSE
#> 
#> $probabilities
#> [1] "exact"
#> 
#> $sample_fn
#> NULL
#> 
#> $joint_fn
#> NULL
#> 
method_spec("nonexistent")
#> NULL