U
    Kvf                     @   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   I/tmp/pip-unpacked-wheel-2v6byqio/statsmodels/tsa/arima/estimators/burg.pyr      s"    #
 r   )r   T)__doc__Z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   