
A Fixed Observational (Non-Randomized) Design
Source:R/design_observational.R
ObservationalDesign.RdA fixed-sample-size DesignFixed whose treatment
assignment vector \(w\) is supplied by the user (e.g. via
assign_w_to_all_subjects(w_precomputed = ...) or
overwrite_all_subject_assignments()) rather than drawn from any
randomization mechanism. Unlike every other DesignFixed subclass, there is no
prob_T to specify – treatment was not assigned by the experimenter according
to a known probability law, so no such probability exists to declare.
No draw mechanism. draw_ws_according_to_design() (and, transitively,
the fallback branch of assign_w_to_all_subjects() that would otherwise call
it) always throws. Any inference procedure that must redraw \(w\) from the design's
own randomization law – randomization tests, randomization confidence intervals, and
randomization/assignment bootstrap – therefore throws the same clear error rather
than silently fabricating a randomization mechanism that never existed. Procedures
that resample subjects instead of redrawing \(w\) (plain nonparametric
bootstrap, Bayesian bootstrap) are unaffected and remain available, since resampling
subjects with their observed, fixed assignment does not require a known randomization
probability.
No balance target. assert_even_allocation() is a no-op here (rather
than the inherited check against prob_T = 0.5): there is no targeted
allocation ratio for an observational design to be out of balance with.
Super classes
Design -> DesignFixed -> ObservationalDesign
Methods
+ inherited public methods from DesignFixed
+ inherited public methods from Design
Design$add_one_subject_response()Design$any_censoring()Design$applicable_inference_class_names()Design$assert_all_responses_recorded()Design$assert_all_subjects_arrived()Design$assert_fixed_sample()Design$capabilities()Design$check_experiment_completed()Design$draw_ws_according_to_design()Design$duplicate()Design$get_X()Design$get_X_imp()Design$get_X_raw()Design$get_design_formula()Design$get_edi_version_created()Design$get_effective_dead()Design$get_effective_time()Design$get_missingness_method()Design$get_n()Design$get_ordinal_levels()Design$get_original_ordinal_levels()Design$get_prob_T()Design$get_response_type()Design$get_response_type_original()Design$get_t()Design$get_w()Design$get_y()Design$get_y_L()Design$get_y_R()Design$get_y_original()Design$has_general_censoring()Design$incompatible_inference_classes_due_to_design_structure()Design$is_a_bernoulli_capable()Design$is_a_cluster_capable()Design$is_a_kk_matching_capable()Design$is_blocking_design()Design$is_fixed_sample_size()Design$is_matching_design()Design$prepare_for_resampling_replay()Design$randomization_family()Design$supports()Design$supports_resampling()Design$transform_y()Design$unavailable_inference_classes_due_to_missing_packages()Design$warm_all_subject_data_cache()
ObservationalDesign$new()
Initialize a fixed observational (non-randomized) design. No
treatment vector is drawn or requested here; the constructor only records
configuration (covariates, response type, etc.) and internally fixes
prob_T = 0.5 purely so the shared Design/DesignFixed
machinery has a value to store — it is never used to draw or validate an
allocation for this class (see assert_even_allocation() and class
documentation). \(w\) itself is supplied afterward via
assign_w_to_all_subjects(w_precomputed = ...) or
overwrite_all_subject_assignments().
Usage
ObservationalDesign$new(
response_type,
include_is_missing_as_a_new_feature = TRUE,
n = NULL,
verbose = FALSE,
missingness_method = "impute",
design_formula = ~.,
seed = NULL
)Arguments
response_type"continuous", "incidence", "proportion", "count", "survival", or "ordinal".
include_is_missing_as_a_new_featureFlag for missingness indicators.
nThe sample size.
verboseA flag for verbosity.
missingness_methodHow to handle missing values in covariates.
design_formulaA formula object.
seedInteger seed for reproducibility. Note this design has no randomization mechanism to seed (see class documentation);
seedonly affects RNG-dependent behavior inherited fromDesignunrelated to treatment assignment (e.g. imputation, bootstrap resampling).
ObservationalDesign$assert_even_allocation()
Observational designs have no targeted allocation ratio to
check balance against, so this is a no-op rather than an error (contrast
with the inherited Design$assert_even_allocation(), which errors if
the realized allocation deviates from prob_T = 0.5).
ObservationalDesign$supports_randomization_draw()
Characterization: FALSE – this design has no
randomization mechanism to redraw \(w\) from (see class documentation).
Metadata-declared replacement for the old draw_ws_raw() throwing
stub (still present below as a fallback for any caller that reaches it
without checking this first – see fix_design_hierarchy.md,
"Observational Design Migration").
ObservationalDesign$supports_resampling_replay()
Characterization: FALSE – this design has no
randomization mechanism to replay against resampled data (bootstrap
randomization test eligibility). Plain nonparametric/Bayesian/m-out-of-n/
PRW-subsampling bootstrap are unaffected (see
Design$supports_resampling()'s documentation) and remain available.
Examples
des = ObservationalDesign$new(n = 10, response_type = 'continuous')
des$add_all_subjects_to_experiment(data.frame(x1 = rnorm(10)))
des$assign_w_to_all_subjects(w_precomputed = rbinom(10, 1, 0.3))