def mean_deriv(self, exog, lin_pred):
        """
        Derivative of the expected endog with respect to the parameters.

        Parameters
        ----------
        exog : array-like
           The exogeneous data at which the derivative is computed,
           number of rows must be a multiple of `ncut`.
        lin_pred : array-like
           The values of the linear predictor, length must be multiple
           of `ncut`.

        Returns
        -------
        The derivative of the expected endog with respect to the
        parameters.
        """

        expval = np.exp(lin_pred)

        # Reshape so that each row contains all the indicators
        # corresponding to one multinomial observation.
        expval_m = np.reshape(expval, (len(expval) // self.ncut,
                                       self.ncut))

        # The normalizing constant for the multinomial probabilities.
        denom = 1 + expval_m.sum(1)
        denom = np.kron(denom, np.ones(self.ncut, dtype=np.float64))

        # The multinomial probabilities
        mprob = expval / denom

        # First term of the derivative: denom * expval' / denom^2 =
        # expval' / denom.
        dmat = mprob[:, None] * exog

        # Second term of the derivative: -expval * denom' / denom^2
        ddenom = expval[:, None] * exog
        dmat -= mprob[:, None] * ddenom / denom[:, None]

        return dmat
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/genmod/generalized_estimating_equations.py/NominalGEE.mean_deriv/original