
    "g	                     d    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
  edd      dd	       Zy
)z_
Yule-Walker method for estimating AR(p) model parameters.

Author: Chad Fulton
License: BSD-3
    )deprecate_kwarg)linear_model)Bunch)SARIMAXParams)SARIMAXSpecificationunbiasedadjustedc                     t        | |      }|j                  } t        |      }|j                  st	        d      |rdnd}t        j                  | |||      \  |_        }|dz  |_        t        d|i      }||fS )	a|  
    Estimate AR parameters using Yule-Walker equations.

    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. Default is True.
    adjusted : bool, optional
        Whether to use the adjusted autocovariance estimator, which uses
        n - h degrees of freedom rather than n. For some processes this option
        may  result in a non-positive definite autocovariance matrix. Default
        is False.

    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.1.

    This procedure assumes that the series is stationary.

    For a description of the effect of the adjusted estimate of the
    autocovariance function, see 2.4.2 of [1]_.

    References
    ----------
    .. [1] Brockwell, Peter J., and Richard A. Davis. 2016.
       Introduction to Time Series and Forecasting. Springer.
    )ar_order)speczYYule-Walker estimation unavailable for models with seasonal or non-consecutive AR orders.r	   mle)orderdemeanmethod   r   )
r   endogr   is_ar_consecutive
ValueErrorr   yule_walker	ar_paramssigma2r   )	r   r   r   r	   r   pr   sigmaother_resultss	            i/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/statsmodels/tsa/arima/estimators/yule_walker.pyr   r      s    T  9DJJE4 A!! C D 	D $ZF%11XfV=AKaxAH  M m    N)r   TF)__doc__statsmodels.compat.pandasr   statsmodels.regressionr   statsmodels.tools.toolsr   statsmodels.tsa.arima.paramsr   #statsmodels.tsa.arima.specificationr   r    r   r   <module>r$      s6    6 / ) 6 D Z(< )<r   