def nabla_beta_loglik(self, beta_estimand):
    beta_matrix = np.reshape(beta_estimand, (self.J, self.K), order='F')
    counts = self.context.counts
    covariates = self.context.covariates
    Z = self.current_Z
    fixed_effects = np.sum(np.multiply(Z, np.dot(covariates, beta_matrix)), axis=1)
    nabla_beta_matrix = np.zeros(beta_matrix.shape)
    nabla_beta_matrix += np.dot(covariates.T, (Z * counts[:, np.newaxis]))
    temp = np.exp(fixed_effects)
    nabla_beta_matrix += (- np.dot(covariates.T, (Z * temp[:, np.newaxis])))
    nabla_beta = nabla_beta_matrix.flatten('F')
    nabla_beta += self.beta_prior.nabla_beta_log_pdf(beta_estimand, self.J)
    output = nabla_beta
    return output
def nabla_beta_loglik(self, beta_estimand):
    beta_matrix = np.reshape(beta_estimand, (self.J, self.K), order='F')
    counts = self.context.counts
    covariates = self.context.covariates
    Z = self.current_Z
    fixed_effects = np.sum(np.multiply(Z, np.dot(covariates, beta_matrix)), axis=1)
    nabla_beta_matrix = np.zeros(beta_matrix.shape)
    nabla_beta_matrix += np.dot(covariates.T, (Z * counts[:, np.newaxis]))
    temp = np.exp(fixed_effects)
    nabla_beta_matrix += (- np.dot(covariates.T, (Z * temp[:, np.newaxis])))
    nabla_beta = nabla_beta_matrix.flatten('F')
    nabla_beta += self.beta_prior.nabla_beta_log_pdf(beta_estimand, self.J)
    output = nabla_beta
    return output