Skip to contents

Validates that a fitter object correctly implements the bayesim Fitter interface. This function checks that the object is a valid S7 Fitter class instance with all required properties and methods implemented.

Usage

validate_fitter(
  fitter,
  smoke_test = FALSE,
  verbose = FALSE,
  data_bundle = NULL,
  fit_spec = NULL,
  task_ctx = NULL
)

Arguments

fitter

An S7 Fitter object to validate

smoke_test

Logical, if TRUE run a quick fit test with sample data to verify that methods work correctly end-to-end

verbose

Logical, if TRUE print progress messages during validation

data_bundle

Optional representative data bundle for the conformance run. Supplying this is recommended for custom fitters whose data contract is not a y ~ x regression.

fit_spec

Optional representative fit specification passed to fit_model() during conformance testing.

task_ctx

Optional task context passed to fit_model() during conformance testing.

Value

The validated fitter object (invisibly) if valid, otherwise raises an error with details about what failed

Details

The validation performs the following checks:

Property Checks:

  • Object is an S7 Fitter class

  • name property exists and is character

  • supports_predictions property exists and is logical

  • supports_log_lik property exists and is logical

  • supports_loo property exists and is logical

  • supports_epred property exists and is logical

Method Checks:

  • fit_model() and extract_draws() are implemented (the core contract)

  • optional methods are required only when their supports_* capability is TRUE; unsupported methods have safe defaults

  • fit_diagnostics() may use the default empty-list implementation

Smoke Test (when smoke_test = TRUE):

Examples

# Validate a built-in fitter (basic check only)
validate_fitter(LinearRegressionFitter())

# Full validation with an end-to-end smoke test
validate_fitter(LinearRegressionFitter(), smoke_test = TRUE)

if (FALSE) { # \dontrun{
# Use in your own fitter's tests
my_fitter <- MyCustomFitter()
validate_fitter(my_fitter, smoke_test = TRUE, verbose = TRUE)
} # }