Ë
    £�Dj¤ƒ ã                  ó²  — d dl mZ d dlmZmZmZ d dlmZ d dlZ	d dl
mZmZ d dlZd dlmZ d dlmZmZmZmZmZmZ d dlmZmZmZ d dlZd dlZd dlZd d	l m!Z! d d
l"m#Z# d dl$m%c m&Z' d dl(m)Z)m*Z* d dl+m,Z, d dl-m.Z. d dl/m0Z0m1Z1m2Z2 d dl3m4Z4 d dl5m6Z6m7Z7m8Z8m9Z9 d dl:m;Z;m<Z<m=Z=m>Z> d dl?m@Z@mAZAmBZBmCZC d dlDmEZE d dlFmGZG d dlHmIZI d dlJmKZK d dlLmMZM d dlNmOZO erd dlPZQg d¢ZR G d„ de«      ZSedeTeUeeeT   f   f   ZVedeTeVeeT   eUeeeTeeT   df   f   f   ZWeTej°                  fZYdFd„ZZ	 	 	 	 	 	 	 	 dGd„Z[ G d„ d eA«      Z\ e0e\jº                  j¼                  «      Z_e_jÁ                  g d!¢d"«      Za G d#„ d$eB«      Zb G d%„ d&e'jÆ                  «      Zd e'jÊ                  edeb«        G d'„ d(e@«      Zf	 dHdd)d*d)d)dddd+d,œ		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dId.„Zg ejN                  d/d0«      Zh e1d1d-eh¬2«      Zi ejN                  d3d0«      Zj e1dd4ej¬2«      Zk e0e\jØ                  j¼                  «      ZmemjÝ                  d5d6«       emje                  d1«       emje                  d«       emjß                  d7ei«       emjß                  d1ek«        e0e\jà                  j¼                  «      ZqeqjÝ                  d8 e1d9d:d;g«      g«       eqjä                  �7eqjä                  d<   Zsesjé                  d d=gd>gf«       eqjÝ                  d<es«        G d?„ d@e\«      Zu G dA„ d:eb«      ZvdJdB„Zw	 	 	 	 	 	 	 	 	 	 	 	 	 	 dKdC„Zx G dD„ dEe'jÆ                  «      Zy e'jÊ                  eyev«       y)Lé    )Úannotations)ÚAppenderÚSubstitutionÚcall_cached_func)ÚdefaultdictN)ÚcombinationsÚproduct)ÚSimpleNamespace)ÚTYPE_CHECKINGÚAnyÚLiteralÚ
NamedTupleÚOptionalÚUnion)ÚHashableÚMappingÚSequence)Ústats)Ú
PandasData)ÚSummaryÚsummary_params)ÚOLS)Úcache_readonly)Ú	DocstringÚ	ParameterÚremove_parameters)ÚSpecificationWarning)ÚArrayLike1DÚArrayLike2DÚFloat64ArrayÚNDArray)Ú
array_likeÚ	bool_likeÚ
float_likeÚint_like)ÚAROrderSelectionResultsÚAutoRegÚAutoRegResultsÚsumofsq)Úpss_critical_values)Úarma2ma)Ú	tsa_model)ÚPredictionResults)ÚDeterministicProcess)Úlagmat)ÚARDLÚARDLResultsÚardl_select_orderÚARDLOrderSelectionResultsÚUECMÚUECMResultsÚBoundsTestResultc                  óF   — e Zd ZU ded<   ded<   ded<   ded<   ded	<   d
„ Zy)r6   ÚfloatÚstatúpd.DataFrameÚ	crit_valsz	pd.SeriesÚp_valuesÚstrÚnullÚalternativec                óÈ   — | j                   j                  › d| j                  d›d| j                  d   d›d| j                  d   d›d| j                  › d	| j
                  › d
�S )Nz
Stat: z0.5fz
Upper P-value: Úupperz0.3gz
Lower P-value: Úlowerz
Null: z
Alternative: ú
)Ú	__class__Ú__name__r9   r<   r>   r?   ©Úselfs    ú^C:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\statsmodels\tsa\ardl\model.pyÚ__repr__zBoundsTestResult.__repr__N   s}   € à‡�×ÑÐ ð Ø‡y�y�Ðð Ø—‘˜gÑ& tÐ,ð -Ø—‘˜gÑ& tÐ,ð -Ø‡y�y€kð Ø×ÑÐð  ðð 	ó    N)rE   Ú
__module__Ú__qualname__Ú__annotations__rI   © rJ   rH   r6   r6   G   s#   … Ø
ƒKØÓØÓØ
ƒIØÓórJ   r6   Úorderc                ó  — | €yt        | t        t        j                  f«      r3t        | «      t        |«      k  rt	        dt        |«      › d|› d�«      ‚y| D ]-  }t        |t        t        j                  f«      rŒ$t        d«      ‚ | D �cg c]  }t        |«      ‘Œ } }t        t        | «      «      t        | «      k7  st        | «      dk  rt	        d«      ‚t        |«      rt        | «      dk  rt	        d	«      ‚yc c}w )
NTz integer orders must be at least z when causal is ú.z8sequence orders must contain non-negative integer valuesr   z9sequence orders must contain distinct non-negative valuesé   z=sequence orders must be strictly positive when causal is True)	Ú
isinstanceÚintÚnpÚintegerÚ
ValueErrorÚ	TypeErrorÚlenÚsetÚmin)rO   ÚcausalÚvs      rH   Ú_check_orderr^   f   s  € Ø€}ØÜ�%œ#œrŸz™zÐ*Ô+Üˆu‹:œ˜F›Ò#ÜØ2´3°v³;°-ð @Ø�X˜Qð óð ð Øò ˆÜ˜!œc¤2§:¡:Ð.Õ/ÜØJóð ðð
 #Ö#˜ŒS��VÐ#€EÐ#Ü
Œ3ˆu‹:ƒœ#˜e›*Ò$¬¨E«
°QªÜØGó
ð 	
ô ˆ6„{”s˜5“z A’~ÜØKó
ð 	
ð ùò $s   ÂC?c                ó  — | €|dv ri S t        | t        j                  «      s1t        | ddd¬«      } t	        t        | j                  d   «      «      }n| j                  D �cg c]  }|‘Œ }}|€|D �ci c]  }|d “Œ }}�nwt        |t        «      �r|}t        |«      j                  |j                  «       «      }t        |j                  «       «      j                  |«      }|rRd}	|	dz  }	|	dj                  t	        t        |D �
cg c]  }
t        |
«      ‘Œ c}
«      «      «      d	z   z  }	t        |	«      ‚|rLd
}	|	dj                  |D �cg c]  }t        |«      ‘Œ c}«      d	z   z  }	t!        j"                  |	t$        d¬«       |D ]  }t'        ||   |«       Œ n[t        |t(        «      r&t'        ||«       |D �ci c]  }|t+        |«      “Œ }}n%t'        ||«       |D �ci c]  }|t	        |«      “Œ }}i }|D ]_  }||   }|€Œ|€J ‚t        |t*        «      r%t	        t        t+        |«      |dz   «      «      ||<   ŒD|D �cg c]  }t+        |«      ‘Œ c}||<   Œa |S c c}w c c}w c c}
w c c}w c c}w c c}w c c}w )N)r   NÚexogé   ©ÚndimÚmaxdimrR   zWorder dictionary contains keys for exogenous variable(s) that are not contained in exogz Extra keys: z, rQ   zSexog contains variables that are missing from the order dictionary.  Missing keys: )Ú
stacklevel)rS   ÚpdÚ	DataFramer"   ÚlistÚrangeÚshapeÚcolumnsr   rZ   Ú
differenceÚkeysÚjoinÚsortedr=   rW   ÚwarningsÚwarnr   r^   Ú
_INT_TYPESrT   )r`   rO   r\   rm   ÚcolÚkÚ
exog_orderÚmissingÚextraÚmsgr]   ÚkeyÚfinal_orderÚvalueÚlags                  rH   Ú_format_orderr}   �   sg  € ð
 €|˜ Ñ*Øˆ	Ü�dœBŸL™LÔ)Ü˜$ ¨Q°qÔ9ˆÜ”E˜$Ÿ*™* Q™-Ó(Ó)‰à#Ÿ|™|Ö,˜’Ð,ˆÐ,Ø€}Ø'+Ö, !�a˜‘gÐ,ˆ
Ò,Ü	�Eœ7Õ	#Øˆ
Ü�d“)×&Ñ& u§z¡z£|Ó4ˆÜ�E—J‘J“LÓ!×,Ñ,¨TÓ2ˆÙð=ð ð �?Ñ"ˆCØ�4—9‘9œT¤&¸%Ö)@°Q¬#¨a­&Ò)@Ó"AÓBÓCÀcÑIÑIˆCÜ˜S“/Ð!Ùð.ð ð �4—9‘9¨gÖ6¨œc !�fÒ6Ó7¸#Ñ=Ñ=ˆCÜ�M‰M˜#Ô3ÀÕBàò 	2ˆCÜ˜ C™¨&Õ1ñ	2ä	�Eœ:Ô	&Ü�U˜FÔ#Ø-1Ö2¨�aœ˜U›‘mÐ2ˆ
Ñ2ä�U˜FÔ#Ø.2Ö3¨�aœ˜e›‘nÐ3ˆ
Ð3Ø-/€KØò ;ˆØ˜3‘ˆØˆ=ØØÐ Ñ Ü�eœSÔ!Ü#¤E¬#¨f«+°u¸q±yÓ$AÓBˆK˜Òà49Ö:¨S¤ C¥Ò:ˆK˜Òð;ð ÐùòU -ùâ,ùò *Aùò 7ùò 3ùò 4ùò  ;s*   Á"	I Á3
I%ÄI*ÅI/
Æ=I4Ç#I9ÉI>c            	      ó  ‡ — e Zd ZdZ	 	 	 dddddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„Zedd„«       Zedd„«       Zedd	„«       Zedd
„«       Z	ed d„«       Z
d!d„Ze	 	 	 	 	 	 d"d„«       Zd#d„Z	 	 	 d$	 	 	 	 	 	 	 d%d„Zddddœ	 	 	 	 	 	 	 d&d„Z	 	 	 	 d'd„Zd„ Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(d„Z	 	 	 	 	 	 	 d)	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d*d„Ze	 	 	 d+dddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,d„«       Zˆ xZS )-r0   a›  
    Autoregressive Distributed Lag (ARDL) Model

    Parameters
    ----------
    endog : array_like
        A 1-d endogenous response variable. The dependent variable.
    lags : {int, list[int]}
        The number of lags to include in the model if an integer or the
        list of lag indices to include.  For example, [1, 4] will only
        include lags 1 and 4 while lags=4 will include lags 1, 2, 3, and 4.
    exog : array_like
        Exogenous variables to include in the model. Either a DataFrame or
        an 2-d array-like structure that can be converted to a NumPy array.
    order : {int, sequence[int], dict}
        If int, uses lags 0, 1, ..., order  for all exog variables. If
        sequence[int], uses the ``order`` for all variables. If a dict,
        applies the lags series by series. If ``exog`` is anything other
        than a DataFrame, the keys are the column index of exog (e.g., 0,
        1, ...). If a DataFrame, keys are column names.
    fixed : array_like
        Additional fixed regressors that are not lagged.
    causal : bool, optional
        Whether to include lag 0 of exog variables.  If True, only includes
        lags 1, 2, ...
    trend : {'n', 'c', 't', 'ct'}, optional
        The trend to include in the model:

        * 'n' - No trend.
        * 'c' - Constant only.
        * 't' - Time trend only.
        * 'ct' - Constant and time trend.

        The default is 'c'.

    seasonal : bool, optional
        Flag indicating whether to include seasonal dummies in the model. If
        seasonal is True and trend includes 'c', then the first period
        is excluded from the seasonal terms.
    deterministic : DeterministicProcess, optional
        A deterministic process.  If provided, trend and seasonal are ignored.
        A warning is raised if trend is not "n" and seasonal is not False.
    hold_back : {None, int}, optional
        Initial observations to exclude from the estimation sample.  If None,
        then hold_back is equal to the maximum lag in the model.  Set to a
        non-zero value to produce comparable models with different lag
        length.  For example, to compare the fit of a model with lags=3 and
        lags=1, set hold_back=3 which ensures that both models are estimated
        using observations 3,...,nobs. hold_back must be >= the maximum lag in
        the model.
    period : {None, int}, optional
        The period of the data. Only used if seasonal is True. This parameter
        can be omitted if using a pandas object for endog that contains a
        recognized frequency.
    missing : {"none", "drop", "raise"}, optional
        Available options are 'none', 'drop', and 'raise'. If 'none', no NaN
        checking is done. If 'drop', any observations with NaNs are dropped.
        If 'raise', an error is raised. Default is 'none'.

    Notes
    -----
    The full specification of an ARDL is

    .. math ::

       Y_t = \delta_0 + \delta_1 t + \delta_2 t^2
             + \sum_{i=1}^{s-1} \gamma_i I_{[(\mod(t,s) + 1) = i]}
             + \sum_{j=1}^p \phi_j Y_{t-j}
             + \sum_{l=1}^k \sum_{m=0}^{o_l} \beta_{l,m} X_{l, t-m}
             + Z_t \lambda
             + \epsilon_t

    where :math:`\delta_\bullet` capture trends, :math:`\gamma_\bullet`
    capture seasonal shifts, s is the period of the seasonality, p is the
    lag length of the endogenous variable, k is the number of exogenous
    variables :math:`X_{l}`, :math:`o_l` is included the lag length of
    :math:`X_{l}`, :math:`Z_t` are ``r`` included fixed regressors and
    :math:`\epsilon_t` is a white noise shock. If ``causal`` is ``True``,
    then the 0-th lag of the exogenous variables is not included and the
    sum starts at ``m=1``.

    See the notebook `Autoregressive Distributed Lag Models
    <../examples/notebooks/generated/autoregressive_distributed_lag.html>`__
    for an overview.

    See Also
    --------
    statsmodels.tsa.ar_model.AutoReg
        Autoregressive model estimation with optional exogenous regressors
    statsmodels.tsa.ardl.UECM
        Unconstrained Error Correction Model estimation
    statsmodels.tsa.statespace.sarimax.SARIMAX
        Seasonal ARIMA model estimation with optional exogenous regressors
    statsmodels.tsa.arima.model.ARIMA
        ARIMA model estimation

    Examples
    --------
    >>> from statsmodels.tsa.api import ARDL
    >>> from statsmodels.datasets import danish_data
    >>> data = danish_data.load_pandas().data
    >>> lrm = data.lrm
    >>> exog = data[["lry", "ibo", "ide"]]

    A basic model where all variables have 3 lags included

    >>> ARDL(data.lrm, 3, data[["lry", "ibo", "ide"]], 3)

    A dictionary can be used to pass custom lag orders

    >>> ARDL(data.lrm, [1, 3], exog, {"lry": 1, "ibo": 3, "ide": 2})

    Setting causal removes the 0-th lag from the exogenous variables

    >>> exog_lags = {"lry": 1, "ibo": 3, "ide": 2}
    >>> ARDL(data.lrm, [1, 3], exog, exog_lags, causal=True)

    A dictionary can also be used to pass specific lags to include.
    Sequences hold the specific lags to include, while integers are expanded
    to include [0, 1, ..., lag]. If causal is False, then the 0-th lag is
    excluded.

    >>> ARDL(lrm, [1, 3], exog, {"lry": [0, 1], "ibo": [0, 1, 3], "ide": 2})

    When using NumPy arrays, the dictionary keys are the column index.

    >>> import numpy as np
    >>> lrma = np.asarray(lrm)
    >>> exoga = np.asarray(exog)
    >>> ARDL(lrma, 3, exoga, {0: [0, 1], 1: [0, 1, 3], 2: 2})
    NFÚnone©Úfixedr\   ÚseasonalÚdeterministicÚ	hold_backÚperiodrv   c               ól  •— t        j                  d«      | _        t        j                  d«      | _        t        ‰| �  ||||||
|||	d¬«
       t        |dd¬«      | _        || j                  _	        |�àt        |dd	d	¬
«      }|j                  d   | j                  j                  j                  d   k7  s(t        j                  t        j                  |«      «      st        d«      ‚t!        |t"        j$                  «      rt'        |j(                  «      | _        n.t-        |j                  d   «      D �cg c]  }d|› �‘Œ	 c}| _        || _        nDt        j                  | j                  j                  j                  d   df«      | _        g | _        i | _        i | _        | j5                  |«      | _        | j9                  |
«      \  | _        | _        | j;                  «       \  | _        | _        | j>                  x| j                  _         | j                  _!        | j<                  | j                  _"        d| _        | j6                  rC| j6                  jG                  «       D �cg c]  }tI        |«      ‘Œ }}tI        |«      dkD  | _        tJ        | _&        tN        | _(        y c c}w c c}w )N©r   r   ©r   F)Útrendr‚   r`   r„   r…   rv   rƒ   Ú	old_namesr\   T)Ústrictr�   ra   rb   r   z‚fixed must be an (nobs, m) array where nobs matches the number of observations in the endog variable, and allvalues must be finiterR   zz.))rU   ÚemptyÚ_xÚ_yÚsuperÚ__init__r#   Ú_causalÚdataÚ
orig_fixedr"   rj   ÚendogÚallÚisfiniterW   rS   rf   rg   rh   rk   Ú_fixed_namesri   Ú_fixedÚ_blocksÚ_namesr^   Ú_orderÚ_construct_regressorsÚ_construct_variable_namesÚ_endog_nameÚ_exog_namesÚparam_namesÚxnamesÚynamesÚvaluesr[   r1   Ú_results_classÚARDLResultsWrapperÚ_results_wrapper)rG   r”   Úlagsr`   rO   r‰   r�   r\   r‚   rƒ   r„   r…   rv   Ú	fixed_arrÚiÚvalÚmin_lagsrD   s                    €rH   r�   zARDL.__init__>  sA  ø€ ô  —(‘(˜6Ó"ˆŒÜ—(‘(˜4“.ˆŒä‰ÑØØØØØØØØØ'Øð 	ô 	
ô ! ¨¸$Ô?ˆŒØ$ˆ�	‰	ÔØÐÜ" 5¨'¸À!ÔDˆIØ�‰˜qÑ! T§Y¡Y§_¡_×%:Ñ%:¸1Ñ%=Ò=ÄRÇVÁVÜ—‘˜IÓ&ôFô !ð,óð ô
 ˜%¤§¡Ô.Ü$(¨¯©Ó$7�Õ!ô ',¨I¯O©O¸AÑ,>Ó&?ö%Ø!"�b˜˜’Hò%�Ô!ð $ˆD�KäŸ(™( D§I¡I§O¡O×$9Ñ$9¸!Ñ$<¸aÐ#@ÓAˆDŒKØ "ˆDÔà.0ˆŒØ02ˆŒð ×'Ñ'¨Ó.ˆŒà×5Ñ5°iÓ@ÑˆŒ�”à-1×-KÑ-KÓ-MÑ*ˆÔ˜$Ô*Ø37×3CÑ3CÐCˆ�	‰	Ô §	¡	Ô 0Ø×+Ñ+ˆ�	‰	ÔàˆŒØ�;Š;Ø,0¯K©K×,>Ñ,>Ó,@ÖA Sœ˜C�ÐAˆHÐAÜ˜x›=¨1Ñ,ˆDŒLÜ)ˆÔÜ 2ˆÕùò3%ùò, Bs   Ä9J,É.J1c                ó.   — | j                   j                  S )z*The fixed data used to construct the model)r’   r“   rF   s    rH   r�   z
ARDL.fixedˆ  s   € ð �y‰y×#Ñ#Ð#rJ   c                ó   — | j                   S )z'Flag indicating that the ARDL is causal)r‘   rF   s    rH   r\   zARDL.causal�  s   € ð �|‰|ÐrJ   c                ó6   — | j                   sdS | j                   S )z-The autoregressive lags included in the modelN)Ú_lagsrF   s    rH   Úar_lagszARDL.ar_lags’  s   € ð  Ÿ:š:ˆtÐ5¨4¯:©:Ð5rJ   c                ó   — | j                   S )z5The lags of exogenous variables included in the model)r›   rF   s    rH   Údl_lagszARDL.dl_lags—  s   € ð �{‰{ÐrJ   c                ó   — | j                   sdnt        t        | j                   «      «      }|g}| j                  j	                  «       D ](  }|€Œ|j                  t        t        |«      «      «       Œ* t        |«      S )zThe order of the ARDL(p,q)r   )r¯   rT   Úmaxr›   r£   ÚappendÚtuple)rG   Úar_orderÚ
ardl_orderr§   s       rH   r¸   zARDL.ardl_orderœ  sj   € ð !ŸJšJ‘1¬C´°D·J±J³Ó,@ˆØ�Zˆ
Ø—K‘K×&Ñ&Ó(ò 	2ˆDØÑØ×!Ñ!¤#¤c¨$£i£.Õ1ð	2ô �ZÓ Ð rJ   c                ó„   — t        j                  | j                  j                  d   | j                  z
  df«      | _        y)z)Place holder to let AutoReg init completer   N)rU   rŒ   r”   rj   Ú
_hold_backrŽ   rF   s    rH   Ú_setup_regressorszARDL._setup_regressors¦  s/   € ä—(‘(˜DŸJ™J×,Ñ,¨QÑ/°$·/±/ÑAÀ1ÐEÓFˆ�rJ   c                ó�  — |si S d}|j                  «       D ]  }|€Œt        t        |«      |«      }Œ t        | t        j                  «      st        | ddd¬«      } i }|D ]b  }||   €Œ	t        | t        j                  «      rt        |t        «      sJ ‚| dd…|f   }n| |   }t        ||d¬«      }||   }|dd…|f   ||<   Œd |S )z6Transform exogenous variables and orders to regressorsr   Nr`   ra   rb   Úin©Úoriginal)
r£   r´   rS   rf   rg   r"   rU   ÚndarrayrT   r/   )	r`   rO   Ú	max_orderrª   Ú	exog_lagsry   rs   Ú
lagged_colr§   s	            rH   Ú_format_exogzARDL._format_exogª  sÞ   € ñ
 ØˆIØˆ	Ø—<‘<“>ò 	5ˆCØ‰Ü¤ C£¨)Ó4‘	ð	5ô ˜$¤§¡Ô-Ü˜d F°¸1Ô=ˆDØˆ	Øò 
	1ˆCØ�S‰zÐ!ØÜ˜$¤§
