@@ -187,8 +187,6 @@ def _select_best_ic(
187187 large_tstat = abs (tstat ) >= stop
188188 lag = int (squeeze (argwhere (large_tstat )).max ())
189189 icbest = float (tstat [lag ])
190- else :
191- raise ValueError ("Unknown method" )
192190
193191 return icbest , lag
194192
@@ -548,6 +546,16 @@ def _compute_if_needed(self) -> None:
548546 self ._check_specification ()
549547 self ._compute_statistic ()
550548
549+ def _clean_method (self , method : str ) -> Literal ["aic" , "bic" , "t-stat" ]:
550+ if not isinstance (method , str ):
551+ raise TypeError ("method must be a string" )
552+ method = method .lower ()
553+ if method in ("t" , "tstat" , "t-stat" ):
554+ return "t-stat"
555+ elif method not in ("aic" , "bic" ):
556+ raise ValueError ("method must be one of 'aic', 'bic' or 't-stat'" )
557+ return method
558+
551559 @property
552560 def null_hypothesis (self ) -> str :
553561 """The null hypothesis"""
@@ -683,11 +691,11 @@ class ADF(UnitRootTest, metaclass=AbstractDocStringInheritor):
683691
684692 max_lags : int, optional
685693 The maximum number of lags to use when selecting lag length
686- method : {"AIC ", "BIC ", "t-stat"}, optional
694+ method : {"aic ", "bic ", "t-stat"}, optional
687695 The method to use when selecting the lag length
688696
689- - "AIC " - Select the minimum of the Akaike IC
690- - "BIC " - Select the minimum of the Schwarz/Bayesian IC
697+ - "aic " - Select the minimum of the Akaike IC
698+ - "bic " - Select the minimum of the Schwarz/Bayesian IC
691699 - "t-stat" - Select the minimum of the Schwarz/Bayesian IC
692700
693701 low_memory : bool
@@ -763,7 +771,7 @@ def __init__(
763771 valid_trends = ("n" , "c" , "ct" , "ctt" )
764772 super ().__init__ (y , lags , trend , valid_trends )
765773 self ._max_lags = max_lags
766- self ._method = method
774+ self ._method = self . _clean_method ( method )
767775 self ._test_name = "Augmented Dickey-Fuller"
768776 self ._regression = None
769777 self ._low_memory = bool (low_memory )
@@ -798,7 +806,7 @@ def _compute_statistic(self) -> None:
798806 y , trend , lags = self ._y , self ._trend , self ._lags
799807 resols = _estimate_df_regression (y , cast ("UnitRootTrend" , trend ), lags )
800808 self ._regression = resols
801- ( self ._stat , * _ ) = (stat , * _ ) = resols .tvalues
809+ self ._stat , * _ = (stat , * _ ) = resols .tvalues
802810 self ._nobs = int (resols .nobs )
803811 self ._pvalue = mackinnonp (
804812 stat ,
@@ -851,11 +859,11 @@ class DFGLS(UnitRootTest, metaclass=AbstractDocStringInheritor):
851859 The maximum number of lags to use when selecting lag length. When using
852860 automatic lag length selection, the lag is selected using OLS
853861 detrending rather than GLS detrending ([pq]_).
854- method : {"AIC ", "BIC ", "t-stat"}, optional
862+ method : {"aic ", "bic ", "t-stat"}, optional
855863 The method to use when selecting the lag length
856864
857- - "AIC " - Select the minimum of the Akaike IC
858- - "BIC " - Select the minimum of the Schwarz/Bayesian IC
865+ - "aic " - Select the minimum of the Akaike IC
866+ - "bic " - Select the minimum of the Schwarz/Bayesian IC
859867 - "t-stat" - Select the minimum of the Schwarz/Bayesian IC
860868
861869 Notes
@@ -912,7 +920,7 @@ def __init__(
912920 valid_trends = ("c" , "ct" )
913921 super ().__init__ (y , lags , trend , valid_trends )
914922 self ._max_lags = max_lags
915- self ._method = method
923+ self ._method = self . _clean_method ( method )
916924 self ._regression = None
917925 self ._low_memory = low_memory
918926 if low_memory is None :
@@ -1403,11 +1411,11 @@ class ZivotAndrews(UnitRootTest, metaclass=AbstractDocStringInheritor):
14031411 calculation in range [0, 0.333] (default=0.15)
14041412 max_lags : int, optional
14051413 The maximum number of lags to use when selecting lag length
1406- method : {"AIC ", "BIC ", "t-stat"}, optional
1414+ method : {"aic ", "bic ", "t-stat"}, optional
14071415 The method to use when selecting the lag length
14081416
1409- - "AIC " - Select the minimum of the Akaike IC
1410- - "BIC " - Select the minimum of the Schwarz/Bayesian IC
1417+ - "aic " - Select the minimum of the Akaike IC
1418+ - "bic " - Select the minimum of the Schwarz/Bayesian IC
14111419 - "t-stat" - Select the minimum of the Schwarz/Bayesian IC
14121420
14131421 Notes
@@ -1457,7 +1465,8 @@ def __init__(
14571465 raise ValueError ("trim must be a float in range [0, 1/3]" )
14581466 self ._trim = trim
14591467 self ._max_lags = max_lags
1460- self ._method = method
1468+ self ._method = self ._clean_method (method )
1469+
14611470 self ._test_name = "Zivot-Andrews"
14621471 self ._all_stats = full (self ._y .shape [0 ], nan )
14631472 self ._null_hypothesis = (
0 commit comments