You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: offset in truncated model raises valueerror #8842
actually the ValueError is good, The truncated models do not support offset, exposure in loglike and score.
parameter estimates are wrong
In standalone usage (without hurdle), users could supply data without truncated observations.
In that case offset and exposure would have the correct size and no error would be raised.
similar:
HurdleCountModel has offset and exposure arguments, but they are not used at all, they are not transmitted to the submodels.
similar for _RCensored, offset is argument but not transmitted to model_main, Poisson, NBP, GPP
API design:
currently exog is the same in both submodels.
When we support offset and exposure, then internal consistency would require that those also apply to both models.
However, then we have an ambiguity with separate exog and offsets when offset_zero = None.
Is the None default, "use the same offset in both submodels", or does it mean "no offset in the zero model".
We could make it conditional on if exog_zero is None. If true, then same exog, offset, exposure applies to same model.
If false, then offset and exposure are treated independently of main model, i.e. offset_zero = None means offset_zero=0.
If I mess up CountModel offset if not None, then the following unit tests fail.
All models (*) that don't show up here, do not have unit tests for offset. (*) subclasses of CountModel that use self.offset from superclass in __init__ (some might still store offset directly)
Activity
josef-pkt commentedon Apr 26, 2023
no "offset" or "exposure" in test_truncated_model.py"
josef-pkt commentedon Apr 26, 2023
actually the ValueError is good, The truncated models do not support offset, exposure in loglike and score.
parameter estimates are wrong
In standalone usage (without hurdle), users could supply data without truncated observations.
In that case offset and exposure would have the correct size and no error would be raised.
josef-pkt commentedon Apr 26, 2023
similar:
HurdleCountModel has offset and exposure arguments, but they are not used at all, they are not transmitted to the submodels.
similar for
_RCensored, offset is argument but not transmitted to model_main, Poisson, NBP, GPPAPI design:
currently exog is the same in both submodels.
When we support offset and exposure, then internal consistency would require that those also apply to both models.
However, then we have an ambiguity with separate exog and offsets when
offset_zero = None.Is the None default, "use the same offset in both submodels", or does it mean "no offset in the zero model".
We could make it conditional on
if exog_zero is None. If true, then same exog, offset, exposure applies to same model.If false, then offset and exposure are treated independently of main model, i.e.
offset_zero = Nonemeansoffset_zero=0.josef-pkt commentedon Apr 26, 2023
related: ZeroInflation agreement is low comparing with offset=ones
(reduces const estimate, but leaves slope parameters unchanged)
other discrete models have much better agreement.
Is this a bug with small effect, a loss in precision, or a too large convergence tolerance?
ZIPoisson with nonzero offset has unit tests against Stata.
and I don't see any problems when reading the code.
update
It's convergence tolerance.
When I make gtol (for default bfgs) more strict, params agree at around 1e-10 or 1e-11
Also if I switch to method="newton" (which is default for basic discrete models) agreement of params is at around 1e-12
josef-pkt commentedon Apr 27, 2023
If I mess up CountModel offset if not None, then the following unit tests fail.
All models
(*)that don't show up here, do not have unit tests for offset.(*)subclasses of CountModel that use self.offset from superclass in__init__(some might still store offset directly)