¡
Ô+Ü! #¤sÔ+Ñ+Øš1˜c˜6‘l‘à˜3‘i�Ü  Y¸Ô>ˆJØ˜‘:ˆDØ'ª¨4¨Ñ0ˆI�cŠNð
	1ð ÐrJ   c                óX   — t        | j                  j                  || j                  «      S )z(Validate and standardize the model order)r}   r’   Ú	orig_exogr‘   )rG   rO   s     rH   r^   zARDL._check_orderÅ  s   € ä˜TŸY™Y×0Ñ0°%¸¿¹ÓFÐFrJ   Ú	nonrobustTc                ó  — | j                   j                  d   dk(  r>t        j                  d«      t        j                  d«      t        j                  d«      fS t	        | j
                  | j                   «      }|j                  |||¬«      }|j                  «       }|j                  }|dk(  rA|s?| j
                  j                  d   }| j                   j                  d   }|||z
  z  }	||	z  }|j                  ||j                  fS )NrR   r   rˆ   r‡   ©Úcov_typeÚcov_kwdsÚuse_trÇ   )r�   rj   rU   rŒ   r   rŽ   ÚfitÚ
cov_paramsrÌ   ÚparamsÚnormalized_cov_params)
rG   rÊ   rË   rÌ   Úols_modÚols_resrÎ   Únobsrt   Úscales
             rH   Ú_fitz	ARDL._fitÉ  sä   € ð �7‰7�=‰=˜Ñ˜qÒ Ü—8‘8˜D“>¤2§8¡8¨FÓ#3´R·X±X¸fÓ5EÐEÐEÜ�d—g‘g˜tŸw™wÓ'ˆØ—+‘+Ø¨¸ð ó 
ˆð ×'Ñ'Ó)ˆ
Ø—‘ˆØ�{Ò"©5Ø—7‘7—=‘= Ñ#ˆDØ—‘—‘˜aÑ ˆAØ˜D 1™HÑ%ˆEØ˜%ÑˆJà�~‰~˜z¨7×+HÑ+HÐHÐHrJ   rÉ   c               óh   — | j                  |||¬«      \  }}}t        | ||||¬«      }t        |«      S )aQ	  
        Estimate the model parameters.

        Parameters
        ----------
        cov_type : str
            The covariance estimator to use. The most common choices are listed
            below.  Supports all covariance estimators that are available
            in ``OLS.fit``.

            * 'nonrobust' - The class OLS covariance estimator that assumes
              homoskedasticity.
            * 'HC0', 'HC1', 'HC2', 'HC3' - Variants of White's
              (or Eiker-Huber-White) covariance estimator. `HC0` is the
              standard implementation.  The other make corrections to improve
              the finite sample performance of the heteroskedasticity robust
              covariance estimator.
            * 'HAC' - Heteroskedasticity-autocorrelation robust covariance
              estimation. Supports cov_kwds.

              - `maxlags` integer (required) : number of lags to use.
              - `kernel` callable or str (optional) : kernel
                  currently available kernels are ['bartlett', 'uniform'],
                  default is Bartlett.
              - `use_correction` bool (optional) : If true, use small sample
                  correction.
        cov_kwds : dict, optional
            A dictionary of keyword arguments to pass to the covariance
            estimator. `nonrobust` and `HC#` do not support cov_kwds.
        use_t : bool, optional
            A flag indicating that inference should use the Student's t
            distribution that accounts for model degree of freedom.  If False,
            uses the normal distribution. If None, defers the choice to
            the cov_type. It also removes degree of freedom corrections from
            the covariance estimator when cov_type is 'nonrobust'.

        Returns
        -------
        ARDLResults
            Estimation results.

        See Also
        --------
        statsmodels.tsa.ar_model.AutoReg
            Ordinary Least Squares estimation.
        statsmodels.regression.linear_model.OLS
            Ordinary Least Squares estimation.
        statsmodels.regression.linear_model.RegressionResults
            See ``get_robustcov_results`` for a detailed list of available
            covariance estimators and options.

        Notes
        -----
        Use ``OLS`` to estimate model parameters and to estimate parameter
        covariance.
        rÉ   ©rÌ   )rÕ   r1   r¥   ©rG   rÊ   rË   rÌ   rÏ   rÎ   Únorm_cov_paramsÚress           rH   rÍ   zARDL.fitß  sJ   € ð~ /3¯i©iØ¨¸ð /8ó /
Ñ+ˆ�
˜Oô Ø�&˜* o¸Uô
ˆô " #Ó&Ð&rJ   c                ó   — | j                   rt        | j                   «      nd| _        t        | j                  j
                  | j                  d¬«      \  }}t        |t        j                  «      sJ ‚t        |t        j                  «      sJ ‚||c| _	        | _
        | j                  j                  d   t        | j                   «      k7  r4| j                   D �cg c]  }|dz
  ‘Œ	 }}| j                  dd…|f   | _	        | j                  j                  }| j                  || j                  «      | _        d}| j                  j#                  «       D ]  }t        ||�t        |«      nd«      }Œ t        | j                  |«      | _        | j$                  j'                  «       | _        | j                  | j                   | j(                  | j*                  dœ| _        | j(                  | j                  g}	|	| j                   j#                  «       D �
cg c]  }
|
‘Œ c}
| j*                  gz   z  }	t        j.                  |	«      }|€t1        | j                  «      | _        | j2                  | j                  k  rt5        d«      ‚|| j2                  d }|j                  d   |j                  d   kD  r,t5        d|j                  d   › d	|j                  d   › d
�«      ‚| j                  j
                  | j2                  d |fS c c}w c c}
w )ú%Construct and format model regressorsr   Úsepr¾   rR   N©r”   r`   rƒ   r�   úDhold_back must be >= the maximum lag of the endog and exog variablesúThe number of regressors (ú�) including deterministics, lags of the endog, lags of the exogenous, and fixed regressors is larger than the sample available for estimation (ú).)r¯   r´   Ú_maxlagr/   r’   r”   rS   rU   rÀ   Ú
_endog_regÚ_endogrj   rY   rÆ   rÄ   r›   Ú_exogr£   Ú_deterministicsÚ	in_sampleÚ_deterministic_regr˜   r™   Úcolumn_stackrT   rº   rW   )rG   r„   rä   rå   r|   Úlag_locsrÆ   Úexog_maxlagrª   ÚxÚexÚregs               rH   rœ   zARDL._construct_regressors&  s†  € ð
 +/¯*ª*”s˜4Ÿ:™:”¸!ˆŒÜ#Ø�I‰I�O‰O˜TŸ\™\°Eô
Ñˆ
�Fô ˜&¤"§*¡*Ô-Ñ-Ü˜*¤b§j¡jÔ1Ñ1Ø'1°6Ð$ˆŒ˜œØ�?‰?× Ñ  Ñ#¤s¨4¯:©:£Ò6Ø+/¯:©:Ö6 C˜˜a›Ð6ˆHÐ6Ø"Ÿo™oªa°¨kÑ:ˆDŒOà—I‘I×'Ñ'ˆ	Ø×&Ñ& y°$·+±+Ó>ˆŒ
àˆØ—;‘;×%Ñ%Ó'ò 	OˆCÜ˜k°s°¬3¨s¬8ÈAÓN‰Kð	Oä˜4Ÿ<™<¨Ó5ˆŒà"&×"6Ñ"6×"@Ñ"@Ó"BˆÔà—_‘_Ø—J‘JØ!×4Ñ4Ø—[‘[ñ	
ˆŒð ×$Ñ$ d§o¡oÐ6ˆØ	˜4Ÿ:™:×,Ñ,Ó.Ö/�RŠbÒ/°4·;±;°-Ñ?Ñ?ˆÜ�o‰o˜aÓ ˆØÐÜ! $§,¡,Ó/ˆDŒOØ�?‰?˜TŸ\™\Ò)Üðóð ð �$—/‘/Ð#Ð$ˆØ�9‰9�Q‰<˜#Ÿ)™) A™,Ò&ÜØ,¨S¯Y©Y°q©\¨Nð ;#ð $'§9¡9¨Q¡< .°ð4óð ð �y‰y�‰˜tŸ™Ð0Ð1°3Ð6Ð6ùòI 7ùò& 0s   ÃLÈ	Lc                óT  — | j                   j                  }| j                  D �cg c]	  }|› d|› �‘Œ }}| j                   j                  }i }| j                  D ]T  }t        |t        j                  «      rd|› �}nt        |«      }| j                  |   }|D �	cg c]	  }	|› d|	› �‘Œ c}	||<   ŒV ||| j                  j                  | j                  dœ| _        t        | j                  j                  «      }
|
|z  }
|D ]
  }|
||   z  }
Œ |
| j                  z  }
||
fS c c}w c c}	w )úConstruct model variables namesú.Lrí   rÞ   )r’   r¢   r¯   rÆ   r›   rS   rU   rÀ   r=   ré   rk   r—   rš   rh   )rG   Úy_namer©   Úendog_lag_namesr`   Ú
exog_namesry   Úbaser§   r|   Úx_namess              rH   r�   zARDL._construct_variable_namesY  s9  € à—‘×!Ñ!ˆØ59·Z±ZÖ@°˜f˜X R¨ sÒ+Ð@ˆÐ@à�y‰y×"Ñ"ˆØˆ
Ø—;‘;ò 	AˆCÜ˜$¤§
¡
Ô+Ø˜3˜%�y‘ä˜3“x�Ø—;‘;˜sÑ#ˆDØ;?Ö@°C $  r¨#¨Ò/Ò@ˆJ�sŠOð	Að %ØØ!×4Ñ4×<Ñ<Ø×&Ñ&ñ	
ˆŒô �t×.Ñ.×6Ñ6Ó7ˆØ�?Ñ"ˆØò 	'ˆCØ�z #‘Ñ&‰Gð	'à�4×$Ñ$Ñ$ˆØ�wˆÐùò/ Aùò As   ¥D ÂD%c           	     óÖ  — d	d„}|| j                   k\  rdn| j                   |z
  }	|dz   | j                  j                  d   k  rC|€A|€?t        || j                   z
  d«      }
 || j                  |
|dz   | j                   z
   |	«      S |€| j
                  j                  nt        j                  |«      }|�-t        j                  |t        j                  |«      d| g«      }|€| j                  nt        j                  |«      }|�-t        j                  |t        j                  |«      d| g«      }| j                  j                  «       }|r4| j                  j                  |«      }t        j                  ||gd¬«      }| j
                  j                  }|r9t        j                   |t        j"                  |t        j$                  «      g«      }|g}| j&                  rTt)        |t        | j&                  «      d¬«      }|j+                  |dd…| j&                  D �cg c]  }|dz
  ‘Œ	 c}f   «       | j,                  dd r¿t/        | j
                  j0                  t        j2                  «      r5t        j2                  || j
                  j0                  j4                  ¬«      }| j7                  || j8                  «      }|j;                  |j=                  «       D �cg c]  }t        j                  |«      ‘Œ c}«       |j                  d   dkD  r|j+                  |«       t        j>                  |«      }t        j$                  |d| j                    ||d S c c}w c c}w )
