U
    Ãmœdï  ã                   @   sJ   d Z ddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 d
dd	„ZdS )zZ
Burg's method for estimating AR(p) model parameters.

Author: Chad Fulton
License: BSD-3
é    N)ÚBunch)Úlinear_model)ÚSARIMAXSpecification)ÚSARIMAXParamsTc                 C   sˆ   t | |d�}|j} t | jt t¡¡r.| d } |js<tdƒ‚t|d�}|dkr\t 	| ¡|_
ntj| ||d�\|_|_
td|iƒ}||fS )a'  
    Estimate AR parameters using Burg technique.

    Parameters
    ----------
    endog : array_like or SARIMAXSpecification
        Input time series array, assumed to be stationary.
    ar_order : int, optional
        Autoregressive order. Default is 0.
    demean : bool, optional
        Whether to estimate and remove the mean from the process prior to
        fitting the autoregressive coefficients.

    Returns
    -------
    parameters : SARIMAXParams object
        Contains the parameter estimates from the final iteration.
    other_results : Bunch
        Includes one component, `spec`, which is the `SARIMAXSpecification`
        instance corresponding to the input arguments.

    Notes
    -----
    The primary reference is [1]_, section 5.1.2.

    This procedure assumes that the series is stationary.

    This function is a light wrapper around `statsmodels.linear_model.burg`.

    References
    ----------
    .. [1] Brockwell, Peter J., and Richard A. Davis. 2016.
       Introduction to Time Series and Forecasting. Springer.
    )Úar_orderg      ð?z\Burg estimation unavailable for models with seasonal or otherwise non-consecutive AR orders.)Úspecr   )ÚorderÚdemeanr   )r   ÚendogÚnpZ
issubdtypeZdtypeÚintZis_ar_consecutiveÚ
ValueErrorr   ÚvarZsigma2r   ÚburgZ	ar_paramsr   )r
   r   r	   r   ÚpZother_results© r   ú^/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/statsmodels/tsa/arima/estimators/burg.pyr      s"    #
ÿ ÿr   )r   T)Ú__doc__Únumpyr   Zstatsmodels.tools.toolsr   Zstatsmodels.regressionr   Z#statsmodels.tsa.arima.specificationr   Zstatsmodels.tsa.arima.paramsr   r   r   r   r   r   Ú<module>   s   