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: predict in ZeroInflated fails if exog_infl not specified #4757
If there are no explanatory variables, exog_infl, specified for the inflation model, then a array of ones is used to model a constant inflation probability. However, if exog_infl in predict is None, then it uses the model.exog_infl which is an array of ones with the length equal to the training sample.
As work around specifying a 1-D array of ones of correct length in predict should work.
discrete_model.CountModel uses a copied version of GLM.predict (minus link check)
GenericZeroInflated.predict uses it's own predict method, but does not follow the same pattern of checks.
Note
exog is None means we have default predict with self.exog. exog is required if not default
In ZI, we have to additionally treat exog_infl, and similarly in Beta regression.
another messy part for ZI:
we have submodel `model_main that also has offset or exposure attached.
Offset should be fine, but we have to watch out that exposure is not transformed twice. (still side effect that exposure is internally log-ed.)
Activity
josef-pkt commentedon Jul 14, 2021
same problem shows up in Beta regression and will apply to all multi-part models #7543 (comment)
josef-pkt commentedon Jul 14, 2021
#4952 mentions that exog_infl has to be 2-d
beta regression also defaults to 2-d constant
exog_precision = np.ones((len(endog), 1), dtype='f')We might want to automatically add the 2-d axis if user specifies a 1-d exog_xxx
josef-pkt commentedon Aug 24, 2021
while trying to fix this, I get test failures with offset exposure. (not directly related to exog_infl)
Looks like there is something wrong, but I don't yet see why test fails
https://github.com/statsmodels/statsmodels/blob/main/statsmodels/discrete/tests/test_count_model.py#L147
compares self.res1 predict (using offset) with itself, instead of res3 which is supposed to be the equivalent exposure version.
but self.res1 predict() is not the same as res3.predict()
josef-pkt commentedon Aug 24, 2021
offset and exposure are not treated the same by default in predict if they are None.
https://github.com/statsmodels/statsmodels/blob/main/statsmodels/discrete/count_model.py#L396
if None: offset = 0, exposure = self.exposure
discrete_model.CountModel uses a copied version of GLM.predict (minus link check)
GenericZeroInflated.predict uses it's own predict method, but does not follow the same pattern of checks.
Note
exog is None means we have default predict with self.exog. exog is required if not default
In ZI, we have to additionally treat exog_infl, and similarly in Beta regression.
another messy part for ZI:
we have submodel `model_main that also has offset or exposure attached.
Offset should be fine, but we have to watch out that exposure is not transformed twice. (still side effect that exposure is internally log-ed.)