z#Construct exog matrix for forecastsc                ó¤   — |dk(  r| S | j                   d   }t        j                  t        j                  ||ft        j                  «      | g«      S ©Nr   rR   )rj   rU   ÚvstackÚfullÚnan)rí   Úpadrt   s      rH   Úpad_xz"ARDL._forecasting_x.<locals>.pad_x�  sB   € Ø�aŠxØ�Ø—‘˜‘
ˆAÜ—9‘9œbŸg™g s¨A h´·±Ó7¸Ð;Ó<Ð<rJ   r   rR   N©Úaxisrî   r¾   ©rk   )rí   ú
np.ndarrayrþ   rT   Úreturnr  ) rº   r”   rj   r´   r�   r’   r`   rU   Úasarrayrû   r˜   rç   rè   Úout_of_samplerf   ÚconcatÚhstackrü   rý   r¯   r/   rµ   r¸   rS   rÆ   rg   rk   rÄ   r›   Úextendr£   rê   )rG   ÚstartÚendÚnum_oosr`   Úexog_oosr�   Ú	fixed_oosrÿ   rþ   Úadjusted_startÚdetÚoos_detr”   rí   Ú	endog_regr|   Úarrr�   s                      rH   Ú_forecasting_xzARDL._forecasting_xu  s§  € ó	=ð ˜DŸO™OÒ+‰a°·±À5Ñ1Hˆð �!‰G�t—z‘z×'Ñ'¨Ñ*Ò*¨t¨|ÀÀÜ  ¨¯©Ñ!8¸!Ó<ˆNÙØ—‘˜¨¨q©°4·?±?Ñ)BÐCÀSóð ð
 "& ˆt�y‰y�~Š~´2·:±:¸dÓ3CˆØÐÜ—9‘9˜d¤B§J¡J¨xÓ$8¸¸'Ð$BÐCÓDˆDØ$˜}�—’´"·*±*¸UÓ2CˆØÐ Ü—I‘I˜u¤b§j¡j°Ó&;¸H¸WÐ&EÐFÓGˆEØ×"Ñ"×,Ñ,Ó.ˆÙØ×*Ñ*×8Ñ8¸ÓAˆGÜ—)‘)˜S '˜N°Ô3ˆCØ—	‘	—‘ˆÙÜ—I‘I˜u¤b§g¡g¨g´r·v±vÓ&>Ð?Ó@ˆEØˆEˆØ�:Š:Ü˜u¤c¨$¯*©*£oÀÔEˆIØ�H‰H�Yšq°d·j±jÖ"A¨s 3¨£7Ò"AÐAÑBÔCØ�?‰?˜1˜2ÑÜ˜$Ÿ)™)×-Ñ-¬r¯|©|Ô<Ü—|‘| D°$·)±)×2EÑ2E×2MÑ2MÔN�Ø×$Ñ$ T¨4¯;©;Ó7ˆDØ�H‰H°·±³Ö?¨#”b—j‘j •oÒ?Ô@Ø�;‰;�q‰>˜AÒØ�H‰H�UŒOÜ�_‰_˜QÓˆÜ "§¡ˆÐˆT�_‰_ÐØ�%�&ˆzÐùò #Bùò
 @s   È#M!Ë$M&c	           	     óF  ‡ ‡— ‰ j                  |||||«      \  }}}}}}	ˆˆ fd„}
‰ j                  j                  j                  d   Š|� |
|d‰ j                  j                  d«      }|� |
|d‰ j                  j                  d«      }|� |
|d‰ j
                  d«      }|�( |
t        j                  |«      d	‰ j
                  d«      }‰ j
                  j                  d
   s‰ j                  sd}nƒ‰ j                  st        j                  nt        ‰ j                  «      }‰ j                  rFt        ‰ j                  j                  «       D �cg c]  }t        |«      ‘Œ c}«      }t        ||«      }|	|kD  r²‰ j                  r|€t        d«      ‚‰ j                  r*|j                  d   |z   |	k  rt        d|	|z
  › d|	› d�«      ‚‰ j
                  j                  d
   r|€t        d«      ‚‰ j
                  j                  d
   r$|j                  d   |	k  rt        d|	› d|	› d�«      ‚‰ j                  �¤|€¢|	r t        j                   |	‰ j                  j                  d
   ft        j"                  «      }t%        ‰ j                  j                  t&        j(                  «      r5t'        j(                  |‰ j                  j                  j*                  ¬«      }‰ j-                  |||	||||«      }|du r	|d
z   |z
  }n<‰ j/                  ||«      }|}|‰ j0                  k  rt3        |‰ j0                  |z
  «      }t        j                   |j                  d   t        j"                  «      }|d| |z  |d| ‰ j4                  j                  d
   }t7        ||j                  d   «      D ]V  }t9        ‰ j                  «      D ]1  \  }}||z
  }||k\  r||   }n‰ j                  ||z      }|||||z   f<   Œ3 ||   |z  ||<   ŒX ‰ j;                  |||d
z   |	z   d«      S c c}w )á£
  
        In-sample prediction and out-of-sample forecasting.

        Parameters
        ----------
        params : array_like
            The fitted model parameters.
        start : int, str, or datetime, optional
            Zero-indexed observation number at which to start forecasting,
            i.e., the first forecast is start. Can also be a date string to
            parse or a datetime type. Default is the the zeroth observation.
        end : int, str, or datetime, optional
            Zero-indexed observation number at which to end forecasting, i.e.,
            the last forecast is end. Can also be a date string to
            parse or a datetime type. However, if the dates index does not
            have a fixed frequency, end must be an integer index if you
            want out-of-sample prediction. Default is the last observation in
            the sample. Unlike standard python slices, end is inclusive so
            that all the predictions [start, start+1, ..., end-1, end] are
            returned.
        dynamic : {bool, int, str, datetime, Timestamp}, optional
            Integer offset relative to `start` at which to begin dynamic
            prediction. Prior to this observation, true endogenous values
            will be used for prediction; starting with this observation and
            continuing through the end of prediction, forecasted endogenous
            values will be used instead. Datetime-like objects are not
            interpreted as offsets. They are instead used to find the index
            location of `dynamic` which is then used to to compute the offset.
        exog : array_like
            A replacement exogenous array.  Must have the same shape as the
            exogenous data array used when the model was created.
        exog_oos : array_like
            An array containing out-of-sample values of the exogenous
            variables. Must have the same number of columns as the exog
            used when the model was created, and at least as many rows as
            the number of out-of-sample forecasts.
        fixed : array_like
            A replacement fixed array.  Must have the same shape as the
            fixed data array used when the model was created.
        fixed_oos : array_like
            An array containing out-of-sample values of the fixed variables.
            Must have the same number of columns as the fixed used when the
            model was created, and at least as many rows as the number of
            out-of-sample forecasts.

        Returns
        -------
        predictions : {ndarray, Series}
            Array of out of in-sample predictions and / or out-of-sample
            forecasts.
        c                ó>  •— t        |t        j                  «      rut        | t        j                  «      st        |› d�«      ‚t	        | j
                  «      t	        ‰j                  j                  j
                  «      k7  rt        |› d�«      ‚t        | |dd¬«      } | j                  dk7  s| j                  d   |j                  d   k7  rt        |› d|j                  d   › �«      ‚|r0| j                  d   |j                  d   k7  rt        |› d	‰› d
�«      ‚| S )Nz; must be a DataFrame when the original exog was a DataFramez0 must have the same columns as the original exogra   F)rc   ÚoptionalrR   z< must have the same number of columns as the original data, r   z9 must have the same number of rows as the original data (râ   )rS   rf   rg   rX   ro   rk   r’   rÆ   rW   r"   rc   rj   )r  ÚnameÚorigÚexactÚnrG   s       €€rH   Ú
check_exogz ARDL.predict.<locals>.check_exogï  s"  ø€ Ü˜$¤§¡Ô-Ü! #¤r§|¡|Ô4Ü#Ø˜&ð !*ð *óð ô ˜#Ÿ+™+Ó&¬&°·±×1DÑ1D×1LÑ1LÓ*MÒMÜ$Ø˜&ð !ð óð ô
 !  d°¸UÔC�Ø�x‰x˜1Š} §	¡	¨!¡°·
±
¸1±Ò =Ü Ø�fð &Ø&*§j¡j°¡m _ð6óð ñ ˜Ÿ™ 1™¨¯©°A©Ò6Ü Ø�fð &Ø&' S¨ð,óð ð ˆJrJ   r   Nr`   Tr  Fr�   r  rR   zoexog_oos must be provided when out-of-sample observations require values of the exog not in the original samplezexog_oos must have at least z observations to produce z, forecasts based on the model specification.zEfixed_oos must be provided when predicting out-of-sample observationszfixed_oos must have at least z forecasts.r  )Ú_prepare_predictionr’   r”   rj   rÆ   r˜   rU   r  r‘   r¯   Úinfr[   r›   r£   rW   r`   rü   rý   rS   rf   rg   rk   r  Ú_parse_dynamicrº   r´   ré   ri   Ú	enumerateÚ_wrap_prediction)rG   rÏ   r
  r  Údynamicr`   r  r�   r  r  r  Ú	max_1stepr]   Úmin_exogrí   Údynamic_startÚdynamic_stepÚfcastsÚoffsetr©   Újr|   Úlocrª   r  s   `                       @rH   ÚpredictzARDL.predict­  s  ù€ ð| 7;×6NÑ6NØ�D˜( E¨3ó7
Ñ3ˆ��h  s¨Gõ	ð4 �I‰I�O‰O×!Ñ! !Ñ$ˆØÐÙ˜d F¨D¯I©I×,?Ñ,?ÀÓFˆDØÐÙ!Ø˜* d§i¡i×&9Ñ&9¸5óˆHð ÐÙ˜u g¨t¯{©{¸DÓAˆEØÐ Ù"Ü—
‘
˜9Ó% {°D·K±KÀóˆIð
 �;‰;×Ñ˜QÒ t§|¢|Ø‰Ià&*§j¢jœŸš´c¸$¿*¹*³oˆIØ�{Š{Ü°·±×0BÑ0BÓ0DÖE¨1¤ A¥ÒEÓF�Ü 	¨8Ó4�	Ø�YÒØ�{Š{˜xÐ/Ü ð&óð ð
 —’ (§.¡.°Ñ"3°iÑ"?À7Ò!JÜ Ø2°7¸YÑ3FÐ2Gð H/Ø/6¨ið 8/ð/óð ð �{‰{× Ñ  Ò#¨	Ð(9Ü ð1óð ð —‘×"Ñ" 1Ò%¨)¯/©/¸!Ñ*<¸wÒ*FÜ Ø3°G°9ð ="Ø") ¨+ð7óð ð
 �9‰9Ð  XÐ%5¹'Ü—w‘w ¨¯©¯©¸Ñ);Ð<¼b¿f¹fÓEˆHÜ˜$Ÿ)™)×-Ñ-¬r¯|©|Ô<ÜŸ<™<Ø d§i¡i×&9Ñ&9×&AÑ&Aô�ð ×ÑØ�3˜  x°¸	ó
ˆð �eÑØ !™G e™O‰Mà×.Ñ.¨w¸Ó>ˆLØ(ˆMØ�t—‘Ò&Ü # M°4·?±?ÀUÑ3JÓ K�ä—‘˜Ÿ™ ™¤R§V¡VÓ,ˆØ!" > MÐ!2°VÑ!;ˆˆ~�ÐØ×(Ñ(×.Ñ.¨qÑ1ˆÜ�} f§l¡l°1¡oÓ6ò 		&ˆAÜ# D§J¡JÓ/ò '‘��3Ø˜#‘g�Ø˜-Ò'Ø  ™+‘Cð Ÿ*™* U¨S¡[Ñ1�CØ#&��!�V˜a‘Z�-Ò ð'ð ˜!™˜v™ˆF�1ŠIð		&ð ×$Ñ$ V¨U°C¸!±G¸gÑ4EÀqÓIÐIùòs  Fs   ÅP©r\   r‚   rƒ   r„   r…   rv   c               ó   — |j                   }d}d|v r$|j                  d«      \  }}|j                  «       }t        j                  |dz   |«      }|j
                  j                  }||_         |j
                  j                  }||_         |�^|j                  d«      d   j                  «       }|› d|› d�}t        j                  ||«      }|j
                  j                  }||_         nd} | ||||||||||	|
|¬«      S )	aM  
        Construct an ARDL from a formula

        Parameters
        ----------
        formula : str
            Formula with form dependent ~ independent | fixed. See Examples
            below.
        data : DataFrame
            DataFrame containing the variables in the formula.
        lags : {int, list[int]}
            The number of lags to include in the model if an integer or the
            list of lag indices to include.  For example, [1, 4] will only
            include lags 1 and 4 while lags=4 will include lags 1, 2, 3,
            and 4.
        order : {int, sequence[int], dict}
            If int, uses lags 0, 1, ..., order  for all exog variables. If
            sequence[int], uses the ``order`` for all variables. If a dict,
            applies the lags series by series. If ``exog`` is anything other
            than a DataFrame, the keys are the column index of exog (e.g., 0,
            1, ...). If a DataFrame, keys are column names.
        causal : bool, optional
            Whether to include lag 0 of exog variables.  If True, only
            includes lags 1, 2, ...
        trend : {'n', 'c', 't', 'ct'}, optional
            The trend to include in the model:

            * 'n' - No trend.
            * 'c' - Constant only.
            * 't' - Time trend only.
            * 'ct' - Constant and time trend.

            The default is 'c'.

        seasonal : bool, optional
            Flag indicating whether to include seasonal dummies in the model.
            If seasonal is True and trend includes 'c', then the first period
            is excluded from the seasonal terms.
        deterministic : DeterministicProcess, optional
            A deterministic process.  If provided, trend and seasonal are
            ignored. A warning is raised if trend is not "n" and seasonal
            is not False.
        hold_back : {None, int}, optional
            Initial observations to exclude from the estimation sample.  If
            None, then hold_back is equal to the maximum lag in the model.
            Set to a non-zero value to produce comparable models with
            different lag length.  For example, to compare the fit of a model
            with lags=3 and lags=1, set hold_back=3 which ensures that both
            models are estimated using observations 3,...,nobs. hold_back
            must be >= the maximum lag in the model.
        period : {None, int}, optional
            The period of the data. Only used if seasonal is True. This
            parameter can be omitted if using a pandas object for endog
            that contains a recognized frequency.
        missing : {"none", "drop", "raise"}, optional
            Available options are 'none', 'drop', and 'raise'. If 'none', no
            NaN checking is done. If 'drop', any observations with NaNs are
            dropped. If 'raise', an error is raised. Default is 'none'.

        Returns
        -------
        ARDL
            The ARDL model instance

        Examples
        --------
        A simple ARDL using the Danish data

        >>> from statsmodels.datasets.danish_data import load
        >>> from statsmodels.tsa.api import ARDL
        >>> data = load().data
        >>> mod = ARDL.from_formula("lrm ~ ibo", data, 2, 2)

        Fixed regressors can be specified using a |

        >>> mod = ARDL.from_formula("lrm ~ ibo | ide", data, 2, 2)
        Nú|z -1ú~r   z ~ z - 1)r‰   r�   r\   r‚   rƒ   r„   r…   rv   )ÚindexÚsplitÚstripr   Úfrom_formular’   rÆ   Ú
orig_endog)ÚclsÚformular’   r§   rO   r‰   r\   r‚   rƒ   r„   r…   rv   r1  Úfixed_formulaÚmodr`   r”   Ú
endog_namer�   s                      rH   r4  zARDL.from_formulaX  s  € ðz —
‘
ˆØˆØ�'‰>Ø%,§]¡]°3Ó%7Ñ"ˆG�]Ø)×/Ñ/Ó1ˆMÜ×Ñ˜w¨™°Ó5ˆØ�x‰x×!Ñ!ˆØˆŒ
Ø—‘×#Ñ#ˆØˆŒØÐ$Ø Ÿ™ sÓ+¨AÑ.×4Ñ4Ó6ˆJØ)˜l¨#¨m¨_¸DÐAˆMÜ×"Ñ" =°$Ó7ˆCØ),¯©×);Ñ);ˆEØˆE�KàˆEÙØØØØØØØØØ'ØØØô
ð 	
rJ   ©Nr   Úc)r”   z)Sequence[float] | pd.Series | ArrayLike2Dr§   úint | Sequence[int] | Noner`   úArrayLike2D | NonerO   Ú
_ARDLOrderr‰   úLiteral['n', 'c', 'ct', 'ctt']r�   r>  r\   Úboolr‚   rA  rƒ   úDeterministicProcess | Noner„   ú
int | Noner…   rC  rv   ú Literal['none', 'drop', 'raise']r  ÚNone)r  úNDArray | pd.DataFrame | None)r  rA  )r  zlist[int] | None©r  údict[Hashable, list[int]])r  ztuple[int, ...])r  rE  )r`   r   rO   rH  r  zdict[Hashable, np.ndarray])rO   r?  r  rH  )rÇ   NT)rÊ   r=   rË   údict[str, Any]rÌ   rA  r  z)tuple[np.ndarray, np.ndarray, np.ndarray])rÊ   r=   rË   rI  rÌ   rA  r  r1   ©r„   rC  r  ztuple[np.ndarray, np.ndarray])r
  rT   r  rT   r  rT   r`   r>  r  r>  r�   r>  r  r>  r  r  ©NNFNNNN)rÏ   r   r
  ú-int | str | dt.datetime | pd.Timestamp | Noner  rL  r#  rA  r`   rF  r  rF  r�   rF  r  rF  ©r   r   r  )r7  r=   r’   r:   r§   r=  rO   r?  r‰   r@  r\   rA  r‚   rA  rƒ   rB  r„   rC  r…   rC  rv   úLiteral['none', 'raise']r  zARDL | UECM)rE   rK   rL   Ú__doc__r�   Úpropertyr�   r\   r°   r²   r¸   r»   ÚstaticmethodrÄ   r^   rÕ   rÍ   rœ   r�   r  r,  Úclassmethodr4  Ú__classcell__©rD   s   @rH   r0   r0   ¹   s†  ø„ ñBðP $(ØØ03ðH3ð %)ØØØ59Ø $Ø!Ø4:ñH3à8ðH3ð )ðH3ð !ð	H3ð
 ðH3ð .ðH3ð "ðH3ð ðH3ð ðH3ð 3ðH3ð ðH3ð ðH3ð 2ðH3ð 
