class_docstr: Perform an OCSB test of seasonality.
  
  Compute the Osborn, Chui, Smith, and Birchenhall (OCSB) test for an input
  time series to determine whether it needs seasonal differencing. The
  regression equation may include lags of the dependent variable. When
  ``lag_method`` = "fixed", the lag order is fixed to ``max_lag``; otherwise,
  ``max_lag`` is the maximum number of lags considered in a lag selection
  procedure that minimizes the ``lag_method`` criterion, which can be
  "aic", "bic" or corrected AIC, "aicc".
  
  Critical values for the test are based on simulations, which have been
  smoothed over to produce critical values for all seasonal periods
  
  Parameters
  ----------
  m : int
      The seasonal differencing term. For monthly data, e.g., this would be
      12. For quarterly, 4, etc. For the OCSB test to work, ``m`` must
      exceed 1.
  
  lag_method : str, optional (default="aic")
      The lag method to use. One of ("fixed", "aic", "bic", "aicc"). The
      metric for assessing model performance after fitting a linear model.
  
  max_lag : int, optional (default=3)
      The maximum lag order to be considered by ``lag_method``.
  
  References
  ----------
  .. [1] Osborn DR, Chui APL, Smith J, and Birchenhall CR (1988)
         "Seasonality and the order of integration for consumption",
         Oxford Bulletin of Economics and Statistics 50(4):361-377.
  
  .. [2] R's forecast::OCSB test source code: https://bit.ly/2QYQHno
class_docstr_tok: ["Perform","an","OCSB","test","of","seasonality",".","Compute","the","Osborn",",","Chui",",","Smith",",","and","Birchenhall","(","OCSB",")","test","for","an","input","time","series","to","determine","whether","it","needs","seasonal","differencing",".","The","regression","equation","may","include","lags","of","the","dependent","variable",".","When","``","lag_method","``","=","``","fixed","''",",","the","lag","order","is","fixed","to","``","max_lag","``",";","otherwise",",","``","max_lag","``","is","the","maximum","number","of","lags","considered","in","a","lag","selection","procedure","that","minimizes","the","``","lag_method","``","criterion",",","which","can","be","''","aic","''",",","``","bic","''","or","corrected","AIC",",","``","aicc","''",".","Critical","values","for","the","test","are","based","on","simulations",",","which","have","been","smoothed","over","to","produce","critical","values","for","all","seasonal","periods","Parameters","--","--","--","--","--","m",":","int","The","seasonal","differencing","term",".","For","monthly","data",",","e.g.",",","this","would","be","12",".","For","quarterly",",","4",",","etc",".","For","the","OCSB","test","to","work",",","``","m","``","must","exceed","1.","lag_method",":","str",",","optional","(","default=","''","aic","''",")","The","lag","method","to","use",".","One","of","(","``","fixed","''",",","``","aic","''",",","``","bic","''",",","``","aicc","''",")",".","The","metric","for","assessing","model","performance","after","fitting","a","linear","model",".","max_lag",":","int",",","optional","(","default=3",")","The","maximum","lag","order","to","be","considered","by","``","lag_method","``",".","References","--","--","--","--","--","..","[","1","]","Osborn","DR",",","Chui","APL",",","Smith","J",",","and","Birchenhall","CR","(","1988",")","``","Seasonality","and","the","order","of","integration","for","consumption","''",",","Oxford","Bulletin","of","Economics","and","Statistics","50","(","4",")",":361-377",".","..","[","2","]","R","'s","forecast",":",":OCSB","test","source","code",":","https",":","\/\/bit.ly\/2QYQHno"]
code: def _compute_test_statistic(self, x):
      m = self.m
      maxlag = self.max_lag
      method = self.lag_method
  
      # We might try multiple lags in this case
      crit_regression = None
      if maxlag > 0 and method != "fixed":
          try:
              icfunc = self._ic_method_map[method]
          except KeyError:
              raise ValueError(
                  "'%s' is an invalid method. Must be one "
                  "of ('aic', 'aicc', 'bic', 'fixed')"
              )
  
          fits = []
          icvals = []
          for lag_term in range(1, maxlag + 1):  # 1 -> maxlag (incl)
              try:
                  fit = self._fit_ocsb(x, m, lag_term, maxlag)
                  fits.append(fit)
                  icvals.append(icfunc(fit))
              except np.linalg.LinAlgError:  # Singular matrix
                  icvals.append(np.nan)
                  fits.append(None)
  
          # If they're all NaN, raise
          if np.isnan(icvals).all():
              raise ValueError(
                  "All lag values up to 'maxlag' produced "
                  "singular matrices. Consider using a longer "
                  "series, a different lag term or a different "
                  "test."
              )
  
          # Compute the information criterion vals
          best_index = int(np.nanargmin(icvals))
          maxlag = best_index - 1
  
          # Save this in case we can't compute a better one
          crit_regression = fits[best_index]
  
      # Compute the actual linear model used for determining the test stat
      try:
          regression = self._fit_ocsb(x, m, maxlag, maxlag)
      except np.linalg.LinAlgError:  # Singular matrix
          if crit_regression is not None:
              regression = crit_regression
          # Otherwise we have no solution to fall back on
          else:
              raise ValueError(
                  "Could not find a solution. Try a longer "
                  "series, different lag term, or a different "
                  "test."
              )
  
      # Get the coefficients for the z4 and z5 matrices
      tvals = regression.tvalues[-2:]  # len 2
      return tvals[-1]
  
imports: from collections import namedtuple
  import math
  from sklearn.linear_model import LinearRegression
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import StandardScaler
  from scipy.linalg import svd
  from statsmodels import api
  from statsmodels.tools import add_constant
  from abc import ABCMeta, abstractmethod
  from numpy.linalg import solve
  import numpy
  from .arima import _aicc
  from ..compat.numpy import DTYPE
  from .stationarity import _BaseStationarityTest
  from ..utils.array import c, diff, check_endog
  from ._arima import C_canova_hansen_sd_test
label_desc: Use image node_id 6 for calling the OCSBTest obj's underlying member method code with example usage: obj._compute_test_statistic(x) and returns: tvals