Ë
    £�Dj  ã                   ó*   — d Z ddlZddlmZ d„ Zdd„Zy)zZAdditional functions

prediction standard errors and confidence intervals


A: josef pktd
é    N)Ústatsc                 óä   — t        j                  | «      } | j                  dk(  r| dd…df   } | S | j                  dk(  rt        j                  | «      } | S | j                  dkD  rt	        d«      ‚| S )zM convert array_like to 2d from 1d or 0d

    not tested because not used
    é   Nr   ztoo many dimensions)ÚnpÚasarrayÚndimÚ
atleast_2dÚ
ValueError)Úxs    újC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\statsmodels/sandbox/regression/predstd.pyÚatleast_2dcolr      sp   € ô
 	�
‰
�1‹€AØ	�‰�!ŠØŠa�ˆg‰Jˆð
 €Hð	 �&‰&�AŠ+Ü�M‰M˜!Óˆð €Hð �&‰&�1Š*ÜÐ.Ó/Ð/Ø€Hó    c                 óJ  — | j                  «       }|€;| j                  j                  }| j                  }|€Ë| j                  j                  }n´t        j                  |«      }|j                  d   |j                  d   k7  rt        d«      ‚| j                  j                  | j                  |«      }|€d}nJt        j                  |«      }|j                  dkD  r&t        |«      |j                  d   k7  rt        d«      ‚| j                  |z  |t        j                  ||j                   «      j                   z  j#                  d«      z   }t        j$                  |«      }t&        j(                  j+                  |dz  | j,                  «      }|||z  z   }	|||z  z
  }
||
|	fS )a  calculate standard deviation and confidence interval for prediction

    applies to WLS and OLS, not to general GLS,
    that is independently but not identically distributed observations

    Parameters
    ----------
    res : regression result instance
        results of WLS or OLS regression required attributes see notes
    exog : array_like (optional)
        exogenous variables for points to predict
    weights : scalar or array_like (optional)
        weights as defined for WLS (inverse of variance of observation)
    alpha : float (default: alpha = 0.05)
        confidence level for two-sided hypothesis

    Returns
    -------
    predstd : array_like, 1d
        standard error of prediction
        same length as rows of exog
    interval_l, interval_u : array_like
        lower und upper confidence bounds

    Notes
    -----
    The result instance needs to have at least the following
    res.model.predict() : predicted values or
    res.fittedvalues : values used in estimation
    res.cov_params() : covariance matrix of parameter estimates

    If exog is 1d, then it is interpreted as one observation,
    i.e. a row vector.

    testing status: not compared with other packages

    References
    ----------

    Greene p.111 for OLS, extended to WLS by analogy

    r   zwrong shape of exogg      ð?r   z+weights and exog do not have matching shapeg       @)Ú
cov_paramsÚmodelÚexogÚfittedvaluesÚweightsr   r	   Úshaper
   ÚpredictÚparamsr   ÚsizeÚlenÚ	mse_residÚdotÚTÚsumÚsqrtr   ÚtÚisfÚdf_resid)Úresr   r   ÚalphaÚcovbÚ	predictedÚpredvarÚpredstdÚtppfÚ
interval_uÚ
interval_ls              r   Úwls_prediction_stdr+      s^  € ð^ �>‰>Ó€DØ€|Ø�y‰y�~‰~ˆØ×$Ñ$ˆ	Øˆ?Ø—i‘i×'Ñ'‰Gä�}‰}˜TÓ"ˆØ�:‰:�a‰=˜DŸJ™J q™MÒ)ÜÐ2Ó3Ð3Ø—I‘I×%Ñ% c§j¡j°$Ó7ˆ	Øˆ?Ø‰Gä—j‘j Ó)ˆGØ�|‰|˜aÒ¤C¨£L°D·J±J¸q±MÒ$AÜ Ð!NÓOÐOð �m‰m˜GÑ# t¬b¯f©f°T¸4¿6¹6Ó.B×.DÑ.DÑ'D×&IÑ&IÈ!Ó&LÑL€GÜ�g‰g�gÓ€GÜ�7‰7�;‰;�u˜R‘x §¡Ó.€DØ˜T G™^Ñ+€JØ˜T G™^Ñ+€JØ�J 
Ð*Ð*r   )NNgš™™™™™©?)Ú__doc__Únumpyr   Úscipyr   r   r+   © r   r   ú<module>r0      s   ðñó Ý òôJ+r   