õH3ðT ò$ó ð$ð òó ðð ò6ó ð6ð òó ðð ò!ó ð!óGð ðØðØ";ðà	#òó ðó4Gð $Ø#'Øð	IàðIð !ðIð ð	Ið
 
3óIð2 $Ø#'ØñE'ð ðE'ð !ð	E'ð
 ðE'ð 
óE'ðN17Ø#ð17à	&ó17òfð86àð6ð ð6ð ð	6ð
 !ð6ð %ð6ð "ð6ð &ð6ð 
ó6ðv @DØ=AØØ.2Ø26Ø/3Ø37ðiJàðiJð =ðiJð ;ð	iJð
 ðiJð ,ðiJð 0ðiJð -ðiJð 1óiJðV ð
 ,-ØØ03ð{
ð ØØ59Ø $Ø!Ø,2ñ{
àð{
ð ð{
ð )ð	{
ð
 ð{
ð .ð{
ð ð{
ð ð{
ð 3ð{
ð ð{
ð ð{
ð *ð{
ð 
ò{
ó ô{
rJ   r0   ©r
  r  r#  r`   r  r�   r  é   c                  ó�  ‡ — e Zd ZdZi Z	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dˆ fd„Z e eej                  j                  d«      «      	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Z		 	 	 d	 	 	 	 	 	 	 dd„Z
dd„Z	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z ee¬«      	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	„«       Zddd
„Zˆ xZS )r1   a4  
    Class to hold results from fitting an ARDL model.

    Parameters
    ----------
    model : ARDL
        Reference to the model that is fit.
    params : ndarray
        The fitted parameters from the AR Model.
    cov_params : ndarray
        The estimated covariance matrix of the model parameters.
    normalized_cov_params : ndarray
        The array inv(dot(x.T,x)) where x contains the regressors in the
        model.
    scale : float, optional
        An estimate of the scale of the model.
    use_t : bool
        Whether use_t was set in fit
    rÏ   c                óŠ  •— t         ‰| �  |||||¬«       i | _        || _        |j                  | _        |j                  j                  d   | _        |j                  | _
        |j                  | _        d| _        | j                  rt        | j                  «      | _        | j                  j                   | _        || _        y )Nr×   r   )r�   r�   Ú_cacheÚ_paramsrÓ   Ú_nobsr”   rj   Ú	_n_totobsÚdf_modelÚ	_df_modelr°   Ú_ar_lagsÚ_max_lagr´   Úmodelr„   rº   Úcov_params_default)rG   ra  rÏ   rÎ   rÐ   rÔ   rÌ   rD   s          €rH   r�   zARDLResults.__init__ô  s¡   ø€ ô 	‰ÑØ�6Ð0°%¸uð 	ô 	
ð ˆŒØˆŒØ—Z‘ZˆŒ
ØŸ™×*Ñ*¨1Ñ-ˆŒØŸ™ˆŒØŸ™ˆŒØˆŒØ�=Š=Ü §¡Ó.ˆDŒMØŸ*™*×.Ñ.ˆŒØ",ˆÕrJ   c           
     ó\   — | j                   j                  | j                  |||||||¬«      S )NrU  )ra  r,  rZ  )rG   r
  r  r#  r`   r  r�   r  s           rH   r,  zARDLResults.predict  s<   € ð �z‰z×!Ñ!Ø�L‰LØØØØØØØð "ó 	
ð 		
rJ   c                óÞ   — | j                   j                  j                  j                  d   }t	        |t
        t        j                  f«      r	||z   dz
  }n|}| j                  ||d||¬«      S )aZ  
        Out-of-sample forecasts

        Parameters
        ----------
        steps : {int, str, datetime}, default 1
            If an integer, the number of steps to forecast from the end of the
            sample. Can also be a date string to parse or a datetime type.
            However, if the dates index does not have a fixed frequency,
            steps must be an integer.
        exog : array_like, optional
            Exogenous values to use out-of-sample. Must have same number of
            columns as original exog data and at least `steps` rows
        fixed : array_like, optional
            Fixed values to use out-of-sample. Must have same number of
            columns as original fixed data and at least `steps` rows

        Returns
        -------
        array_like
            Array of out of in-sample predictions and / or out-of-sample
            forecasts.

        See Also
        --------
        ARDLResults.predict
            In- and out-of-sample predictions
        ARDLResults.get_prediction
            In- and out-of-sample predictions and confidence intervals
        r   rR   F)r
  r  r#  r  r  )	ra  r’   r5  rj   rS   rT   rU   rV   r,  )rG   Ústepsr`   r�   r
  r  s         rH   ÚforecastzARDLResults.forecast"  sj   € ðH —
‘
—‘×*Ñ*×0Ñ0°Ñ3ˆÜ�eœc¤2§:¡:Ð.Ô/Ø˜%‘- !Ñ#‰CàˆCØ�|‰|Ø˜S¨%¸$È%ð ó 
ð 	
rJ   c                ó@  — | j                   �| j                   ng }t        |«      }t        j                  | j                  dz   «      }d|d<   | j
                  j                  j                  d   }| j                  |||z    }t        |«      D ]  \  }}||    ||<   Œ |S )ú6Returns poly repr of an AR, (1  -phi1 L -phi2 L^2-...)rR   r   )
r_  rY   rU   Úzerosr`  ra  ré   rj   rZ  r!  )rG   r°   Úk_arÚ	ar_paramsr)  rÏ   r©   r|   s           rH   Ú	_lag_reprzARDLResults._lag_reprO  sš   € à#'§=¡=Ð#<�$—-’-À"ˆÜ�7‹|ˆÜ—H‘H˜TŸ]™]¨QÑ.Ó/ˆ	Øˆ	�!‰Ø—‘×.Ñ.×4Ñ4°QÑ7ˆØ—‘˜f v°¡}Ð5ˆÜ Ó(ò 	(‰FˆAˆsØ$ Q™i˜ZˆI�cŠNð	(àÐrJ   c           	     ó”  — | j                  |||||||¬«      }t        j                  || j                  ¬«      }	t        j                  |	t        j
                  |«      <   |€dn|}|€| j                  j                  d   n|}| j                  j                  ||«      \  }
}
}}
|dkD  rZ| j                  «       }t        |t        j                  d«      |¬«      }| j                  t        j                  |dz  «      z  |	| d t        |t        j                  «      r!t        j                  |	|j                   ¬	«      }	t#        ||	«      S )
a!
  
        Predictions and prediction intervals

        Parameters
        ----------
        start : int, str, or datetime, optional
            Zero-indexed observation number at which to start forecasting,
            i.e., the first forecast is start. Can also be a date string to
            parse or a datetime type. Default is the the zeroth observation.
        end : int, str, or datetime, optional
            Zero-indexed observation number at which to end forecasting, i.e.,
            the last forecast is end. Can also be a date string to
            parse or a datetime type. However, if the dates index does not
            have a fixed frequency, end must be an integer index if you
            want out-of-sample prediction. Default is the last observation in
            the sample. Unlike standard python slices, end is inclusive so
            that all the predictions [start, start+1, ..., end-1, end] are
            returned.
        dynamic : {bool, int, str, datetime, Timestamp}, optional
            Integer offset relative to `start` at which to begin dynamic
            prediction. Prior to this observation, true endogenous values
            will be used for prediction; starting with this observation and
            continuing through the end of prediction, forecasted endogenous
            values will be used instead. Datetime-like objects are not
            interpreted as offsets. They are instead used to find the index
            location of `dynamic` which is then used to to compute the offset.
        exog : array_like
            A replacement exogenous array.  Must have the same shape as the
            exogenous data array used when the model was created.
        exog_oos : array_like
            An array containing out-of-sample values of the exogenous variable.
            Must has the same number of columns as the exog used when the
            model was created, and at least as many rows as the number of
            out-of-sample forecasts.
        fixed : array_like
            A replacement fixed array.  Must have the same shape as the
            fixed data array used when the model was created.
        fixed_oos : array_like
            An array containing out-of-sample values of the fixed variables.
            Must have the same number of columns as the fixed used when the
            model was created, and at least as many rows as the number of
            out-of-sample forecasts.

        Returns
        -------
        PredictionResults
            Prediction results with mean and prediction intervals
        rU  )Ú
fill_valueNr   éÿÿÿÿrR   )r§   ra   ©r1  )r,  rU   Ú	full_likeÚsigma2rý   Úisnanra  Ú_indexÚ_get_prediction_indexrl  r+   ÚonesÚcumsumrS   rf   ÚSeriesr1  r-   )rG   r
  r  r#  r`   r  r�   r  ÚmeanÚmean_varÚ_Úoosrk  Úmas                 rH   Úget_predictionzARDLResults.get_prediction[  s  € ðt �|‰|ØØØØØØØð ó 
ˆô —<‘< °·±Ô=ˆÜ#%§6¡6ˆ”—‘˜$“Ñ Ø�]‘¨ˆØ'* {ˆd�j‰j×Ñ Ò#¸ˆØ—z‘z×7Ñ7¸¸sÓC‰ˆˆ1ˆc�1Ø�Š7ØŸ™Ó(ˆIÜ˜¤B§G¡G¨A£J°SÔ9ˆBØ"Ÿk™k¬B¯I©I°b¸!±eÓ,<Ñ<ˆH�c�T�UˆOÜ�dœBŸI™IÔ&Ü—y‘y °·±Ô<ˆHä   xÓ0Ð0rJ   )Úpredict_paramsc           	     ó`   — | j                  |||||||¬«      }| j                  |||||	|
|«      S )a1  
        Plot in- and out-of-sample predictions

        Parameters
        ----------
%(predict_params)s
        alpha : {float, None}
            The tail probability not covered by the confidence interval. Must
            be in (0, 1). Confidence interval is constructed assuming normally
            distributed shocks. If None, figure will not show the confidence
            interval.
        in_sample : bool
            Flag indicating whether to include the in-sample period in the
            plot.
        fig : Figure
            An existing figure handle. If not provided, a new figure is
            created.
        figsize: tuple[float, float]
            Tuple containing the figure size values.

        Returns
        -------
        Figure
            Figure handle containing the plot.
        rU  )r~  Ú_plot_predictions)rG   r
  r  r#  r`   r  r�   r  Úalpharè   ÚfigÚfigsizeÚpredictionss                rH   Úplot_predictzARDLResults.plot_predict¬  sS   € ðN ×)Ñ)ØØØØØØØð *ó 
ˆð ×%Ñ%Ø˜  U¨I°s¸Gó
ð 	
rJ   c           	     ó*  — | j                   }|j                  j                  dz   }d}| j                  }| j                  j
                  �G| j                  j
                  }||   j                  d«      g}|d|d   j                  d«      z   gz  }n3t        |«      t        t        | j                  j                  «      «      g}| j                   j                  j                  t        | j                   j                  «      z   }| j                   j                  rd|z   }t        | j                   j                  «      }d|gfd|gfd	|gfd
dd|d   gfd|d   gfg}	dt        t        | j                   j                  «      «      gfdd| j                  z  gfdd| j                  dz  z  gfdd| j                   z  gfdd| j"                  z  gfdd| j$                  z  gfg}
t'        «       }|j)                  | |	|
|¬«       |j+                  | |d¬«       |S )a£  
        Summarize the Model

        Parameters
        ----------
        alpha : float, optional
            Significance level for the confidence intervals.

        Returns
        -------
        Summary
            This holds the summary table and text, which can be printed or
            converted to various output formats.

        See Also
        --------
        statsmodels.iolib.summary.Summary
        z Model ResultszConditional MLEz%m-%d-%Yz- ro  zSeas. zDep. Variable:zModel:zMethod:)zDate:N)zTime:NzSample:r   Ú rR   zNo. Observations:zLog Likelihoodz%#5.3fzS.D. of innovationsg      à?ÚAICÚBICÚHQIC)ÚgleftÚgrightÚtitleF)r‚  rÌ   )ra  rD   rE   rº   r’   ÚdatesÚstrftimer=   rY   r5  r¸   r‚   Úendog_namesr”   Úllfrr  ÚaicÚbicÚhqicr   Úadd_table_2colsÚadd_table_params)rG   r‚  ra  rŽ  Úmethodr
  r�  ÚsampleÚdep_nameÚtop_leftÚ	top_rightÚsmrys               rH   ÚsummaryzARDLResults.summaryà  s  € ð& —
‘
ˆà—‘×(Ñ(Ð+;Ñ;ˆØ"ˆà—‘ˆØ�9‰9�?‰?Ð&Ø—I‘I—O‘OˆEØ˜E‘l×+Ñ+¨JÓ7Ð8ˆFØ�t˜e B™i×0Ñ0°Ó<Ñ<Ð=Ñ=‰Fä˜%“j¤#¤c¨$¯)©)×*>Ñ*>Ó&?Ó"@ÐAˆFØ—
‘
×$Ñ$×-Ñ-´°D·J±J×4IÑ4IÓ0JÑJˆØ�:‰:×ÒØ˜uÑ$ˆEä�t—z‘z×-Ñ-Ó.ˆà ˜zÐ*Ø˜�wÐØ˜˜Ð!ØØØ˜ ™˜Ð$Ø�&˜‘)�Ðð
ˆð !¤3¤s¨4¯:©:×+;Ñ+;Ó'<Ó#=Ð">Ð?Ø ¨4¯8©8Ñ 3Ð4Ð5Ø" X°·±¸SÑ0@Ñ%@Ð$AÐBØ�X §¡Ñ(Ð)Ð*Ø�X §¡Ñ(Ð)Ð*Ø�h §¡Ñ*Ð+Ð,ð
ˆ	ô ‹yˆØ×ÑØ˜¨¸%ð 	ô 	
ð 	×Ñ˜d¨%°uÐÔ=àˆrJ   )Nç      ð?F)ra  r0   rÏ   r  rÎ   r  rÐ   zFloat64Array | NonerÔ   r8   rÌ   rA  rK  )r
  rL  r  rL  r#  rA  r`   rF  r  rF  r�   rF  r  rF  )rR   NN)re  rT   r`   rF  r�   rF  r  únp.ndarray | pd.Series)r  r  )r
  rL  r  rL  r#  rA  r`   rF  r  rF  r�   rF  r  rF  r  r   )NNFNNNNçš™™™™™©?TNN)r
  rL  r  rL  r#  rA  r`   rF  r  rF  r�   rF  r  rF  r‚  r8   rè   rA  rƒ  úmatplotlib.figure.Figurer„  ztuple[int, int] | Noner  r¢  ©r¡  ©r‚  r8   r  r   )rE   rK   rL   rO  rY  r�   r   r   r0   r,  rf  rl  r~  r   Ú_predict_paramsr†  rž  rS  rT  s   @rH   r1   r1   Ý  sS  ø„ ñð( €Fð 6:ØØð-àð-ð ð-ð ð	-ð
  3ð-ð ð-ð õ-ñ0 Ñ §¡× 4Ñ 4°hÓ?Ó@ð @DØ=AØØ.2Ø26Ø/3Ø37ð
à<ð
ð ;ð
ð ð	
ð
 ,ð
ð 0ð
ð -ð
ð 1ò
ó Að
ð. Ø.2Ø/3ð	+
àð+
ð ,ð+
ð -ð	+
ð
 
 ó+
óZ
ð @DØ=AØØ.2Ø26Ø/3Ø37ðO1à<ðO1ð ;ðO1ð ð	O1ð
 ,ðO1ð 0ðO1ð -ðO1ð 1ðO1ð 
 óO1ñb  Ô1ð @DØ=AØØ.2Ø26Ø/3Ø37ØØØ(,Ø*.ð1
à<ð1
ð ;ð1
ð ð	1
ð
 ,ð1
ð 0ð1
ð -ð1
ð 1ð1
ð ð1
ð ð1
ð &ð1
ð (ð1
ð 
"ò1
ó 2ð1
÷f=ð =rJ   r1   c                  ó°   — e Zd Zi Z ej
                  ej                  j                  e«      Zi Z	 ej
                  ej                  j                  e	«      Z
y)r¥   N©rE   rK   rL   Ú_attrsÚwrapÚunion_dictsr,   ÚTimeSeriesResultsWrapperÚ_wrap_attrsÚ_methodsÚ_wrap_methodsrN   rJ   rH   r¥   r¥      óT   „ Ø€FØ"�$×"Ñ"Ø×*Ñ*×6Ñ6¸ó€Kð €HØ$�D×$Ñ$Ø×*Ñ*×8Ñ8¸(ó�MrJ   r¥   c                  ó4   ‡ — e Zd ZdZˆ fd„Zedd„«       Zˆ xZS )r3   zr
    Results from an ARDL order selection

    Contains the information criteria for all fitted model orders.
    c           
     óÞ  •— d}t         ‰
| �  |||||«       d„ }t        j                  |j	                  «       D ��	ci c]  \  }}	|	d    ||«      “Œ c}	}t
        ¬«      | _        dx| j                  j                  _        | j                  _        | j                  j                  «       | _        t        j                  |j	                  «       D ��	ci c]  \  }}	|	d    ||«      “Œ c}	}t
        ¬«      | _
        dx| j                  j                  _        | j                  _        | j                  j                  «       | _
        t        j                  |j	                  «       D ��	ci c]  \  }}	|	d    ||«      “Œ c}	}t
        ¬«      | _        d	x| j                  j                  _        | j                  _        | j                  j                  «       | _        y c c}	}w c c}	}w c c}	}w )
