class_docstr: Diagnostic and specification tests and plots for Poisson model
  
  status: experimental
  
  Parameters
  ----------
  results : PoissonResults instance
docstr: Hosmer-Lemeshow style test for count data.
  
  Note, this does not take into account that parameters are estimated.
  The distribution of the test statistic is only an approximation.
  
  This corresponds to the Hosmer-Lemeshow type test for an ordinal
  response variable. The outcome space y = k is partitioned into bins
  and treated as ordinal variable.
  The observations are split into approximately equal sized groups
  of observations sorted according the ``sort_var``.
docstr_tok: ["Hosmer-Lemeshow","style","test","for","count","data",".","Note",",","this","does","not","take","into","account","that","parameters","are","estimated",".","The","distribution","of","the","test","statistic","is","only","an","approximation",".","This","corresponds","to","the","Hosmer-Lemeshow","type","test","for","an","ordinal","response","variable",".","The","outcome","space","y","=","k","is","partitioned","into","bins","and","treated","as","ordinal","variable",".","The","observations","are","split","into","approximately","equal","sized","groups","of","observations","sorted","according","the","``","sort_var","``","."]
code: def _chisquare_binned(
      self,
      sort_var=None,
      bins=10,
      k_max=None,
      df=None,
      sort_method="quicksort",
      frac_upp=0.1,
      alpha_nc=0.05,
  ):
      """Hosmer-Lemeshow style test for count data.
  
      Note, this does not take into account that parameters are estimated.
      The distribution of the test statistic is only an approximation.
  
      This corresponds to the Hosmer-Lemeshow type test for an ordinal
      response variable. The outcome space y = k is partitioned into bins
      and treated as ordinal variable.
      The observations are split into approximately equal sized groups
      of observations sorted according the ``sort_var``.
  
      """
  
      if sort_var is None:
          sort_var = self.results.predict(which="lin")
  
      endog = self.results.model.endog
      # not sure yet how this is supposed to work
      # max_count = endog.max * 2
      # no option for max count in predict
      # counts = (endog == np.arange(max_count)).astype(int)
      expected = self.results.predict(which="prob")
      counts = (endog[:, None] == np.arange(expected.shape[1])).astype(
          int
      )
  
      # truncate upper tail
      if k_max is None:
          nobs = len(endog)
          icumcounts_sum = nobs - counts.sum(0).cumsum(0)
          k_max = np.argmax(icumcounts_sum < nobs * frac_upp) - 1
      expected = expected[:, :k_max]
      counts = counts[:, :k_max]
      # we should correct for or include truncated upper bin
      # inplace modification, we cannot reuse expected and counts anymore
      expected[:, -1] += 1 - expected.sum(1)
      counts[:, -1] += 1 - counts.sum(1)
  
      # TODO: what's the correct df, same as for multinomial/ordered ?
      res = test_chisquare_binning(
          counts,
          expected,
          sort_var=sort_var,
          bins=bins,
          df=df,
          ordered=True,
          sort_method=sort_method,
          alpha_nc=alpha_nc,
      )
      return res
  
file_path: statsmodels/statsmodels/discrete/diagnostic.py
imports: import warnings
  import numpy
  from statsmodels.tools.decorators import cache_readonly
  from statsmodels.stats.diagnostic_gen import test_chisquare_binning
  from statsmodels.discrete._diagnostics_count import test_poisson_dispersion, test_poisson_zeroinflation_jh, test_poisson_zeroinflation_broek, test_poisson_zeros, test_chisquare_prob, plot_probs
label_desc: Use image node_id 4 for calling the PoissonDiagnostic obj's underlying member method code with example usage: obj._chisquare_binned(sort_var, bins, k_max, df, sort_method, frac_upp, alpha_nc) and returns: res