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"]
docstr: Perform the TS lagging
docstr_tok: ["Perform","the","TS","lagging"]
code: def _do_lag(y, lag, omit_na=True):
      """Perform the TS lagging"""
      n = y.shape[0]
      if lag == 1:
          return y.reshape(n, 1)
  
      # Create a 2d array of dims (n + (lag - 1), lag). This looks cryptic..
      # If there are tons of lags, this may not be super efficient...
      out = np.ones((n + (lag - 1), lag)) * np.nan
      for i in range(lag):
          out[i : i + n, i] = y
  
      if omit_na:
          out = out[~np.isnan(out).any(axis=1)]
      return out
  
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 3 for calling the OCSBTest obj's underlying member method code with example usage: obj._do_lag(y, lag, omit_na) and returns: out, y