N))rˆ   )r   r   r   c                ó(   — | d   t        | dd  «      fS rú   )Údict)Úds    rH   Ú_to_dictz4ARDLOrderSelectionResults.__init__.<locals>._to_dict9  s   € Ø�Q‘4œ˜a  ˜e›Ð$Ð$rJ   r   ©Údtyper‰  rR   rŠ  ra   r‹  )r�   r�   rf   rx  ÚitemsÚobjectÚ_aicr1  r  Ú
sort_indexÚ_bicÚ_hqic)rG   ra  Úicsr‰   r‚   r…   Ú_icsrµ  rt   r]   rD   s             €rH   r�   z"ARDLOrderSelectionResults.__init__5  sm  ø€ Ø#ˆÜ‰Ñ˜  e¨X°vÔ>ò	%ô —I‘IØ+.¯9©9«;×7¡4 1 aˆQˆq‰T‘8˜A“;ÑÓ7¼vô
ˆŒ	ð 16Ð5ˆ�	‰	�‰Ô˜tŸy™yœ~Ø—I‘I×(Ñ(Ó*ˆŒ	ä—I‘IØ+.¯9©9«;×7¡4 1 aˆQˆq‰T‘8˜A“;ÑÓ7¼vô
ˆŒ	ð 16Ð5ˆ�	‰	�‰Ô˜tŸy™yœ~Ø—I‘I×(Ñ(Ó*ˆŒ	ä—Y‘YØ+.¯9©9«;×7¡4 1 aˆQˆq‰T‘8˜A“;ÑÓ7¼vô
ˆŒ
ð 39Ð8ˆ�
‰
×ÑÔ §
¡
¤Ø—Z‘Z×*Ñ*Ó,ˆ�
ùó 8ùó 8ùó 8s   ¼G
ÃG#
Å(G)
c                ó.   — | j                   j                  S )z5The lags of exogenous variables in the selected model)Ú_modelr²   rF   s    rH   r²   z!ARDLOrderSelectionResults.dl_lagsN  s   € ð �{‰{×"Ñ"Ð"rJ   rG  )rE   rK   rL   rO  r�   rP  r²   rS  rT  s   @rH   r3   r3   .  s!   ø„ ñô-ð2 ò#ó ô#rJ   r3   Fr”  r   )	r�   r\   ÚicÚglobr‚   rƒ   r„   r…   rv   rT   c       	        óÜ  — t        |dd¬«      }d„ }t        | |||||||	|
|||¬«      }|j                  }|j                  }t	        j
                  |d   |d   g«      }||d }g }g }|j                  |d	   |d «       |j                  t        t        |d	   j                  d
   d
z   «      «      «       g }|d   D ]b  }|d   |   |d }|j                  |«       |j                  t        t        |j                  d
   d
z   «      «      «       |j                  |«       Œd |j                  }|j                  d
   rVt        j                  j                  |«      }t        t        |«      «      D ]  }||   }||||z  z  z
  ||<   Œ ||||z  z  z
  }d„ }|j                  d
   }i }|rò|j                  �|j                  ng }|D �cg c]  }d|f‘Œ } }|j                  j!                  «       D ]  \  }!}"| |"D �cg c]  }|!|f‘Œ c}z  } Œ t	        j
                  |D �#cg c]  }#|#‘Œ c}#«      }t        t        |j                  d
   «      «      }$t        |j                  d
   «      D ]0  }t#        |$|«      D ]  }% || |%«      }& |||dd…|%f   |«      ||&<   Œ! Œ2 nÇt%        |Ž D ]¼  }'t	        j
                  t'        |«      D ��#cg c]  \  }}#|#dd…d|'|   …f   ‘Œ c}#}«      }|'d   r|'d   ndg}&t'        |'d
d «      D ]G  \  }(})||(   }|r|&j                  ||)dk(  rdn|)f«       Œ(|&j                  ||)d
z
  dk\  r|)d
z
  ndf«       ŒI t)        |&«      }& ||||«      ||&<   Œ¾ dd
ddœ|   }*t        j*                  }+|D ]  }&||&   |*   })|)|+k  sŒ|)}+|&},Œ ,d
d D �!�"ci c]  \  }!}"|!|"“Œ
 }-}!}"t        | |,d   ||-||||	|
|||¬«      }.t-        |.|||	|«      S c c}w c c}w c c}#w c c}#}w c c}"}!w )a  
    ARDL order selection

    Parameters
    ----------
    endog : array_like
        A 1-d endogenous response variable. The dependent variable.
    maxlag : int
        The maximum lag to consider for the endogenous variable.
    exog : array_like
        Exogenous variables to include in the model. Either a DataFrame or
        an 2-d array-like structure that can be converted to a NumPy array.
    maxorder : {int, dict}
        If int, sets a common max lag length for all exog variables. If
        a dict, then sets individual lag length. They keys are column names
        if exog is a DataFrame or column indices otherwise.
    trend : {'n', 'c', 't', 'ct'}, optional
        The trend to include in the model:

        * 'n' - No trend.
        * 'c' - Constant only.
        * 't' - Time trend only.
        * 'ct' - Constant and time trend.

        The default is 'c'.
    fixed : array_like
        Additional fixed regressors that are not lagged.
    causal : bool, optional
        Whether to include lag 0 of exog variables.  If True, only includes
        lags 1, 2, ...
    ic : {"aic", "bic", "hqic"}
        The information criterion to use in model selection.
    glob : bool
        Whether to consider all possible submodels of the largest model
        or only if smaller order lags must be included if larger order
        lags are.  If ``True``, the number of model considered is of the
        order 2**(maxlag + k * maxorder) assuming maxorder is an int. This
        can be very large unless k and maxorder are bot relatively small.
        If False, the number of model considered is of the order
        maxlag*maxorder**k which may also be substantial when k and maxorder
        are large.
    seasonal : bool, optional
        Flag indicating whether to include seasonal dummies in the model. If
        seasonal is True and trend includes 'c', then the first period
        is excluded from the seasonal terms.
    deterministic : DeterministicProcess, optional
        A deterministic process.  If provided, trend and seasonal are ignored.
        A warning is raised if trend is not "n" and seasonal is not False.
    hold_back : {None, int}, optional
        Initial observations to exclude from the estimation sample.  If None,
        then hold_back is equal to the maximum lag in the model.  Set to a
        non-zero value to produce comparable models with different lag
        length.  For example, to compare the fit of a model with lags=3 and
        lags=1, set hold_back=3 which ensures that both models are estimated
        using observations 3,...,nobs. hold_back must be >= the maximum lag in
        the model.
    period : {None, int}, optional
        The period of the data. Only used if seasonal is True. This parameter
        can be omitted if using a pandas object for endog that contains a
        recognized frequency.
    missing : {"none", "drop", "raise"}, optional
        Available options are 'none', 'drop', and 'raise'. If 'none', no NaN
        checking is done. If 'drop', any observations with NaNs are dropped.
        If 'raise', an error is raised. Default is 'none'.

    Returns
    -------
    ARDLSelectionResults
        A results holder containing the selected model and the complete set
        of information criteria for all models fit.
    r„   T)r  c                ó  — |j                   d   r,| |t        j                  j                  || d ¬«      d   z  z
  }n| }|j                   d   }d|z  t	        |«      z  }| t        j
                  dt        j                  z  |z  «      dz   z  dz  }t        |||j                   d   z   ||¬«      }t        t        j                  |«      }t        t        j                  |«      }	t        t        j                  |«      }
||	|
fS )NrR   )Úrcondr   rŸ  ra   )rÓ   r]  rr  r’  )rj   rU   ÚlinalgÚlstsqr)   ÚlogÚpir
   r   r1   r“  r”  r•  )Úyrí   ÚdfÚresidrÓ   rr  r’  rÚ   r“  r”  r•  s              rH   Úcompute_icsz&ardl_select_order.<locals>.compute_ics®  sã   € Ø�7‰7�1Š:Ø˜œBŸI™IŸO™O¨A¨q¸˜OÓ=¸aÑ@Ñ@Ñ@‰EàˆEØ�{‰{˜1‰~ˆØ�t‘œg e›nÑ,ˆØˆe”r—v‘v˜a¤"§%¡%™i¨&Ñ0Ó1°AÑ5Ñ6¸Ñ:ˆÜØ  Q§W¡W¨Q¡Z¡¸ÀCô
ˆô œ{Ÿ™°Ó4ˆÜœ{Ÿ™°Ó4ˆÜ¤× 0Ñ 0°#Ó6ˆà�C˜ˆ~ÐrJ   r€   rƒ   r�   Nr”   rR   r`   c                ó0  — |dk(  r;| D ��ci c]  \  }}|€Œ	|d“Œ }}}dt        d„ |j                  «       D «       «      z   S t        t        «      }g }|D ];  }| |   }|d   €|j	                  |d   «       Œ"||d      j	                  |d   «       Œ= t        |«      }|r|dgk(  rd}nt        |«      }| D ]  }|d   |vsŒ|d   €Œd ||d   <   Œ |D ]  }||   €Œ	t        ||   «      ||<   Œ |ft        d„ |j                  «       D «       «      z   S c c}}w )NrN   r   rˆ   c              3  ó*   K  — | ]  \  }}||f–— Œ y ­w©NrN   ©Ú.0rt   r]   s      rH   ú	<genexpr>z;ardl_select_order.<locals>.perm_to_tuple.<locals>.<genexpr>ç  s   è ø€ Ò=©4¨1¨a  A¤Ñ=ùó   ‚rR   c              3  ó*   K  — | ]  \  }}||f–— Œ y ­wrÑ  rN   rÒ  s      rH   rÔ  z;ardl_select_order.<locals>.perm_to_tuple.<locals>.<genexpr>û  s   è ø€ Ò >©D¨A¨q ! Q¤Ñ >ùrÕ  )r¶   r¸  r   rh   rµ   r³  )rm   Úpermrt   r{  r´  Úy_lagsr]   ry   s           rH   Úperm_to_tuplez(ardl_select_order.<locals>.perm_to_tupleä  sC  € Ø�2Š:Ø"&×8™$˜!˜Q¨!©-��A‘Ð8ˆAÑ8Øœ%Ñ=°1·7±7³9Ô=Ó=Ñ=Ð=ÜœÓˆØˆØò 	)ˆAØ�q‘'ˆCØ�1‰vˆ~Ø—‘˜c !™fÕ%à�#�a‘&‘	× Ñ   Q¡Õ(ð	)ô �‹GˆÙ˜ A 3šØ‰Fä˜6“]ˆFØò 	!ˆCØ�1‰v˜QŠ 3 q¡6Ñ#5Ø ��#�a‘&’	ð	!ð ò 	'ˆCØ�‰vÑ!Ü˜q ™v›��#’ð	'ð ˆyœ5Ñ >°A·G±G³IÔ >Ó>Ñ>Ð>ùó+ 9s
   ‹
D–Dr   ra   )r“  r”  r•  )r%   r0   r„   r™   rU   rê   rµ   rh   ri   rj   rŽ   rÇ  ÚpinvrY   r°   r›   r¸  r   r	   r!  r¶   r  r3   )/r”   Úmaxlagr`   Úmaxorderr‰   r�   r\   rÂ  rÃ  r‚   rƒ   r„   r…   rv   Úorig_hold_backrÎ  rö   ÚblocksÚalwaysÚselectÚiter_ordersÚ	var_namesÚvarÚblockrË  Úpinv_alwaysr©   rí   rÙ  Ú	always_dfr¾  r°   rm   rt   r]   ÚaÚall_columnsr×  ry   Úior*  rª   r1  ÚlowestÚselected_orderru   ra  s/                                                  rH   r2   r2   T  si  € ôp ˜i¨¸tÔD€Nòô$ ØØØØØØØØØ#ØØØô€Dð —‘€IØ�\‰\€FÜ�_‰_˜f _Ñ5°v¸g±ÐGÓH€FØ�I�JÐ€FØ€FØ€KØ
‡M�M�&˜‘/ ) *Ð-Ô.Ø×Ñ”tœE &¨¡/×"7Ñ"7¸Ñ":¸QÑ">Ó?Ó@ÔAØ€IØ�f‰~ò ˆØ�v‘˜sÑ# I JÐ/ˆØ�‰�eÔØ×Ñœ4¤ e§k¡k°!¡n°qÑ&8Ó 9Ó:Ô;Ø×Ñ˜Õð	ð
 	�‰€AØ‡|�|�A‚Ü—i‘i—n‘n VÓ,ˆÜ”s˜6“{Ó#ò 	7ˆAØ�q‘	ˆAØ˜F k°A¡oÑ6Ñ6ˆF�1ŠIð	7ð �˜+¨™/Ñ*Ñ*ˆò?ð2 —‘˜Q‘€IØ
€CÙØ"&§,¡,Ð":�$—,’,ÀˆØ#*Ö+˜a��q’	Ð+ˆÐ+Ø—K‘K×%Ñ%Ó'ò 	(‰DˆAˆqØ QÖ' �a˜’VÒ'Ñ'‰Dð	(ä�O‰O¨Ö/ 1šQÒ/Ó0ˆÜœ5 §¡¨¡Ó,Ó-ˆÜ�q—w‘w˜q‘zÓ"ò 	AˆAÜ$ [°!Ó4ò A�Ù# D¨$Ó/�Ù& q¨!ªA¨t¨G©*°iÓ@��C’ñAñ	Aô
 ˜;Ð'ò 
	4ˆBÜ—‘¼9ÀVÓ;L× M±4°1°a ¢1 g¨¨1© g :£Ó MÓNˆAØ˜qšE�2�a’5 tÐ,ˆCÜ# B q r FÓ+ò I‘��3Ø ‘l�ÙØ—J‘J ¨S°AªX¡T¸3Ð?Õ@à—J‘J °°a±¸1² S¨1¢WÀ$ÐGÕHðIô ˜“*ˆCÙ" 1 a¨Ó3ˆC�ŠHð
	4ð ˜a¨Ñ+¨BÑ/€EÜ�V‰V€FØò !ˆØ�#‰h�u‰oˆØ�‹<ØˆFØ ‰Nð	!ð
 $2°!°"Ð#5×6™4˜1˜a�!�Q‘$Ð6€JÑ6ÜØØ�qÑØØØØØØØ#Ø ØØô€Eô % U¨C°¸À&ÓIÐIùòY ,ùâ'ùÚ/ùó !Nùó" 7s   ÇOÇ7OÈ	OËO"ÎO(zZThe number of lags of the endogenous variable to include in the model. Must be at least 1.éG   r§   )r  ÚtypeÚdesczùIf int, uses lags 0, 1, ..., order  for all exog variables. If a dict, applies the lags series by series. If ``exog`` is anything other than a DataFrame, the keys are the column index of exog (e.g., 0, 1, ...). If a DataFrame, keys are column names.z	int, dictr   z Construct an UECM from a formular’   ÚReturnsrˆ  r5   zEstimation results.zSee Also)zstatsmodels.tsa.ardl.ARDLNz/Autoregressive distributed lag model estimationc            
      óð  ‡ — e Zd ZdZ	 	 	 dddddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„Z	 	 	 	 	 	 dˆ fd„Zdˆ fd„Zd	„ Z	 	 	 	 dd
„Z e	 e
e«      «      ddddœ	 	 	 	 	 	 	 dd„«       Ze	 d	 	 	 dd„«       Z	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Ze e	ej#                  «       j%                  dd «      «      	 	 	 ddddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„«       «       Zˆ xZS ) r4   a‚  
    Unconstrained Error Correlation Model(UECM)

    Parameters
    ----------
    endog : array_like
        A 1-d endogenous response variable. The dependent variable.
    lags : {int, list[int]}
        The number of lags of the endogenous variable to include in the
        model. Must be at least 1.
    exog : array_like
        Exogenous variables to include in the model. Either a DataFrame or
        an 2-d array-like structure that can be converted to a NumPy array.
    order : {int, sequence[int], dict}
        If int, uses lags 0, 1, ..., order  for all exog variables. If a
        dict, applies the lags series by series. If ``exog`` is anything
        other than a DataFrame, the keys are the column index of exog
        (e.g., 0, 1, ...). If a DataFrame, keys are column names.
    fixed : array_like
        Additional fixed regressors that are not lagged.
    causal : bool, optional
        Whether to include lag 0 of exog variables.  If True, only includes
        lags 1, 2, ...
    trend : {'n', 'c', 't', 'ct'}, optional
        The trend to include in the model:

        * 'n' - No trend.
        * 'c' - Constant only.
        * 't' - Time trend only.
        * 'ct' - Constant and time trend.

        The default is 'c'.

    seasonal : bool, optional
        Flag indicating whether to include seasonal dummies in the model. If
        seasonal is True and trend includes 'c', then the first period
        is excluded from the seasonal terms.
    deterministic : DeterministicProcess, optional
        A deterministic process.  If provided, trend and seasonal are ignored.
        A warning is raised if trend is not "n" and seasonal is not False.
    hold_back : {None, int}, optional
        Initial observations to exclude from the estimation sample.  If None,
        then hold_back is equal to the maximum lag in the model.  Set to a
        non-zero value to produce comparable models with different lag
        length.  For example, to compare the fit of a model with lags=3 and
        lags=1, set hold_back=3 which ensures that both models are estimated
        using observations 3,...,nobs. hold_back must be >= the maximum lag in
        the model.
    period : {None, int}, optional
        The period of the data. Only used if seasonal is True. This parameter
        can be omitted if using a pandas object for endog that contains a
        recognized frequency.
    missing : {"none", "drop", "raise"}, optional
        Available options are 'none', 'drop', and 'raise'. If 'none', no NaN
        checking is done. If 'drop', any observations with NaNs are dropped.
        If 'raise', an error is raised. Default is 'none'.

    Notes
    -----
    The full specification of an UECM is

    .. math ::

       \Delta Y_t = \delta_0 + \delta_1 t + \delta_2 t^2
             + \sum_{i=1}^{s-1} \gamma_i I_{[(\mod(t,s) + 1) = i]}
             + \lambda_0 Y_{t-1} + \lambda_1 X_{1,t-1} + \ldots
             + \lambda_{k} X_{k,t-1}
             + \sum_{j=1}^{p-1} \phi_j \Delta Y_{t-j}
             + \sum_{l=1}^k \sum_{m=0}^{o_l-1} \beta_{l,m} \Delta X_{l, t-m}
             + Z_t \lambda
             + \epsilon_t

    where :math:`\delta_\bullet` capture trends, :math:`\gamma_\bullet`
    capture seasonal shifts, s is the period of the seasonality, p is the
    lag length of the endogenous variable, k is the number of exogenous
    variables :math:`X_{l}`, :math:`o_l` is included the lag length of
    :math:`X_{l}`, :math:`Z_t` are ``r`` included fixed regressors and
    :math:`\epsilon_t` is a white noise shock. If ``causal`` is ``True``,
    then the 0-th lag of the exogenous variables is not included and the
    sum starts at ``m=1``.

    See Also
    --------
    statsmodels.tsa.ardl.ARDL
        Autoregressive distributed lag model estimation
    statsmodels.tsa.ar_model.AutoReg
        Autoregressive model estimation with optional exogenous regressors
    statsmodels.tsa.statespace.sarimax.SARIMAX
        Seasonal ARIMA model estimation with optional exogenous regressors
    statsmodels.tsa.arima.model.ARIMA
        ARIMA model estimation

    Examples
    --------
    >>> from statsmodels.tsa.api import UECM
    >>> from statsmodels.datasets import danish_data
    >>> data = danish_data.load_pandas().data
    >>> lrm = data.lrm
    >>> exog = data[["lry", "ibo", "ide"]]

    A basic model where all variables have 3 lags included

    >>> UECM(data.lrm, 3, data[["lry", "ibo", "ide"]], 3)

    A dictionary can be used to pass custom lag orders

    >>> UECM(data.lrm, [1, 3], exog, {"lry": 1, "ibo": 3, "ide": 2})

    Setting causal removes the 0-th lag from the exogenous variables

    >>> exog_lags = {"lry": 1, "ibo": 3, "ide": 2}
    >>> UECM(data.lrm, 3, exog, exog_lags, causal=True)

    When using NumPy arrays, the dictionary keys are the column index.

    >>> import numpy as np
    >>> lrma = np.asarray(lrm)
    >>> exoga = np.asarray(exog)
    >>> UECM(lrma, 3, exoga, {0: 1, 1: 3, 2: 2})
    NFr   r€   c               óh   •— t         ‰| �  |||||||||
|||	¬«       t        | _        t        | _        y )N)r‰   r�   r‚   r\   r„   r…   rv   rƒ   )r�   r�   r5   r¤   ÚUECMResultsWrapperr¦   )rG   r”   r§   r`   rO   r‰   r�   r\   r‚   rƒ   r„   r…   rv   rD   s                €rH   r�   zUECM.__init__Ò  sM   ø€ ô  	‰ÑØØØØØØØØØØØØ'ð 	ô 	
ô *ˆÔÜ 2ˆÕrJ   c                ó^   •— t        |t        «      s|�t        d«      ‚t        ‰| �  ||«      S )z(Check lags value conforms to requirementzlags must be an integer or None)rS   rr   rX   r�   Ú_check_lags)rG   r§   r„   rD   s      €rH   rô  zUECM._check_lagsó  s1   ø€ ô ˜4¤Ô,°°ÜÐ=Ó>Ð>Ü‰wÑ" 4¨Ó3Ð3rJ   c                óZ  •— t        |t        «      r7|j                  «       D ]#  \  }}t        |t        «      rŒ|€Œt	        d«      ‚ nt        |t        «      s|�t	        d«      ‚t
        ‰| �  |«      }|st        d«      ‚|j                  «       D ]  \  }}|dgk(  sŒt        d«      ‚ |S )z#Check order conforms to requirementz.order values must be positive integers or NonezVorder must be None, a positive integer, or a dict containing positive integers or Nonez2Model must contain at least one exogenous variabler   z7All included exog variables must have a lag length >= 1)rS   r   r¸  rr   rX   r�   r^   rW   )rG   rO   rt   r]   ry   rª   rD   s         €rH   r^   zUECM._check_orderû  sÅ   ø€ ä�eœWÔ%ØŸ™›ò ‘��1Ü! !¤ZÕ0°Q±]Ü#ØHóð ñô
 ˜U¤JÔ/°5°=Üð7óð ô
 ‘Ñ$ UÓ+ˆÙÜØDóð ð Ÿ™›ò 	‰HˆC�Ø�q�c‹zÜ ØMóð ð	ð
 ˆrJ   c                ó®  — | j                   j                  }t        |t        j                  «      r|j
                  xs d}n;t        |t        j                  «      r|j                  «       j
                  xs d}nd}d|› �}t        | j                  j                  «      }|j                  |› d�«       | j                   j                  }t        |t        j                  «      }g }| j                  j                  «       D ]L  \  }}	|	€Œ	|r|› d�}
