def _margeff_cov_params_count(model, cov_margins, params, exog, count_ind, method, J):
 for i in count_ind:
  exog0 = exog.copy()
  exog0[:, i] -= 1
  dfdb0 = model._derivative_predict(params, exog0, method)
  exog0[:, i] += 2
  dfdb1 = model._derivative_predict(params, exog0, method)
  dfdb = (dfdb1 - dfdb0)
  if (dfdb.ndim >= 2):
   dfdb = (dfdb.mean(0) / 2)
  if (J > 1):
   K = (dfdb.shape[1] / (J - 1))
   cov_margins[i::K, :] = dfdb
  else:
   cov_margins[i, :] = dfdb
 return cov_margins

def _margeff_cov_params_count ( model , cov_margins , params , exog , count_ind , method , J ) : for i in count_ind : exog0 = exog . copy ( ) exog0 [ : , i ] -= 1 dfdb0 = model . _derivative_predict ( params , exog0 , method ) exog0 [ : , i ] += 2 dfdb1 = model . _derivative_predict ( params , exog0 , method ) dfdb = ( dfdb1 - dfdb0 ) if ( dfdb . ndim >= 2 ) : dfdb = ( dfdb . mean ( 0 ) / 2 ) if ( J > 1 ) : K = ( dfdb . shape [ 1 ] / ( J - 1 ) ) cov_margins [ i : : K , : ] = dfdb else : cov_margins [ i , : ] = dfdb return cov_margins
returns the jacobian for discrete regressors for use in margeff_cov_params .