From e8173629465e42dc928d7400e75dacf23d30c5ad Mon Sep 17 00:00:00 2001 From: Gilles de Hollander Date: Wed, 10 Jun 2026 14:06:52 +0200 Subject: [PATCH] Allow fixing the static choice lapse (p_lapse) to a scalar Mirror the DDM/RDM RTLapseMixin p_outlier API on the static-choice LapseModel: p_lapse can be a fixed float (lapse on but NOT sampled) in addition to the default None (hierarchical per-subject rate). Lets hard prior-estimation geometries keep a lapse without a second funnel, and -- as for the RT models' contaminant -- lets you assume a small lapse rather than estimate a weakly identified rate. Default None preserves existing behaviour. Co-Authored-By: Claude Opus 4.8 (1M context) --- bauer/core.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bauer/core.py b/bauer/core.py index aedc5fe..3b242f0 100644 --- a/bauer/core.py +++ b/bauer/core.py @@ -1076,10 +1076,22 @@ class LapseModel(BaseModel): lapse_mu_mean = 0.02 lapse_mu_kappa = 8.0 lapse_kappa_sd = 3.0 + # ``p_lapse`` mirrors the DDM/RDM ``p_outlier`` API: + # - None (default): the per-subject lapse rate is estimated hierarchically + # (the original behaviour) under ``lapse_group``. + # - a FLOAT: the choice-lapse rate is FIXED at that value; it is NOT a + # sampled parameter, so it cannot funnel/diverge. Useful for hard + # geometries (e.g. full-prior estimation) where a free hierarchical lapse + # trades one funnel for another, and -- as for the RT models' contaminant + # -- where you'd rather assume a small lapse than try to estimate it. + p_lapse = None def get_free_parameters(self): pars = super().get_free_parameters() + if isinstance(self.p_lapse, (int, float)): + # Fixed choice-lapse rate: not a free parameter. + return pars pars['p_lapse'] = _lapse_param_spec(self.lapse_group, self.lapse_mu_mean, self.lapse_mu_kappa, @@ -1093,7 +1105,10 @@ def _get_choice_predictions(self, model_inputs): def get_model_inputs(self, parameters): model_inputs = super().get_model_inputs(parameters) - model_inputs['p_lapse'] = parameters['p_lapse'] + if isinstance(self.p_lapse, (int, float)): + model_inputs['p_lapse'] = pt.constant(float(self.p_lapse)) + else: + model_inputs['p_lapse'] = parameters['p_lapse'] return model_inputs