nd|› d�}
|j                  |
«       |
dd }|	dd D ]  }|j                  d|› |› �«       Œ ŒN | j                  rt!        | j                  «      nd}t#        d|«      D �cg c]	  }|› d	|› �‘Œ }}|j%                  |«       |j%                  |«       |j%                  | j&                  «       ||fS c c}w )
rñ   rË  zD.ú.L1Nrí   ro  r   rR   rò   )r’   r5  rS   rf   rx  r  rg   Úsqueezerh   ré   rk   rµ   rÆ   r›   r¸  r¯   r´   ri   r	  r—   )rG   r”   Úy_baseró   r÷   rÆ   Úexog_pandasÚdexog_namesry   rª   Úx_nameÚlag_baser|   rØ  Údendog_namess                  rH   r�   zUECM._construct_variable_names  s¨  € à—	‘	×$Ñ$ˆÜ�eœRŸY™YÔ'Ø—Z‘ZÒ& 3‰FÜ˜œrŸ|™|Ô,Ø—]‘]“_×)Ñ)Ò0¨S‰FàˆFØ�f�X�ˆä�t×.Ñ.×6Ñ6Ó7ˆà�‰˜&˜ �~Ô&Ø—I‘I×'Ñ'ˆ	Ü  ¬B¯L©LÓ9ˆØˆØŸ™×)Ñ)Ó+ò 		=‰HˆC�Ø‰ÙØ #˜u C˜[‘Fà    S˜\�FØ—‘˜vÔ&Ø! # 2˜;�Ø˜s ˜8ò =�CØ×&Ñ&¨¨H¨:°c°UÐ';Õ<ñ=ð		=ð %)§J¢J”�T—Z‘Z”°AˆÜ6;¸A¸vÓ6FÖG¨s˜6˜( " S EÒ*ÐGˆÐGØ�‰�|Ô$Ø�‰�{Ô#Ø�‰�t×(Ñ(Ô)Ø�wˆÐùò	 Hs   ÆGc                óÊ	  — | j                   rt        | j                   «      nd| _        t        j                  | j
                  j                  t        j                  «      }t        j                  | j
                  j                  d¬«      |dd t        d| j                  dz
  «      }t        ||d¬«      \  | _
        | _        | j                  j                  «       | _        | j
                  j                  }t!        |t"        j$                  «      }t        j                  | j
                  j                  t        j                  «      }| j
                  j                  dd |dd |j'                  «       g}| j(                  j+                  «       D ]g  \  }}	|	€Œ	|r|j,                  j/                  |«      }
n|}
| j
                  j0                  dd…|
f   |dd |j3                  |j'                  «       «       Œi t        j4                  |«      | _        |r|j                  «       }nRt        j                  | j
                  j0                  t        j                  «      }t        j                  |d¬«      |dd i }| j(                  j+                  «       D ]  \  }}	|	�|	dgk(  rdn|	dd }	|	||<   Œ | j9                  ||«      | _        | j                  | j6                  | j                  | j:                  | j<                  dœ| _        | j                  g}| j>                  j+                  «       D ]h  \  }}	|d	k7  r%|j3                  t        j@                  |	«      «       Œ0|	jC                  «       D ]&  }|j3                  t        j@                  |«      «       Œ( Œj |d   }t        j4                  |dd «      }d}| j(                  jC                  «       D ]  }	t        ||	�t        |	«      nd«      }Œ t        | j                  |«      | _        t        | j                  d«      | _        |€tE        | j                  «      | _#        | jF                  | j                  k  rtI        d
«      ‚|| jF                  d }|jJ                  d   |jJ                  d   kD  r,tI        d|jJ                  d   › d|jJ                  d   › d�«      ‚t        jL                  |«      | jF                  d |fS )rÜ   r   r   rR   NrÝ   r¾   ro  )rƒ   Úlevelsr”   r`   r�   r`   rß   rà   rá   râ   )'r¯   r´   rã   rU   rq  r’   r”   rý   Údiffr/   rä   rå   rç   rè   ré   rÆ   rS   rf   rg   Úcopyr›   r¸  rk   Úget_locr`   rµ   rê   Ú_levelsrÄ   ræ   r˜   r™   r  r£   rT   rº   rW   rj   rø  )rG   r„   ÚdendogÚdlagrÆ   rú  ÚlvlÚlvlsry   rª   r+  ÚdexogÚ	adj_orderrÞ  ÚsubvalrË  rï   rì   s                     rH   rœ   zUECM._construct_regressors8  sú  € ð
 +/¯*ª*”s˜4Ÿ:™:”¸!ˆŒÜ—‘˜dŸi™iŸo™o¬r¯v©vÓ6ˆÜ—W‘W˜TŸY™YŸ_™_°1Ô5ˆˆqˆrˆ
Ü�1�d—l‘l QÑ&Ó'ˆÜ'-¨f°dÀUÔ'KÑ$ˆŒ˜œà"&×"6Ñ"6×"@Ñ"@Ó"BˆÔà—I‘I×'Ñ'ˆ	Ü  ¬B¯L©LÓ9ˆÜ�l‰l˜4Ÿ9™9Ÿ?™?¬B¯F©FÓ3ˆØ—)‘)—/‘/ # 2Ð&ˆˆAˆBˆØ—‘“
ˆ|ˆØŸ™×)Ñ)Ó+ò 	(‰HˆC�Ø‰ÙØ#×+Ñ+×3Ñ3°CÓ8‘Cà�CØŸ)™)Ÿ.™.¨¨"¨¨c¨Ñ2��A�B�Ø—‘˜CŸH™H›JÕ'ð	(ô —‘ tÓ,ˆŒñ Ø—N‘NÓ$‰Eä—L‘L §¡§¡´·±Ó8ˆEÜŸ™ 	°Ô2ˆE�!�"ˆIØˆ	ØŸ™×)Ñ)Ó+ò 	!‰HˆC�Ø˜;¨#°!°ª*‘$¸3¸sÀ¸8ˆCØ ˆI�cŠNð	!ð ×&Ñ& u¨iÓ8ˆŒ
ð "×4Ñ4Ø—l‘lØ—_‘_Ø—J‘JØ—[‘[ñ
ˆŒð —+‘+�ˆØŸ™×*Ñ*Ó,ò 	6‰HˆC�Ø�fŠ}Ø—‘œbŸj™j¨›oÕ.à!Ÿj™j›lò 6�FØ—M‘M¤"§*¡*¨VÓ"4Õ5ñ6ð		6ð �1‰IˆÜ�o‰o˜f Q R˜jÓ)ˆØˆØ—;‘;×%Ñ%Ó'ò 	OˆCÜ˜k°s°¬3¨s¬8ÈAÓN‰Kð	Oä˜4Ÿ<™<¨Ó5ˆŒä˜4Ÿ<™<¨Ó+ˆŒØÐÜ! $§,¡,Ó/ˆDŒOØ�?‰?˜TŸ\™\Ò)Üðóð ð �$—/‘/Ð#Ð$ˆØ�9‰9�Q‰<˜#Ÿ)™) A™,Ò&ÜØ,¨S¯Y©Y°q©\¨Nð ;#ð $'§9¡9¨Q¡< .°ð4óð ô �z‰z˜!‹}˜TŸ_™_Ð.Ð/°Ð4Ð4rJ   rÇ   TrÉ   c               óh   — | j                  |||¬«      \  }}}t        | ||||¬«      }t        |«      S )NrÉ   r×   )rÕ   r5   rò  rØ   s           rH   rÍ   zUECM.fit‡  sI   € ð /3¯i©iØ¨¸ð /8ó /
Ñ+ˆ�
˜Oô Ø�&˜* o¸Uô
ˆô " #Ó&Ð&rJ   r0   c                ó®  — d}i }|j                   }|j                  «       D ]X  \  }}t        |«      }t        ||   «      |t	        |j
                   «      z   k  rt        |j                  d¬«      «      ‚|||<   ŒZ |j                  €d}	nJt        |j                  «      }t        |j                  «      |k7  rt        |j                  d¬«      «      ‚|}	 | |j                  j                  |	|j                  j                  ||j                  |j                  |j                  |j                  |j                   |j
                  ||j"                  ¬«      S )a|  
        Construct a UECM from an ARDL model

        Parameters
        ----------
        ardl : ARDL
            The ARDL model instance
        missing : {"none", "drop", "raise"}, default "none"
            How to treat missing observations.

        Returns
        -------
        UECM
            The UECM model instance

        Notes
        -----
        The lag requirements for a UECM are stricter than for an ARDL.
        Any variable that is included in the UECM must have a lag length
        of at least 1. Additionally, the included lags must be contiguous
        starting at 0 if non-causal or 1 if causal.
        zmUECM can only be created from ARDL models that include all {var_typ} lags up to the maximum lag in the model.Ú	exogenous)Úvar_typNÚ
endogenous)r‰   r�   r‚   r„   r…   r\   rv   rƒ   )r²   r¸  r´   rY   rT   r\   rW   Úformatr°   r’   r5  rÆ   r‰   r�   r‚   r„   r…   rƒ   )
r6  Úardlrv   ÚerrÚ	uecm_lagsr²   ry   rª   Úmax_valr°   s
             rH   Ú	from_ardlzUECM.from_ardl—  s-  € ð6Að 	ð ˆ	Ø—,‘,ˆØŸ™›ò 	%‰HˆC�Ü˜#“hˆGÜ�7˜3‘<Ó  G¬c°d·k±k°/Ó.BÑ$BÒCÜ  §¡°K Ó!@ÓAÐAØ$ˆI�cŠNð		%ð
 �<‰<ÐØ‰Gä˜$Ÿ,™,Ó'ˆGÜ�4—<‘<Ó  GÒ+Ü  §¡°L Ó!AÓBÐBØˆGáØ�I‰I× Ñ ØØ�I‰I×ÑØØ—*‘*Ø—*‘*Ø—]‘]Ø—n‘nØ—;‘;Ø—;‘;ØØ×,Ñ,ô
ð 	
rJ   c	                óR  — |durt        d«      ‚| j                  |||||«      \  }}}}}}	|	dk7  rt        d«      ‚t        j                  | j                  j
                  d   t        j                  «      }
| j                  |z  |
| j                  j
                  d    d |
||dz    S )r  Fz#dynamic forecasts are not supportedr   z)Out-of-sample forecasts are not supportedNrR   )ÚNotImplementedErrorr  rU   rü   r”   rj   rý   r�   )rG   rÏ   r
  r  r#  r`   r  r�   r  r  Úpreds              rH   r,  zUECM.predictÓ  s¶   € ð| ˜%ÑÜ%Ð&KÓLÐLØ6:×6NÑ6NØ�D˜( E¨3ó7
Ñ3ˆ��h  s¨Gð �aŠ<Ü%Ø;óð ô �w‰w�t—z‘z×'Ñ'¨Ñ*¬B¯F©FÓ3ˆØ$(§G¡G¨fÑ$4ˆˆd�g‰g�m‰m˜AÑÐÐ Ð!Ø�E˜C !™GÐ$Ð$rJ   r-  c               ó8   •— t         ‰| �  |||||||||	|
|¬«      S )Nr-  )r�   r4  )r6  r7  r’   r§   rO   r‰   r\   r‚   rƒ   r„   r…   rv   rD   s               €rH   r4  zUECM.from_formula  s=   ø€ ô" ‰wÑ#ØØØØØØØØ'ØØØð $ó 
ð 	
rJ   r;  )r”   úArrayLike1D | ArrayLike2Dr§   rC  r`   r>  rO   Ú
_UECMOrderr‰   r@  r�   r>  r\   rA  r‚   rA  rƒ   rB  r„   rC  r…   rC  rv   rD  r  rE  )r§   r=  r„   rC  r  ztuple[list[int], int])rO   r?  rJ  )rÊ   r=   rË   rI  rÌ   rA  r  r5   )r   )r  r0   rv   rD  rK  )rÏ   r   r
  rL  r  rL  r#  rA  r`   rF  r  rF  r�   rF  r  rF  r  r  rM  )r7  r=   r’   r:   r§   r=  rO   r?  r‰   r@  r\   rA  r‚   rA  rƒ   rB  r„   rC  r…   rC  rv   rN  r  r4   )rE   rK   rL   rO  r�   rô  r^   r�   rœ   r   r=   Úfit_docrÍ   rR  r  r,  Úfrom_formula_docÚ__str__Úreplacer4  rS  rT  s   @rH   r4   r4   X  sÄ  ø„ ñwðz $(ØØ03ð3ð %)ØØØ59Ø $Ø!Ø4:ñ3à(ð3ð ð3ð !ð	3ð
 ð3ð .ð3ð "ð3ð ð3ð ð3ð 3ð3ð ð3ð ð3ð 2ð3ð 
õ3ðB4Ø.ð4Ø;Eð4à	õ4õò4!ðFM5Ø#ðM5à	&óM5ñ^ ‰c�'‹lÓð $Ø#'Øñ'ð ð'ð !ð	'ð
 ð'ð 
ò'ó ð'ð àEKð9
Øð9
Ø"Bò9
ó ð9
ð| @DØ=AØØ.2Ø26Ø/3Ø37ðI%àðI%ð =ðI%ð ;ð	I%ð
 ðI%ð ,ðI%ð 0ðI%ð -ðI%ð 1ðI%ð 
óI%ðV ÙÐ×&Ñ&Ó(×0Ñ0°¸Ó@ÓAð
 ,-ØØ03ð
ð ØØ59Ø $Ø!Ø,2ñ
àð
ð ð
ð )ð	
ð
 ð
ð .ð
ð ð
ð ð
ð 3ð
ð ð
ð ð
ð *ð
ð 
ô
ó Bó ô
rJ   r4   c                  óâ   — e Zd ZU dZi Zded<   	 d	 	 	 	 	 dd„Zedd„«       Zedd„«       Z	edd„«       Z
edd„«       Zddd	„Zddd
„Zedd„«       Zdd„Zd„ Z	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zy)r5   aþ  
    Class to hold results from fitting an UECM model.

    Parameters
    ----------
    model : UECM
        Reference to the model that is fit.
    params : ndarray
        The fitted parameters from the AR Model.
    cov_params : ndarray
        The estimated covariance matrix of the model parameters.
    normalized_cov_params : ndarray
        The array inv(dot(x.T,x)) where x contains the regressors in the
        model.
    scale : float, optional
        An estimate of the scale of the model.
    rI  rY  c                ó  — t        | j                  j                  t        «      s|S | j                  j                  d   j
                  d   }| j                  j                  d   j
                  d   }| j                  j                  d ||z    }t        |||z   «      D ]!  }||   }|j                  d«      sŒ|d d ||<   Œ# |j                  dk(  rt        j                  |||¬«      S t        j                  |||¬«      S )	Nrƒ   rR   r   r÷  éýÿÿÿra   )rk   r1  ©r1  r  )rS   ra  r’   r   r™   rj   rõ   ri   Úendswithrc   rf   rg   rx  )rG   rª   r  ÚndetÚnlvlÚlblsr©   Úlbls           rH   Ú_ci_wrapzUECMResults._ci_wrapS  sä   € ô ˜$Ÿ*™*Ÿ/™/¬:Ô6ØˆJØ�z‰z×!Ñ! /Ñ2×8Ñ8¸Ñ;ˆØ�z‰z×!Ñ! (Ñ+×1Ñ1°!Ñ4ˆØ�z‰z×$Ñ$ _¨¨t©Ð5ˆÜ�t˜T D™[Ó)ò 	#ˆAØ�q‘'ˆCØ�|‰|˜EÕ"Ø˜c˜r˜(��Q’ð	#ð �8‰8�qŠ=Ü—<‘< ¨T¸Ô>Ð>Ü�y‰y˜ D¨tÔ4Ð4rJ   c                ó(  — | j                   j                  d   j                  d   }| j                   j                  d   j                  d   }t        j                  | j
                  «      |   }| j                  | j
                  d||z    |z  d«      S )z3Parameters of normalized cointegrating relationshiprƒ   rR   r   NÚ	ci_params)ra  r™   rj   rU   r  rÏ   r*  )rG   r&  r'  rö   s       rH   r,  zUECMResults.ci_paramsc  s~   € ð �z‰z×!Ñ! /Ñ2×8Ñ8¸Ñ;ˆØ�z‰z×!Ñ! (Ñ+×1Ñ1°!Ñ4ˆÜ�z‰z˜$Ÿ+™+Ó& tÑ,ˆØ�}‰}˜TŸ[™[¨¨4°$©;Ð7¸$Ñ>ÀÓLÐLrJ   c                ó’   — t        j                  t        j                  | j                  «       «      «      }| j	                  |d«      S )z8Standard Errors of normalized cointegrating relationshipÚci_bse)rU   ÚsqrtÚdiagÚci_cov_paramsr*  )rG   Úbses     rH   r.  zUECMResults.ci_bsek  s5   € ô �g‰g”b—g‘g˜d×0Ñ0Ó2Ó3Ó4ˆØ�}‰}˜S (Ó+Ð+rJ   c                ó’  — | j                   j                  d   j                  d   }t        j                  «       5  t        j
                  d«       t        j                  | j                  «      t        j                  | j                  «      z  }t        j                  ||<   ddd«       | j                  d«      S # 1 sw Y   ŒxY w)z1T-values of normalized cointegrating relationshiprƒ   rR   ÚignoreNÚ
ci_tvalues)ra  r™   rj   rp   Úcatch_warningsÚsimplefilterrU   r  r,  r.  rý   r*  )rG   r&  Útvaluess      rH   r5  zUECMResults.ci_tvaluesq  s–   € ð �z‰z×!Ñ! /Ñ2×8Ñ8¸Ñ;ˆÜ×$Ñ$Ó&ñ 	#Ü×!Ñ! (Ô+Ü—j‘j §¡Ó0´2·:±:¸d¿k¹kÓ3JÑJˆGÜŸF™FˆG�D‰M÷	#ð �}‰}˜W lÓ3Ð3÷		#ð 	#ús   »A(B=Â=Cc                ó&  — t        j                  «       5  t        j                  d«       ddt        j                  j                  t        j                  | j                  «      «      z
  z  }ddd«       | j                  d«      S # 1 sw Y   ŒxY w)z1P-values of normalized cointegrating relationshipr4  ra   rR   NÚ
ci_pvalues)
rp   r6  r7  r   ÚnormÚcdfrU   Úabsr5  r*  )rG   Úpvaluess     rH   r:  zUECMResults.ci_pvalues{  ss   € ô ×$Ñ$Ó&ñ 	HÜ×!Ñ! (Ô+Ø˜1œuŸz™zŸ~™~¬b¯f©f°T·_±_Ó.EÓFÑFÑGˆG÷	Hð �}‰}˜W lÓ3Ð3÷	Hð 	Hús   •ABÂBc                óà  — t        |d«      }| j                  r5t        j                  | j                  «      j                  d|dz  z
  «      }n)t        j                  «       j                  d|dz  z
  «      }| j                  }| j                  }|||z  z
  |||z  z   g}t        |t        j                  «      st        j                  |«      S t        j                  |d¬«      }ddg|_        |S )Nr‚  rR   ra   r   rB   rA   )r$   rÌ   r   ÚtÚdf_residÚppfr;  r,  r.  rS   rf   rx  rU   rê   r  rk   )rG   r‚  ÚqÚpÚseÚoutrÌ  s          rH   Úci_conf_intzUECMResults.ci_conf_intƒ  sÂ   € Ü˜5 'Ó*ˆà�:Š:Ü—‘˜Ÿ™Ó&×*Ñ*¨1¨u°q©y©=Ó9‰Aä—
‘
“× Ñ   U¨Q¡Y¡Ó/ˆAØ�N‰NˆØ�[‰[ˆØ�1�r‘6‰z˜1˜q 2™v™:Ð&ˆÜ˜!œRŸY™YÔ'Ü—?‘? 3Ó'Ð'ä�Y‰Y�s Ô#ˆØ˜wÐ'ˆŒ
àˆ	rJ   c                ó  ‡ — |fˆ fd„	}t        «       }‰ j                  j                  d   j                  d   }‰ j                  j                  d   j                  d   }t	        ‰ j                  j
                  «      d ||z    }t        ‰ j                  j                  |¬«      }t        ‰ j                  ‰ j                  ‰ j                  ‰ j                  ||¬«      }t        |«      }	d|	_        |j                  j                  |	«       |S )Nc                óL   •— t        j                  ‰j                  | «      «      S rÑ  )rU   r  rG  )r‚  rG   s    €rH   Ú_ciz#UECMResults.ci_summary.<locals>._ci–  s   ø€ Ü—:‘:˜d×.Ñ.¨uÓ5Ó6Ð6rJ   rƒ   rR   r   )r‘  rõ   )rÏ   r2  r8  r>  Úconf_intra  zCointegrating Vector)r   ra  r™   rj   rh   rõ   r
   r‘  r,  r.  r5  r:  r   rŽ  Útablesrµ   )
rG   r‚  rJ  r�  r&  r'  rõ   ra  r’   Útabs
   `         rH   Ú
ci_summaryzUECMResults.ci_summary•  sâ   ø€ Øõ 	7ô ‹yˆØ�z‰z×!Ñ! /Ñ2×8Ñ8¸Ñ;ˆØ�z‰z×!Ñ! (Ñ+×1Ñ1°!Ñ4ˆÜ˜$Ÿ*™*×/Ñ/Ó0°°D¸4±KÐAˆ
äØŸ
™
×.Ñ.¸:ô
ˆô Ø—>‘>Ø—‘Ø—O‘OØ—O‘OØØô
ˆô ˜TÓ"ˆØ*ˆŒ	Ø�‰×Ñ˜3ÔàˆrJ   c                ó,  — | j                   j                  d   }| j                   j                  j                  }t	        |t
        j                  «      }|r|n| j                   j                  }t        j                  |«      | j                   j                  g}| j                   j                  j                  «       D ]J  \  }}|€Œ	|r(|j                  t        j                  ||   «      «       Œ3|j                  |d d …|f   «       ŒL t        j                  |«      }|| j                  z  }t	        | j                   j                  t         «      s|S | j                   j                  j"                  j$                  }	t        j&                  ||	d¬«      S )Nrƒ   Ú	ci_residsr$  )ra  r™   r’   rÆ   rS   rf   rg   r`   rU   r  r”   r²   r¸  rµ   rê   r,  r   r5  r1  rx  )
rG   r´  r`   Ú	is_pandasÚcolsry   r{   Úci_xÚresidsr1  s
             rH   rP  zUECMResults.ci_resids¯  s#  € à�J‰J×Ñ˜Ñ/ˆØ�z‰z�‰×(Ñ(ˆÜ˜t¤R§\¡\Ó2ˆ	Ù ‰t d§j¡j§o¡oˆÜ—
‘
˜1“˜tŸz™z×/Ñ/Ð0ˆØŸ*™*×,Ñ,×2Ñ2Ó4ò 	.‰JˆC�ØÑ ÙØ—K‘K¤§
¡
¨4°©9Ó 5Õ6à—K‘K ¢Q¨ V¡Õ-ð	.ô �‰˜tÓ$ˆØ˜Ÿ™Ñ&ˆÜ˜$Ÿ*™*Ÿ/™/¬:Ô6ØˆMØ—
‘
—‘×*Ñ*×0Ñ0ˆÜ�y‰y˜ u°;Ô?Ð?rJ   c                óŒ  — | j                   j                  d   j                  d   }| j                   j                  d   j                  d   }t        t	        ||z   «      «      }| j                  «       }t        j                  |«      }|t        j                  ||«         }|j                  d   }t        j                  | j                  «      d||z    }||   }	t        j                  ||f«      }
t	        |«      D ]#  }||k(  rŒ	d|	z  |
||f<   ||    |	dz  z  |
||f<   Œ% |
|z  |
j                  z  }| j                  |«      S )z6Covariance of normalized of cointegrating relationshiprƒ   rR   r   r   Nra   )ra  r™   rj   rh   ri   rÎ   rU   r  Úix_rÏ   ri  ÚTr*  )rG   r&  r'  r+  ÚcovÚcov_aÚci_covÚmrÏ   rö   r´  r©   s               rH   r1  zUECMResults.ci_cov_paramsÃ  s3  € à�z‰z×!Ñ! /Ñ2×8Ñ8¸Ñ;ˆØ�z‰z×!Ñ! (Ñ+×1Ñ1°!Ñ4ˆÜ”5˜ ™Ó%Ó&ˆØ�o‰oÓˆÜ—
‘
˜3“ˆØ”r—v‘v˜c 3Ó'Ñ(ˆØ�L‰L˜‰OˆÜ—‘˜DŸK™KÓ(¨¨4°$©;Ð7ˆØ�d‰|ˆÜ�H‰H�a˜�VÓˆÜ�q“ò 	0ˆAØ�DŠyØØ˜$‘hˆAˆa�ˆd‰GØ  ™)˜ t¨Q¡wÑ/ˆAˆa�ˆgŠJð		0ð
 �V‘˜aŸc™cÑ!ˆØ�}‰}˜VÓ$Ð$rJ   c                 ó   — y)rh  NrN   rF   s    rH   rl  zUECMResults._lag_repr×  s   � rJ   Nc           	     ó  — | j                   }|dk(  rd}	n	|dv rd}	nd}	|j                  j                  «       D �
�ci c]  \  }
}|
t        |«      “Œ }}
}t	        |j
                  j                  t        |j                  «      |j
                  j                  ||j                  |	¬«      }|j                  |||¬«      }|j                  «       }t        |j                   j                  «      }|dk(  rt        j                  |«      }nz|dk(  rt        j                  |dz   «      }n\|d	k(  rt        j                  d|dz   «      }n=|d
k(  rt        j                  d|dz   «      }n|dk(  rt        j                  d|dz   «      }t        j                   j"                  d   |j"                  d   f«      }t%        |«      D ]  \  }}d|||f<   Œ ||z  |j&                  z  }||j(                  z  }|j&                  t        j*                  j-                  |«      z  |z  |j"                  d   z  }|}|r“|dk  rŽt.        j0                  }||f}
||
dz      }||
dz      }t3        j4                  ||dœt.        j6                  ¬«      }d|j8                  _        t3        j<                  t?        |||d«      t?        |||d«      dœ«      }n-|j@                  j"                  d   }tC        ||||||¬«      \  }}tE        |||dd«      S c c}}
w )ad  
        Cointegration bounds test of Pesaran, Shin, and Smith

        Parameters
        ----------
        case : {1, 2, 3, 4, 5}
            One of the cases covered in the PSS test.
        cov_type : str
            The covariance estimator to use. The asymptotic distribution of
            the PSS test has only been established in the homoskedastic case,
            which is the default.

            The most common choices are listed below.  Supports all covariance
            estimators that are available in ``OLS.fit``.

            * 'nonrobust' - The class OLS covariance estimator that assumes
              homoskedasticity.
            * 'HC0', 'HC1', 'HC2', 'HC3' - Variants of White's
              (or Eiker-Huber-White) covariance estimator. `HC0` is the
              standard implementation.  The other make corrections to improve
              the finite sample performance of the heteroskedasticity robust
              covariance estimator.
            * 'HAC' - Heteroskedasticity-autocorrelation robust covariance
              estimation. Supports cov_kwds.

              - `maxlags` integer (required) : number of lags to use.
              - `kernel` callable or str (optional) : kernel
                  currently available kernels are ['bartlett', 'uniform'],
                  default is Bartlett.
              - `use_correction` bool (optional) : If true, use small sample
                  correction.
        cov_kwds : dict, optional
            A dictionary of keyword arguments to pass to the covariance
            estimator. `nonrobust` and `HC#` do not support cov_kwds.
        use_t : bool, optional
            A flag indicating that small-sample corrections should be applied
            to the covariance estimator.
        asymptotic : bool
            Flag indicating whether to use asymptotic critical values which
            were computed by simulation (True, default) or to simulate a
            sample-size specific set of critical values. Tables are only
            available for up to 10 components in the cointegrating
            relationship, so if more variables are included then simulation
            is always used. The simulation computed the test statistic under
            and assumption that the residuals are homoskedastic.
        nsim : int
            Number of simulations to run when computing exact critical values.
            Only used if ``asymptotic`` is ``True``.
        seed : {None, int, sequence[int], RandomState, Generator}, optional
            Seed to use when simulating critical values. Must be provided if
            reproducible critical value and p-values are required when
            ``asymptotic`` is ``False``.

        Returns
        -------
        BoundsTestResult
            Named tuple containing ``stat``, ``crit_vals``, ``p_values``,
            ``null` and ``alternative``. The statistic is the F-type
            test statistic favored in PSS.

        Notes
        -----
        The PSS bounds test has 5 cases which test the coefficients on the
        level terms in the model

        .. math::

           \Delta Y_{t}=\delta_{0} + \delta_{1}t + Z_{t-1}\beta
                        + \sum_{j=0}^{P}\Delta X_{t-j}\Gamma + \epsilon_{t}

        where :math:`Z_{t-1}` contains both :math:`Y_{t-1}` and
        :math:`X_{t-1}`.

        The cases determine which deterministic terms are included in the
        model and which are tested as part of the test.

        Cases:

        1. No deterministic terms
        2. Constant included in both the model and the test
        3. Constant included in the model but not in the test
        4. Constant and trend included in the model, only trend included in
           the test
        5. Constant and trend included in the model, neither included in the
           test

        The test statistic is a Wald-type quadratic form test that all of the
        coefficients in :math:`\beta` are 0 along with any included
        deterministic terms, which depends on the case. The statistic returned
        is an F-type test statistic which is the standard quadratic form test
        statistic divided by the number of restrictions.

        References
        ----------
        .. [*] Pesaran, M. H., Shin, Y., & Smith, R. J. (2001). Bounds testing
           approaches to the analysis of level relationships. Journal of
           applied econometrics, 16(3), 289-326.
        rR   r  ©ra   é   r<  Úct)rO   r\   r‰   rÉ   ra   r_  é   é   r   é
   )T)F©rB   rA   rp  Ú
percentileFT)rÓ   ÚnsimÚseedzNo CointegrationzPossible Cointegration)#ra  r›   r¸  r´   r4   r’   r”   r°   rÆ   r\   rÍ   rÎ   rY   r¸   rU   Úarangeri  rj   r!  rW  rÏ   rÇ  Úinvr*   r;   rf   rg   Úcrit_percentilesr1  r  rx  Ú_pss_pvaluerÍ  Ú_pss_simulater6   )rG   ÚcaserÊ   rË   rÌ   Ú
asymptoticrf  rg  ra  r‰   ry   rª   rO   ÚuecmrÚ   rX  ÚnvarÚrestÚrr©   r+  ÚvcvÚcoefr9   rt   ÚcvrA   rB   r;   r<   rÓ   s                                  rH   Úbounds_testzUECMResults.bounds_testÛ  sÉ  € ð` —
‘
ˆà�1Š9Ø‰EØ�V‰^Ø‰EàˆEØ/4¯|©|×/AÑ/AÓ/C×D¡8 3¨�”c˜#“h‘ÐDˆÑDÜØ�J‰J×ÑÜ�—‘ÓØ�J‰J× Ñ ØØ—<‘<Øô
ˆð �h‰h °8À5ˆhÓIˆØ�n‰nÓˆÜ�3—9‘9×'Ñ'Ó(ˆØ�1Š9Ü—9‘9˜T“?‰DØ�QŠYÜ—9‘9˜T A™XÓ&‰DØ�QŠYÜ—9‘9˜Q  q¡Ó)‰DØ�QŠYÜ—9‘9˜Q  q¡Ó)‰DØ�QŠYÜ—9‘9˜Q  q¡Ó)ˆDÜ�H‰H�d—j‘j ‘m S§Y¡Y¨q¡\Ð2Ó3ˆÜ “oò 	‰FˆAˆsØˆAˆa�ˆfŠIð	à�#‰g˜Ÿ™‰mˆØ�3—:‘:‰~ˆØ�v‰vœŸ	™	Ÿ™ cÓ*Ñ*¨TÑ1°A·G±G¸A±JÑ>ˆØˆÙ˜!˜rš'Ü$×.Ñ.ˆBØ�d�)ˆCØ�s˜W‘}Ñ%ˆEØ�s˜X‘~Ñ&ˆEÜŸ™Ø¨%Ñ0Ü)×:Ñ:ôˆIð $0ˆI�O‰OÔ Ü—y‘yä(¨¨q°$¸Ó>Ü(¨¨q°$¸Ó=ñó‰Hð —9‘9—?‘? 1Ñ%ˆDÜ"/Ø�a˜ D¨t¸$ô#ÑˆI�xô  ØØØØØ$ó
ð 	
ùóg Es   »L )rˆ  )rª   r  r  r=   r  z"NDArray | pd.Series | pd.DataFrame)r  r   r£  )r‚  r8   r  úFloat64Array | pd.DataFramer¤  )r  rw  )rÇ   NTTi † N)rm  úLiteral[1, 2, 3, 4, 5]rÊ   r=   rË   rI  rÌ   rA  rn  rA  rf  rT   rg  úHint | Sequence[int] | np.random.RandomState | np.random.Generator | None)rE   rK   rL   rO  rY  rM   r*  r   r,  r.  r5  r:  rG  rN  rP  r1  rl  rv  rN   rJ   rH   r5   r5   >  s  … ñð$  €FˆNÓð ,.ð5Øð5Ø%(ð5à	+ó5ð  òMó ðMð ò,ó ð,ð
 ò4ó ð4ð ò4ó ð4ôô$ð4 ò@ó ð@ó&%ò(Eð $Ø#'ØØØð
 ðq
à$ðq
ð ðq
ð !ð	q
ð
 ðq
ð ðq
ð ðq
ðôq
rJ   c                ó|  — |||f}t         j                  |   }t         j                  |   }t         j                  |   }t	        j
                  | «      }| |kD  r|n|}	t        t        |	«      «      D �
cg c]  }
||
z  ‘Œ	 }}
dt        j                  j                  |t	        j                  |	«      z  «      z
  S c c}
w )NrR   )r*   Úlarge_pÚsmall_pÚ	stat_starrU   rÉ  ri   rY   r   r;  r<  Úarray)r9   rt   rm  Úi1ry   r{  r|  Ú	thresholdÚlog_statrD  r©   rí   s               rH   rk  rk  �	  s    € Øˆd�Bˆ-€CÜ!×)Ñ)¨#Ñ.€GÜ!×)Ñ)¨#Ñ.€GÜ#×-Ñ-¨cÑ2€IÜ�v‰v�d‹|€HØ˜)Ò#‰¨€AÜ#¤C¨£F›mÖ,˜ˆ�1‹Ð,€AÐ,ØŒu�z‰z�~‰~˜a¤"§(¡(¨1£+™oÓ.Ñ.Ð.ùò 	-s   Á3B9c                ó	  — t        |t        j                  j                  «      s t        j                  j	                  |«      }n(t        |t        j                  j                  «      sJ ‚|}d„ }dd|z  |z  z  }|}	d}
t        j
                  |«      }t        j
                  |«      }|	dkD  �r8t        |	|«      }|j                  ||dz   |f«      }t        j                  |d d …d d …d d…f   d¬«      }t        j                  |d d …d d …dd …f   d¬«      }|d d …d d …dd …f   }t        j                  |d¬«      }|dv r(t        j
                  |||dz   f«      }d|d d …d d …df<   ni|d	v rMt        j
                  |||d
z   f«      }t        j                  |t        ¬«      |d d …d d …df<   d|d d …d d …df<   nt        j
                  |||f«      }|d d …d d…f   |d d …d d …d d…f<   |d d …d d…f   |d d …d d …d|…f<    |||«      }|j                  d   |j                  d
   z
  }|d
z  j                  d«      |z  }|dv r|d d …d d …dd …f   }n|dk(  r|d d …d d …dd …f   }|dv r) ||«      }|j                  d   |j                  d   z
  }n$t        j                  |«      }|j                  d   }|d
z  j                  d«      |d
z  j                  d«      z
  |z  }||z  }|||
|
|z    |d d …d d…f   |d d …d d …d|…f<    |||«      }|d
z  j                  d«      |z  }|dv r|d d …d d …dd …f   }n|dk(  r|d d …d d …dd …f   }|dv r) ||«      }|j                  d   |j                  d   z
  }n$t        j                  |«      }|j                  d   }|d
z  j                  d«      |d
z  j                  d«      z
  |z  }||z  }|||
|
|z    |
|z  }
|	|z  }	|	dkD  r�Œ8t        j                   }t#        j$                  t        j&                  ||«      t        j&                  ||«      dœ|¬«      }d|j(                  _        t#        j,                  | |k  j/                  «       | |k  j/                  «       dœ«      }||fS )Nc                ó"  — t        j                  | g d¢«      }t        j                  || «      }t        j                  ||«      }t         j                  j	                  ||«      }t        j
                  |t        j                  | |«      z
  «      S )N)r   ra   rR   )rU   Ú	transposeÚmatmulrÇ  Úsolverø  )ÚrhsÚlhsÚrhs_tÚxpxÚxpyÚbs         rH   Ú_vectorized_ols_residz,_pss_simulate.<locals>._vectorized_ols_resid­	  se   € Ü—‘˜S¢)Ó,ˆÜ�i‰i˜˜sÓ#ˆÜ�i‰i˜˜sÓ#ˆÜ�I‰I�O‰O˜C Ó%ˆÜ�z‰z˜#¤§	¡	¨#¨qÓ 1Ñ1Ó2Ð2rJ   i áõrV  r   rR   r   r^  ro  )ra  rb  ra   r¶  éþÿÿÿ)r_  ra  rb  )r_  ra  rb  rd  rp  re  )rS   rU   ÚrandomÚRandomStateÚdefault_rngrŒ   r[   Ústandard_normalrw  r  rh  r8   rj   Úsumrø  r*   rj  rf   rg   re  r1  r  rx  ry  )r9   rt   rm  rÓ   rf  rg  Úrsr�  Ú
block_sizeÚ	remainingr+  Úf_upperÚf_lowerÚto_doÚerË  Úx_upperÚx_lowerrˆ  r‡  ÚurÌ  Ús2Úrhs_rÚurÚnrestÚfrj  r;   r<   s                                 rH   rl  rl  š	  su  € ô �dœBŸI™I×1Ñ1Ô2Ü�Y‰Y×"Ñ" 4Ó(‰ä˜$¤§	¡	× 5Ñ 5Ô6Ñ6Øˆò3ð   T¡¨A¡Ñ.€JØ€IØ
€CÜ�h‰h�t‹n€GÜ�h‰h�t‹n€GØ
�a‹-Ü�I˜zÓ*ˆØ×Ñ  t¨a¡x°Ð3Ó4ˆä�I‰I�ašš1˜b˜q˜b˜‘k¨Ô*ˆÜ—)‘)˜Aša¢ A¡B˜h™K¨aÔ0ˆØ’A’q˜!™"�H‘+ˆÜ�g‰g�a˜aÔ ˆØ�6‰>Ü—(‘(˜E 4¨¨Q©Ð/Ó0ˆCØˆC’’1�b�ŠMØ�V‰^Ü—(‘(˜E 4¨¨Q©Ð/Ó0ˆCÜŸI™I d´%Ô8ˆC’’1�b�‰MØˆC’’1�b�ŠMä—(‘(˜E 4¨Ð+Ó,ˆCØš!˜S˜b˜S˜&™	ˆŠAŠq�"�1�"ˆH‰Ø ¢ C R C ™ˆŠAŠq�!�A�#ˆI‰á! # sÓ+ˆØ�Y‰Y�q‰\˜CŸI™I a™LÑ(ˆØ�‰d�Z‰Z˜‹]˜RÑˆà�6‰>Øšš1˜b™c˜	‘N‰EØ�QŠYØšš1˜b™c˜	‘NˆEØ�9ÑÙ& u¨cÓ2ˆBØ—I‘I˜b‘M E§K¡K°¡OÑ3‰Eä—‘˜C“ˆBØ—I‘I˜b‘MˆEà�!‰e�[‰[˜‹^˜q !™tŸj™j¨›mÑ+¨uÑ4ˆØ	ˆR‰ˆØ%&ˆ��c˜E‘kÐ"ð !¢ C R C ™ˆŠAŠq�!�A�#ˆI‰Ù! # sÓ+ˆØ�‰d�Z‰Z˜‹]˜RÑˆà�6‰>Øšš1˜b™c˜	‘N‰EØ�QŠYØšš1˜b™c˜	‘NˆEØ�9ÑÙ& u¨cÓ2ˆBØ—I‘I˜b‘M E§K¡K°¡OÑ3‰Eä—‘˜C“ˆBØ—I‘I˜b‘MˆEà�!‰e�[‰[˜‹^˜q !™tŸj™j¨›mÑ+¨uÑ4ˆØ	ˆR‰ˆØ%&ˆ��c˜E‘kÐ"àˆu‰ˆØ�UÑˆ	ðy �aŒ-ô| +×;Ñ;ÐÜ—‘ä—]‘] 7Ð,<Ó=Ü—]‘] 7Ð,<Ó=ñ	
ð ô€Ið (€I‡O�OÔÜ�y‰yØ˜'‘>×'Ñ'Ó)°T¸G±^×4IÑ4IÓ4KÑLó€Hð �hÐÐrJ   c                  ó°   — e Zd Zi Z ej
                  ej                  j                  e«      Zi Z	 ej
                  ej                  j                  e	«      Z
y)rò  Nr§  rN   rJ   rH   rò  rò  
  r¯  rJ   rò  )rO   r=  r\   rA  r  rA  )r`   r   rO   r?  r\   rA  r  rH  )r<  )r”   r  rÛ  rT   r`   r   rÜ  zint | dict[Hashable, int]r‰   r@  r�   r>  r\   rA  rÂ  zLiteral['aic', 'bic']rÃ  rA  r‚   rA  rƒ   rB  r„   rC  r…   rC  rv   rN  r  r3   )
r9   r8   rt   rT   rm  rT   r  rA  r  r8   )r9   r8   rt   rT   rm  rx  rÓ   rT   rf  rT   rg  ry  r  ztuple[pd.DataFrame, pd.Series])zÚ
__future__r   Ústatsmodels.compat.pandasr   r   r   Úcollectionsr   ÚdatetimeÚdtÚ	itertoolsr   r	   ÚtextwrapÚtypesr
   Útypingr   r   r   r   r   r   Úcollections.abcr   r   r   rp   ÚnumpyrU   Úpandasrf   Úscipyr   Ústatsmodels.base.datar   Ústatsmodels.base.wrapperrö   Úwrapperr©  Ústatsmodels.iolib.summaryr   r   Ú#statsmodels.regression.linear_modelr   Ústatsmodels.tools.decoratorsr   Ústatsmodels.tools.docstringr   r   r   Ústatsmodels.tools.sm_exceptionsr   Ústatsmodels.tools.typingr   r   r    r!   Ústatsmodels.tools.validationr"   r#   r$   r%   Ústatsmodels.tsa.ar_modelr&   r'   r(   r)   Ústatsmodels.tsa.ardlr*   Ústatsmodels.tsa.arima_processr+   Ústatsmodels.tsa.baser,   Ústatsmodels.tsa.base.predictionr-   Ústatsmodels.tsa.deterministicr.   Ústatsmodels.tsa.tsatoolsr/   Úmatplotlib.figureÚ
matplotlibÚ__all__r6   rT   r³  r  r?  rV   rr   r^   r}   r0   r,  rO  ÚdocÚextract_parametersr¥  r1   ÚResultsWrapperr¥   Úpopulate_wrapperr3   r2   Ú
lags_descrÚ
lags_paramÚorder_descrÚorder_paramr4  r  Úreplace_blockÚinsert_parametersrÍ   r  Ú_dsÚsee_alsoÚinsertr4   r5   rk  rl  rò  rN   rJ   rH   ú<module>rÒ     so  ðÝ "ç NÑ Nå #Û ß +Û Ý !÷÷ ÷ 8Ñ 7Û ã Û Ý å ,ß 'Ð 'ß =Ý 3Ý 7ß OÑ OÝ @÷ó ÷ó ÷ó õ 5Ý 1Ý *Ý =Ý >Ý +áÛò€ô�zô ð$ �4˜˜d 8¨X°c©]Ð#:Ñ;Ð;Ñ<€
àØØØØˆS�MØˆ�5˜˜h s™m¨TÐ1Ñ2Ð	2Ñ3ð	5ñ€
ð �2—:‘:Ð€
óð65Ø
ð5Ø(ð5Ø26ð5àó5ôp[
ˆ7ô [
ñ| �—‘×$Ñ$Ó%€Ø×(Ñ(ÚIÈ1ó€ô
@�.ô @ôF
˜×,Ñ,ô ð €× Ñ Ð(¨+Ô 6ô##Ð 7ô ##ðV -0ðYJð !%ØØ %ØØØ15Ø ØØ(.ñYJØ$ðYJàðYJð ðYJð (ð	YJð
 *ðYJð ðYJð ðYJð 	ðYJð ðYJð ðYJð /ðYJð ðYJð ðYJð &ðYJð  ó!YJðx ˆX�]‰]ðàó€
ñ
 ˜F¨°ZÔ@€
Øˆh�m‰mð*ð ó€ñ ˜W¨;¸[ÔI€á˜T×.Ñ.×6Ñ6Ó7Ð Ø × Ñ ˜yÐ*LÔ MØ × "Ñ " 6Ô *Ø × "Ñ " 7Ô +Ø × "Ñ " 6¨:Ô 6Ø × "Ñ " 6¨;Ô 7ñ �D—H‘H×$Ñ$Ó
%€Ø × Ñ Ø‘	˜"˜mÐ.CÐ-DÓEÐFôð ‡;�;ÐØ�{‰{˜:Ñ&€HØ‡O�OØ	à0Ð1Ø>Ð?ð	
ôð ×Ñ˜* hÔ/ôc
ˆ4ô c
ôLN
�+ô N
ób
/ðiØ
ðià
ðið !ðið ð	ið
 ðiððið $óiôX˜×,Ñ,ô ð €× Ñ Ð(¨+Õ 6rJ   