'For computing marginal effects returns dF(XB) / dX where F(.) is
the predicted probabilities
transform can be \'dydx\', \'dyex\', \'eydx\', or \'eyex\'.
Not all of these make sense in the presence of discrete regressors,
but checks are done in the results in get_margeff.'

def _derivative_exog(self, params, exog=None, transform='dydx', dummy_idx=None, count_idx=None):

    if (exog is None):
        exog = self.exog
    margeff = np.dot(self.pdf(np.dot(exog, params))[:, None], params[None, :])
    if ('ex' in transform):
        margeff *= exog
    if ('ey' in transform):
        margeff /= self.predict(params, exog)[:, None]
    if (count_idx is not None):
        from statsmodels.discrete.discrete_margins import _get_count_effects
        margeff = _get_count_effects(margeff, exog, count_idx, transform, self, params)
    if (dummy_idx is not None):
        from statsmodels.discrete.discrete_margins import _get_dummy_effects
        margeff = _get_dummy_effects(margeff, exog, dummy_idx, transform, self, params)
    return margeff
