Skip to content

BUG/ENH: GEE Margins do not support dummy and count #3704

Open

Description

@josef-pkt

see #3696 (comment)

dummy=True in GEE Margins raises
AttributeError: 'GEE' object has no attribute '_derivative_predict'

continuing example from 3696:

# check for GMM margins
import statsmodels.api as sm
groups = np.ones(x.shape[0], dtype=np.int32)
mod = sm.GEE(y, x, groups, family=sm.families.Binomial())
res_gee = mod.fit(cov_type='naive')
#mod._derivative_predict = mod._derivative_exog  # try monkey patching with wrong method
me_gee =  res_gee.get_margeff(at='mean', dummy = False)
me_gee_dummy =  res_gee.get_margeff(at='mean', dummy=True)

dummy=False works
dummy=True is missing _derivative_predict

  File "...\statsmodels\genmod\generalized_estimating_equations.py", line 1733, in get_margeff
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    return GEEMargins(self, (at, method, atexog, dummy, count))
  File "...\statsmodels\genmod\generalized_estimating_equations.py", line 2528, in __init__
    self.get_margeff(*args, **kwargs)
  File "...\statsmodels\genmod\generalized_estimating_equations.py", line 2719, in get_margeff
    method, 1)
  File "...\statsmodels\discrete\discrete_margins.py", line 344, in margeff_cov_with_se
    pass
  File "...\statsmodels\discrete\discrete_margins.py", line 324, in margeff_cov_params
    else:
  File "...\statsmodels\discrete\discrete_margins.py", line 214, in _margeff_cov_params_dummy
    dfdb = dfdb.mean(0)
AttributeError: 'GEE' object has no attribute '_derivative_predict'

Activity

  1. added
    topic-post_estim
    on Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-genmodtopic-post_estimtype-bugtype-enh

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions