def score_obs(self, params):
    '\n        Generic Zero Inflated model score (gradient) vector of the log-likelihood\n\n        Parameters\n        ----------\n        params : array_like\n            The parameters of the model\n\n        Returns\n        -------\n        score : ndarray, 1-D\n            The score vector of the model, i.e. the first derivative of the\n            loglikelihood function, evaluated at `params`\n        '
    params_infl = params[:self.k_inflate]
    params_main = params[self.k_inflate:]
    y = self.endog
    w = self.model_infl.predict(params_infl)
    w = np.clip(w, np.finfo(float).eps, (1 - np.finfo(float).eps))
    score_main = self.model_main.score_obs(params_main)
    llf_main = self.model_main.loglikeobs(params_main)
    llf = self.loglikeobs(params)
    zero_idx = np.nonzero((y == 0))[0]
    nonzero_idx = np.nonzero(y)[0]
    mu = self.model_main.predict(params_main)
    dldp = np.zeros((self.exog.shape[0], self.k_exog), dtype=np.float64)
    dldw = np.zeros_like(self.exog_infl, dtype=np.float64)
    dldp[zero_idx, :] = (score_main[zero_idx].T * (1 - (w[zero_idx] / np.exp(llf[zero_idx])))).T
    dldp[nonzero_idx, :] = score_main[nonzero_idx]
    if (self.inflation == 'logit'):
        dldw[zero_idx, :] = ((((self.exog_infl[zero_idx].T * w[zero_idx]) * (1 - w[zero_idx])) * (1 - np.exp(llf_main[zero_idx]))) / np.exp(llf[zero_idx])).T
        dldw[nonzero_idx, :] = (- (self.exog_infl[nonzero_idx].T * w[nonzero_idx]).T)
    elif (self.inflation == 'probit'):
        return approx_fprime(params, self.loglikeobs)
    return np.hstack((dldw, dldp))
Generic Zero Inflated model score (gradient) vector of the log-likelihood

Parameters
----------
params : array_like
    The parameters of the model

Returns
-------
score : ndarray, 1-D
    The score vector of the model, i.e. the first derivative of the
    loglikelihood function, evaluated at `params`
def score_obs(self, params):
    '\n        Generic Zero Inflated model score (gradient) vector of the log-likelihood\n\n        Parameters\n        ----------\n        params : array_like\n            The parameters of the model\n\n        Returns\n        -------\n        score : ndarray, 1-D\n            The score vector of the model, i.e. the first derivative of the\n            loglikelihood function, evaluated at `params`\n        '
    params_infl = params[:self.k_inflate]
    params_main = params[self.k_inflate:]
    y = self.endog
    w = self.model_infl.predict(params_infl)
    w = np.clip(w, np.finfo(float).eps, (1 - np.finfo(float).eps))
    score_main = self.model_main.score_obs(params_main)
    llf_main = self.model_main.loglikeobs(params_main)
    llf = self.loglikeobs(params)
    zero_idx = np.nonzero((y == 0))[0]
    nonzero_idx = np.nonzero(y)[0]
    mu = self.model_main.predict(params_main)
    dldp = np.zeros((self.exog.shape[0], self.k_exog), dtype=np.float64)
    dldw = np.zeros_like(self.exog_infl, dtype=np.float64)
    dldp[zero_idx, :] = (score_main[zero_idx].T * (1 - (w[zero_idx] / np.exp(llf[zero_idx])))).T
    dldp[nonzero_idx, :] = score_main[nonzero_idx]
    if (self.inflation == 'logit'):
        dldw[zero_idx, :] = ((((self.exog_infl[zero_idx].T * w[zero_idx]) * (1 - w[zero_idx])) * (1 - np.exp(llf_main[zero_idx]))) / np.exp(llf[zero_idx])).T
        dldw[nonzero_idx, :] = (- (self.exog_infl[nonzero_idx].T * w[nonzero_idx]).T)
    elif (self.inflation == 'probit'):
        return approx_fprime(params, self.loglikeobs)
    return np.hstack((dldw, dldp))