code: def test_predict(self):
      res1 = self.res1
      res2 = self.res2
      ex = np.asarray(exog).mean(0)
  
      # test for which="mean"
      rdf = res2.results_margins_atmeans
      pred = res1.get_prediction(ex, **self.pred_kwds_mean)
      assert_allclose(pred.predicted, rdf["b"].iloc[0], rtol=1e-4)
      assert_allclose(pred.se, rdf["se"].iloc[0], rtol=1e-4, atol=1e-4)
      if isinstance(pred, PredictionResultsMonotonic):
          # default method is endpoint transformation for non-ZI models
          ci = pred.conf_int()[0]
          assert_allclose(
              ci[0], rdf["ll"].iloc[0], rtol=1e-3, atol=1e-4
          )
          assert_allclose(
              ci[1], rdf["ul"].iloc[0], rtol=1e-3, atol=1e-4
          )
  
          ci = pred.conf_int(method="delta")[0]
          assert_allclose(
              ci[0], rdf["ll"].iloc[0], rtol=1e-4, atol=1e-4
          )
          assert_allclose(
              ci[1], rdf["ul"].iloc[0], rtol=1e-4, atol=1e-4
          )
      else:
          ci = pred.conf_int()[0]
          assert_allclose(
              ci[0], rdf["ll"].iloc[0], rtol=1e-4, atol=1e-4
          )
          assert_allclose(
              ci[1], rdf["ul"].iloc[0], rtol=1e-4, atol=1e-4
          )
  
      stat, _ = pred.t_test()
      assert_allclose(stat, pred.tvalues, rtol=1e-4, atol=1e-4)
  
      rdf = res2.results_margins_mean
      pred = res1.get_prediction(average=True, **self.pred_kwds_mean)
      assert_allclose(
          pred.predicted, rdf["b"].iloc[0], rtol=3e-4
      )  # self.rtol)
      assert_allclose(pred.se, rdf["se"].iloc[0], rtol=3e-3, atol=1e-4)
      if isinstance(pred, PredictionResultsMonotonic):
          # default method is endpoint transformation for non-ZI models
          ci = pred.conf_int()[0]
          assert_allclose(
              ci[0], rdf["ll"].iloc[0], rtol=1e-3, atol=1e-4
          )
          assert_allclose(
              ci[1], rdf["ul"].iloc[0], rtol=1e-3, atol=1e-4
          )
  
          ci = pred.conf_int(method="delta")[0]
          assert_allclose(
              ci[0], rdf["ll"].iloc[0], rtol=1e-4, atol=1e-4
          )
          assert_allclose(
              ci[1], rdf["ul"].iloc[0], rtol=1e-4, atol=1e-4
          )
      else:
          ci = pred.conf_int()[0]
          assert_allclose(
              ci[0], rdf["ll"].iloc[0], rtol=5e-4, atol=1e-4
          )
          assert_allclose(
              ci[1], rdf["ul"].iloc[0], rtol=5e-4, atol=1e-4
          )
  
      stat, _ = pred.t_test()
      assert_allclose(stat, pred.tvalues, rtol=1e-4, atol=1e-4)
  
      # test for which="prob"
      rdf = res2.results_margins_atmeans
      pred = res1.get_prediction(
          ex, which="prob", y_values=np.arange(2), **self.pred_kwds_mean
      )
      assert_allclose(
          pred.predicted, rdf["b"].iloc[1:3], rtol=3e-4
      )  # self.rtol)
      assert_allclose(
          pred.se, rdf["se"].iloc[1:3], rtol=3e-3, atol=1e-4
      )
  
      ci = pred.conf_int()
      assert_allclose(
          ci[:, 0], rdf["ll"].iloc[1:3], rtol=5e-4, atol=1e-4
      )
      assert_allclose(
          ci[:, 1], rdf["ul"].iloc[1:3], rtol=5e-4, atol=1e-4
      )
  
      stat, _ = pred.t_test()
      assert_allclose(stat, pred.tvalues, rtol=1e-4, atol=1e-4)
  
      rdf = res2.results_margins_mean
      pred = res1.get_prediction(
          which="prob",
          y_values=np.arange(2),
          average=True,
          **self.pred_kwds_mean,
      )
      assert_allclose(
          pred.predicted, rdf["b"].iloc[1:3], rtol=5e-3
      )  # self.rtol)
      assert_allclose(
          pred.se, rdf["se"].iloc[1:3], rtol=3e-3, atol=5e-4
      )
  
      ci = pred.conf_int()
      assert_allclose(
          ci[:, 0], rdf["ll"].iloc[1:3], rtol=5e-4, atol=1e-3
      )
      assert_allclose(
          ci[:, 1], rdf["ul"].iloc[1:3], rtol=5e-4, atol=5e-3
      )
  
      stat, _ = pred.t_test()
      assert_allclose(stat, pred.tvalues, rtol=1e-4, atol=1e-4)
      stat, _ = pred.t_test(value=pred.predicted)
      assert_equal(stat, 0)
  
      # test agg_weights
      df6 = exog[:6]
      aw = np.zeros(len(res1.model.endog))
      aw[:6] = 1
      aw /= aw.mean()
      pm6 = res1.get_prediction(
          exog=df6, which="mean", average=True, **self.pred_kwds_6
      )
      dfm6 = pm6.summary_frame()
      pmw = res1.get_prediction(
          which="mean", average=True, agg_weights=aw
      )
      dfmw = pmw.summary_frame()
      assert_allclose(pmw.predicted, pm6.predicted, rtol=1e-13)
      assert_allclose(dfmw, dfm6, rtol=1e-7)
  
imports: import warnings
  import numpy
  from numpy.testing import assert_allclose, assert_equal
  import pytest
  from statsmodels.tools.tools import add_constant
  from statsmodels.base._prediction_inference import PredictionResultsMonotonic
  from statsmodels.discrete.discrete_model import BinaryModel, Logit, Probit, Poisson, NegativeBinomial, NegativeBinomialP, GeneralizedPoisson
  from statsmodels.discrete.count_model import ZeroInflatedPoisson, ZeroInflatedNegativeBinomialP, ZeroInflatedGeneralizedPoisson
  from statsmodels.sandbox.regression.tests.test_gmm_poisson import DATA
  from .results import results_predict
label_desc: Use image node_id 2 for calling the CheckPredict obj's underlying member method code with example usage: obj.test_predict() without return types