Skip to content

ENH: add get_margeff to GLM - #8889

Merged
josef-pkt merged 2 commits into
statsmodels:mainfrom
josef-pkt:glm_margeff
Jun 9, 2023
Merged

josef-pkt merged 2 commits into
statsmodels:mainfrom
josef-pkt:glm_margeff

Conversation

@josef-pkt

@josef-pkt josef-pkt commented May 19, 2023 •

Copy link
Copy Markdown
Member

closes #4751
see also #7341 mentions weights which are not supported here in GLM

adding margeff to GLM is largely copy-paste-adjust

unit tests compare GLM with discrete Logit, Probit and Poisson in discrete/tests/test_sandwich_cov
those comparisons do not include Negbin NB2

(could possibly be backported even though it's an enhancement)

@josef-pkt

josef-pkt commented May 19, 2023 •

Copy link
Copy Markdown
Member Author

undecided:
what do we do about weights in GLM for margeff?
currently warns and ignores weights, i.e. implicitly weights=1, similarly for exposure

What should be the default in future?

We could add explicit var_weights=1, freq_weights=1, exposure=1.
Then, setting them to None by user could be used for default as in predict, i.e. use model.xxx attribute if exog=None.
The default would still be different from predict unless we change the default in a backwards incompatible way.

freq_weights will be needed to get average partial/marginal effect ("overall") for the freq weighted sample. (similar to weights in new get_prediction with average=True)
var_weights: I have no idea, They do not look relevant for prediction and partial effects. i.e. only needed for estimation.
exposure depends on desired mean, either exposure weighted average or average for standard exposure.

offset is different, it needs to be supported, currently raises if it has been used in estimation.
offset could be neglected if it is a standin for log(exposure)
i.e. we will not treat offset and log(exposure) symmetrically for margins

@josef-pkt

Copy link
Copy Markdown
Member Author

unrelated test failure

@josef-pkt
josef-pkt merged commit aa78e9c into statsmodels:main Jun 9, 2023
@bashtage bashtage modified the milestones: 0.15, 0.14 Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: add GLM Margins and supporting helper functions

3 participants