class_docstr: Conduct an ADF test for stationarity.
  
  In statistics and econometrics, an augmented Dickey–Fuller test (ADF)
  tests the null hypothesis of a unit root is present in a time series
  sample. The alternative hypothesis is different depending on which version
  of the test is used, but is usually stationarity or trend-stationarity. It
  is an augmented version of the Dickey–Fuller test for a larger and more
  complicated set of time series models.
  
  Parameters
  ----------
  alpha : float, optional (default=0.05)
      Level of the test
  
  k : int, optional (default=None)
      The drift parameter. If ``k`` is None, it will be set to:
      ``np.trunc(np.power(x.shape[0] - 1, 1 / 3.0))``
  
  Notes
  -----
  This test is generally used indirectly via the
  :func:`pmdarima.arima.ndiffs` function, which computes the
  differencing term, ``d``.
  
  ADF test does not perform as close to the R code as do the KPSS and PP
  tests. This is due to the fact that is has to use statsmodels OLS
  regression for std err estimates rather than the more robust sklearn
  LinearRegression.
  
  References
  ----------
  .. [1] https://wikipedia.org/wiki/Augmented_Dickey–Fuller_test
  .. [2] R's tseries ADF source code: https://bit.ly/2EnvM5V
class_docstr_tok: ["Conduct","an","ADF","test","for","stationarity",".","In","statistics","and","econometrics",",","an","augmented","Dickey\u2013Fuller","test","(","ADF",")","tests","the","null","hypothesis","of","a","unit","root","is","present","in","a","time","series","sample",".","The","alternative","hypothesis","is","different","depending","on","which","version","of","the","test","is","used",",","but","is","usually","stationarity","or","trend-stationarity",".","It","is","an","augmented","version","of","the","Dickey\u2013Fuller","test","for","a","larger","and","more","complicated","set","of","time","series","models",".","Parameters","--","--","--","--","--","alpha",":","float",",","optional","(","default=0.05",")","Level","of","the","test","k",":","int",",","optional","(","default=None",")","The","drift","parameter",".","If","``","k","``","is","None",",","it","will","be","set","to",":","``","np.trunc","(","np.power","(","x.shape","[","0","]","-","1",",","1","\/","3.0",")",")","``","Notes","--","--","-","This","test","is","generally","used","indirectly","via","the",":","func",":","`","pmdarima.arima.ndiffs","`","function",",","which","computes","the","differencing","term",",","``","d","``",".","ADF","test","does","not","perform","as","close","to","the","R","code","as","do","the","KPSS","and","PP","tests",".","This","is","due","to","the","fact","that","is","has","to","use","statsmodels","OLS","regression","for","std","err","estimates","rather","than","the","more","robust","sklearn","LinearRegression",".","References","--","--","--","--","--","..","[","1","]","https",":","\/\/wikipedia.org\/wiki\/Augmented_Dickey\u2013Fuller_test","..","[","2","]","R","'s","tseries","ADF","source","code",":","https",":","\/\/bit.ly\/2EnvM5V"]
docstr: Test whether the time series is stationary or needs differencing.
  
  Parameters
  ----------
  x : array-like, shape=(n_samples,)
      The time series vector.
  
  Returns
  -------
  pval : float
      The computed P-value of the test.
  
  sig : bool
      Whether the P-value is significant at the ``alpha`` level.
      More directly, whether to difference the time series.
docstr_tok: ["Test","whether","the","time","series","is","stationary","or","needs","differencing",".","Parameters","--","--","--","--","--","x",":","array-like",",","shape=","(","n_samples",",",")","The","time","series","vector",".","Returns","--","--","--","-","pval",":","float","The","computed","P-value","of","the","test",".","sig",":","bool","Whether","the","P-value","is","significant","at","the","``","alpha","``","level",".","More","directly",",","whether","to","difference","the","time","series","."]
code: def should_diff(self, x):
      """Test whether the time series is stationary or needs differencing.
  
      Parameters
      ----------
      x : array-like, shape=(n_samples,)
          The time series vector.
  
      Returns
      -------
      pval : float
          The computed P-value of the test.
  
      sig : bool
          Whether the P-value is significant at the ``alpha`` level.
          More directly, whether to difference the time series.
      """
      if not self._base_case(x):
          return np.nan, False
  
      # ensure vector
      x = check_endog(x, dtype=DTYPE, preserve_series=False)
  
      # if k is none...
      k = self.k
      if k is None:
          k = np.trunc(np.power(x.shape[0] - 1, 1 / 3.0))
  
      # See [2] for the R source. This is L153 - L160
      k = int(k) + 1
      y = diff(x)  # diff(as.vector(x, mode='double'))
      n = y.shape[0]
      z = self._embed(y, k).T  # Same as R embed(x, k)
  
      # Compute ordinary least squares
      res = self._ols(x, y, z, k)
      STAT = self._ols_std_error(res)
  
      # In the past we assigned to the np memory view which is slower
      tableipl = np.array(
          [
              approx(self.tableT, self.table[:, i], xout=n, rule=2)[
                  1
              ]  # xt,yt
              for i in range(self.tablen)
          ]
      )
  
      # make sure to do 1 - x...
      _, interpol = approx(tableipl, self.tablep, xout=STAT, rule=2)
  
      # Added in v1.1.0. Not sure whether it's likely we'll hit it, but it's
      # how R is warning the user...
      # if np.isnan(approx(tableipl, self.tablep, xout=STAT, rule=1)[1]):
      #     if interpol == self.tablep.min():
      #         warnings.warn("p-value is smaller than printed value")
      #     else:
      #         warnings.warn("p-value is larger than printed value")
  
      # pval = 1 - interpol[0]  # explosive
      pval = interpol[0]  # stationarity
  
      # in the R code, here is where the P value warning is tested again...
      # else if (test == "adf")
      #     suppressWarnings(dodiff < - tseries::adf.test(x)$p.value > alpha)
      return pval, pval > self.alpha
  
imports: from sklearn.base import BaseEstimator
  from sklearn.linear_model import LinearRegression
  from statsmodels import api
  from abc import ABCMeta, abstractmethod
  import numpy
  from ..compat.numpy import DTYPE
  from ..decorators import deprecated
  from ..utils.array import c, diff, check_endog
  from .approx import approx
  from ._arima import C_tseries_pp_sum
label_desc: Use image node_id 4 for calling the ADFTest obj's underlying member method code with example usage: obj.should_diff(x) and returns: pval,  unknown, np,  False