Ë
    ¢�DjWÌ  ã                   ó^  — g d ¢Z ddlZddlZddlmc mZ ddlmc mZ	 ddl
mc mZ ddlmZmZ ddlmZmZmZmZmZmZmZmZ ddlmZ ddlmZ ddlmZ ddl m!Z!  G d	„ d
e«      Z" G d„ de"«      Z# G d„ de"«      Z$ G d„ de"«      Z% G d„ de«      Z& G d„ de&«      Z' G d„ de&«      Z( G d„ de&«      Z) G d„ de&«      Z* G d„ de«      Z+ G d„ de«      Z, G d„ d e,«      Z- G d!„ d"e,«      Z. G d#„ d$ee,«      Z/ G d%„ d&ej`                  «      Z1 e	jd                  e1e,«        G d'„ d(ej`                  «      Z3 e	jd                  e3e/«        G d)„ d*e«      Z4 G d+„ d,ee4«      Z5 G d-„ d.ej`                  «      Z6 e	jd                  e6e4«        G d/„ d0ej`                  «      Z7 e	jd                  e7e5«       y)1)ÚTruncatedLFPoissonÚTruncatedLFNegativeBinomialPÚHurdleCountModelé    N)ÚtruncatedpoissonÚtruncatednegbin)ÚDiscreteModelÚ
CountModelÚCountResultsÚL1CountResultsÚPoissonÚNegativeBinomialPÚGeneralizedPoissonÚ_discrete_results_docs)Úapprox_hess)Úcache_readonly)ÚConvergenceWarning)Údeepcopyc                   ó  ‡ — e Zd Zdej                  dej
                  z   dœz  Z	 	 dˆ fd„	Zd„ Zd„ Z	d„ Z
d„ Z	 	 	 dˆ fd	„	Zej                  j                  e_        	 	 	 	 dˆ fd
„	Zej                  j                  e_        d„ Z	 	 dd„Zˆ xZS )ÚTruncatedLFGenerica¾  
    Generic Truncated model for count data

    .. versionadded:: 0.14.0

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    truncation : int, optional
        Truncation parameter specify truncation point out of the support
        of the distribution. pmf(k) = 0 for k <= truncation
    úÞoffset : array_like
        Offset is added to the linear prediction with coefficient equal to 1.
    exposure : array_like
        Log(exposure) is added to the linear prediction with coefficient
        equal to 1.

    ©ÚparamsÚextra_paramsc                 óX  •— t        ‰	| �  ||f|||dœ|¤Ž | j                  |kD  }| j                  |   | _        | j                  |   | _        |�| j                  |   | _        |�| j
                  |   | _        || _        || _        | j                  j                  dg«       g | _
        y )N©ÚoffsetÚexposureÚmissingÚ
truncation)ÚsuperÚ__init__ÚendogÚexogr   r   Útruncr   Ú
_init_keysÚextendÚ_null_drop_keys)
Úselfr"   r#   r   r   r   r   ÚkwargsÚmaskÚ	__class__s
            €úhC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\statsmodels/discrete/truncated_model.pyr!   zTruncatedLFGeneric.__init__9   sµ   ø€ ä‰ÑØØð	ð ØØñ	ð ò	ð �z‰z˜JÑ&ˆØ—I‘I˜d‘OˆŒ	Ø—Z‘Z Ñ%ˆŒ
ØÐØŸ+™+ dÑ+ˆDŒKØÐØ ŸM™M¨$Ñ/ˆDŒMàˆŒ
Ø$ˆŒà�‰×Ñ ˜~Ô.Ø!ˆÕó    c                 óJ   — t        j                  | j                  |«      «      S )a`  
        Loglikelihood of Generic Truncated model

        Parameters
        ----------
        params : array-like
            The parameters of the model.

        Returns
        -------
        loglike : float
            The log-likelihood function of the model evaluated at `params`.
            See notes.

        Notes
        -----

        ©ÚnpÚsumÚ
loglikeobs©r(   r   s     r,   ÚloglikezTruncatedLFGeneric.loglikeQ   ó   € ô& �v‰v�d—o‘o fÓ-Ó.Ð.r-   c                 ó�  — | j                   j                  |«      }| j                  dz   }| j                  |dt	        j
                  |«      ¬«      j                  d«      }t	        j                  |t        j                   «      }|dkD  }t        j                  ||<   |dk  }t	        j                  d||   z
  «      ||<   ||z
  }|S )a†  
        Loglikelihood for observations of Generic Truncated model

        Parameters
        ----------
        params : array-like
            The parameters of the model.

        Returns
        -------
        loglike : ndarray (nobs,)
            The log likelihood for each observation of the model evaluated
            at `params`. See Notes

        Notes
        -----

        é   ú	prob-base©ÚwhichÚy_valueséÿÿÿÿ)Ú
model_mainr2   r$   Úpredictr0   Úaranger1   Ú	full_likeÚinfÚnanÚlog)r(   r   Úllf_mainÚytÚpmfÚlog_1_m_pmfÚlocÚllfs           r,   r2   zTruncatedLFGeneric.loglikeobsf   s·   € ð& —?‘?×-Ñ-¨fÓ5ˆà�Z‰Z˜!‰^ˆð �l‰lØ˜+´·	±	¸"³ð ó ?ß?B¹sÀ2»wð 	ô —l‘l 3¬¯©¨Ó0ˆØ�A‰gˆÜŸ6™6ˆ�CÑØ�A‰gˆÜŸ6™6 ! c¨#¡h¡,Ó/ˆ�CÑØ˜Ñ$ˆàˆ
r-   c                 óÂ  — | j                   j                  |«      }t        j                  | j                  t        j
                  ¬«      }t        j                  |t        j
                  ¬«      }t        | j                  dz   «      D ]µ  }| j                   j                  t        j                  | j                  «      |z  | j                  t        | dd«      t        | dd«      ¬«      }t        j                  |j                  |«      «      }||j                  |«      j                  |z  j                  z  }||z  }Œ· ||j                  d|z
  z  j                  z   }|S )á†  
        Generic Truncated model score (gradient) vector of the log-likelihood

        Parameters
        ----------
        params : array-like
            The parameters of the model

        Returns
        -------
        score : ndarray, 1-D
            The score vector of the model, i.e. the first derivative of the
            loglikelihood function, evaluated at `params`
        )Údtyper7   r   Nr   )r   r   )r=   Ú	score_obsr0   Ú
zeros_liker"   Úfloat64Úranger$   r+   Ú	ones_liker#   ÚgetattrÚexpr2   ÚT)	r(   r   Ú
score_mainrF   Úscore_truncÚiÚmodelÚpmf_iÚdparamss	            r,   rM   zTruncatedLFGeneric.score_obs”   s  € ð —_‘_×.Ñ.¨vÓ6ˆ
ä�m‰m˜DŸJ™J¬b¯j©jÔ9ˆä—m‘m J´b·j±jÔAˆÜ�t—z‘z A‘~Ó&ò 		ˆAØ—O‘O×-Ñ-Ü—‘˜TŸZ™ZÓ(¨1Ñ,Ø—	‘	Ü˜t X¨tÓ4Ü   z°4Ó8ð	 .ó ˆEô —F‘F˜5×+Ñ+¨FÓ3Ó4ˆEØ˜EŸO™O¨FÓ3×5Ñ5¸Ñ=×@Ñ@Ñ@ˆKØ�5‰L‰Cð		ð  §¡°°S±Ñ 9×<Ñ<Ñ<ˆàˆr-   c                 óB   — | j                  |«      j                  d«      S )rK   r   ©rM   r1   r3   s     r,   ÚscorezTruncatedLFGeneric.score·   ó   € ð �~‰~˜fÓ%×)Ñ)¨!Ó,Ð,r-   c
           
      óÚ  •— |€Àt        | dd«      t        | dd«      z   }t        j                  |«      dk(  r|dk(  rd }| j                  j	                  | j
                  | j                  |¬«      }t        j                  «       5  t        j                  dt        ¬«       |j                  d¬«      j                  }d d d «       | j                  dz   | j                  z   }| j
                  j                  d   |z
  | _        t#        ‰| �,  d|||||d	„ d
œ|
¤Ž}| j%                  | |j&                  «      }| j)                  |«      }|€i } |j*                  d|d|	dœ|¤Ž |S # 1 sw Y   Œ¦xY w)Nr   r   r   r7   ©r   Úignore©Úcategory©Údispc                 ó   — | S ©N© ©Úxs    r,   ú<lambda>z(TruncatedLFGeneric.fit.<locals>.<lambda>ß   ó   € ˜q€ r-   ©Ústart_paramsÚmethodÚmaxiterre   Úfull_outputÚcallbackT©Úcov_typeÚuse_selfÚuse_trh   )rR   r0   Úsizer=   r+   r"   r#   ÚwarningsÚcatch_warningsÚsimplefilterr   Úfitr   Údf_modelÚk_extraÚshapeÚdf_residr    Úresult_classÚ_resultsÚresult_class_wrapperÚ_get_robustcov_results)r(   rn   ro   rp   rq   re   rr   rt   Úcov_kwdsrv   r)   r   rX   Úk_paramsÚmlefitÚzipfitÚresultr+   s                    €r,   r{   zTruncatedLFGeneric.fitÈ   st  ø€ ð ÐÜ˜T 8¨QÓ/´'¸$À
ÈAÓ2NÑNˆFÜ�w‰w�v‹ !Ò#¨°!ªØ�Ø—O‘O×-Ñ-¨d¯j©j¸$¿)¹)Ø5;ð .ó =ˆEä×(Ñ(Ó*ñ 8Ü×%Ñ% hÔ9KÕLØ$Ÿy™y¨a˜yÓ0×7Ñ7�÷8ð
 —=‘= 1Ñ$ t§|¡|Ñ3ˆØŸ
™
×(Ñ(¨Ñ+¨hÑ6ˆŒä‘‘ð Ø%ØØØØ#Ù ñð ñˆð ×"Ñ" 4¨¯©Ó9ˆØ×*Ñ*¨6Ó2ˆàÐØˆHà%ˆ×%Ñ%ð 	N¨xØ/3¸5ñ	NØDLò	Nàˆ÷58ð 8ús   Â8E!Å!E*c                 óz  •— t        j                  |«      dk(  r6|dk7  r1| j                  j                  d   }|t        j                  |«      z  }|}|€”t        | dd«      t        | dd«      z   }t        j                  |«      dk(  r|dk(  rd }| j                  j                  | j                  | j                  |¬«      } |j                  d	||||d||||	|
|dœ|¤Žj                  }t        t        | �&  d	|||||||||	|
|dœ|¤Ž}|dv r| j                  | |«      }nt        d|z  «      ‚| j                  |«      S ©
Nr7   r   r   r   r`   )rn   ro   rp   rq   re   rr   ÚalphaÚ	trim_modeÚauto_trim_tolÚsize_trim_tolÚqc_tol)Úl1Úl1_cvxopt_cpz+argument method == %s, which is not handledrh   ©r0   rw   r#   r~   ÚonesrR   r=   r+   r"   Úfit_regularizedr   r    r	   Úresult_class_regÚ	TypeErrorÚresult_class_reg_wrapper©r(   rn   ro   rp   rq   re   rr   r‹   rŒ   r�   rŽ   r�   r)   r…   Úalpha_pr   rX   ÚcntfitÚdiscretefitr+   s                      €r,   r”   z"TruncatedLFGeneric.fit_regularizedï   ó}  ø€ ô �7‰7�5‹>˜QÒ 5¨A¢:Ø—y‘y—‘ qÑ)ˆHØœBŸG™G HÓ-Ñ-ˆEàˆØÐÜ˜T 8¨QÓ/´'¸$À
ÈAÓ2NÑNˆFÜ�w‰w�v‹ !Ò#¨°!ªØ�Ø—O‘O×-Ñ-¨d¯j©j¸$¿)¹)Ø5;ð .ó =ˆEà0˜5×0Ñ0ð FØ)°&À'Ø'¨a¸(Ø¨Ø+Ø+°FñFð
 ?EñF÷
 GMÁfð ô ”z 4Ñ8ð FØ)°&À'Ø'¨d¸XØ yÀØ+°Fñ	Fð ?Eñ	Fˆð Ð+Ñ+Ø×/Ñ/°°fÓ=‰KäØAÀFÑJóLð Lð ×,Ñ,¨[Ó9Ð9r-   c                 ó.   — t        || j                  «      S )a‡  
        Generic Truncated model Hessian matrix of the loglikelihood

        Parameters
        ----------
        params : array-like
            The parameters of the model

        Returns
        -------
        hess : ndarray, (k_vars, k_vars)
            The Hessian, second derivative of loglikelihood function,
            evaluated at `params`

        Notes
        -----
        ©r   r4   r3   s     r,   ÚhessianzTruncatedLFGeneric.hessian  ó   € ô$ ˜6 4§<¡<Ó0Ð0r-   c                 ó	  — | j                  |||¬«      \  }}}t        j                  ||d|j                  d    «      }||z   |z   }|dk(  �r,t        j                  |«      }	| j
                  dk(  r!| j                  j                  |	|«      }
|	|
z  S | j
                  dk(  r|	S | j
                  dkD  r¼t        j                  t        j                  d| j
                  dz   «      «      }| j                  j                  ||t        j                  |«      |d|¬«      }|j                  d«      }t        j                  | j
                  dz   «      |z  j                  d«      }|	|z
  d|z
  z  }|S t        d	«      ‚|d
k(  r|S |dk(  rt        j                  |«      S |dk(  �r|�t        j                  |«      }nIt        j                  t        j                  dt        j                  | j                  «      dz   «      «      }t        j                  |«      dd…df   }	| j                  dk(  r)| j                   j#                  ||	| j$                  «      }|S | j                  dk(  rD| j                  j&                  }| j                   j#                  ||	|d   || j$                  «      }|S t        d«      ‚|dk(  r„|�t        j(                  |«      }n6t        j                  dt        j                  | j                  «      dz   «      }| j                  j                  ||t        j                  |«      |d|¬«      }|S |dk(  �r=t        j                  |«      }	t        j                  t        j                  d| j
                  dz   «      «      }| j                  j                  ||t        j                  |«      |d|¬«      }|j                  d«      }t        j                  | j
                  dz   «      |z  j                  d«      }|	|z
  d|z
  z  }t        j                  | j
                  dz   «      dz  |z  j                  d«      }| j                  j+                  |	|«      }|	dz  |z   |z
  d|z
  z  }||dz  z
  }|S t        d|z  «      ‚)aù	  
        Predict response variable or other statistic given exogenous variables.

        Parameters
        ----------
        params : array_like
            The parameters of the model.
        exog : ndarray, optional
            Explanatory variables for the main count model.
            If ``exog`` is None, then the data from the model will be used.
        offset : ndarray, optional
            Offset is added to the linear predictor of the mean function with
            coefficient equal to 1.
            Default is zero if exog is not None, and the model offset if exog
            is None.
        exposure : ndarray, optional
            Log(exposure) is added to the linear predictor with coefficient
            equal to 1. If exposure is specified, then it will be logged by
            the method. The user does not need to log it first.
            Default is one if exog is is not None, and it is the model exposure
            if exog is None.
        which : str (optional)
            Statitistic to predict. Default is 'mean'.

            - 'mean' : the conditional expectation of endog E(y | x)
            - 'mean-main' : mean parameter of truncated count model.
              Note, this is not the mean of the truncated distribution.
            - 'linear' : the linear predictor of the truncated count model.
            - 'var' : returns the estimated variance of endog implied by the
              model.
            - 'prob-trunc' : probability of truncation. This is the probability
              of observing a zero count implied
              by the truncation model.
            - 'prob' : probabilities of each count from 0 to max(endog), or
              for y_values if those are provided. This is a multivariate
              return (2-dim when predicting for several observations).
              The probabilities in the truncated region are zero.
            - 'prob-base' : probabilities for untruncated base distribution.
              The probabilities are for each count from 0 to max(endog), or
              for y_values if those are provided. This is a multivariate
              return (2-dim when predicting for several observations).


        y_values : array_like
            Values of the random variable endog at which pmf is evaluated.
            Only used if ``which="prob"``

        Returns
        -------
        predicted values

        Notes
        -----
        If exposure is specified, then it will be logged by the method.
        The user does not need to log it first.
        ©r#   r   r   Nr7   Úmeanr   r<   Úprob)r#   r   r   r:   r;   zunsupported self.truncationÚlinearú	mean-mainzk_extra is not 0 or 1r8   Úvaré   z argument which == %s not handled)Ú_get_predict_arraysr0   Údotr~   rS   r   r=   Ú_prob_nonzeroÚ
atleast_2dr?   r>   r1   Ú
ValueErrorÚmaxr"   r}   Ú
model_distrF   r$   ÚparameterizationÚasarrayÚ_var)r(   r   r#   r   r   r:   r;   ÚfittedÚlinpredÚmuÚ	prob_mainÚcountsÚprobsÚprob_tregionÚmean_tregionr£   ÚpÚmnc2_tregionÚvmÚmnc2Úvs                        r,   r>   zTruncatedLFGeneric.predict*  s  € ðt "&×!9Ñ!9ØØØð ":ó "Ñˆˆf�hô —‘˜˜f ^ d§j¡j°¡mÐ4Ó5ˆØ˜8Ñ# fÑ,ˆà�F‹?Ü—‘˜“ˆBØ�‰ !Ò#Ø ŸO™O×9Ñ9¸"¸fÓE�	Ø˜I‘~Ð%Ø—‘ BÒ&Ø�	Ø—‘ 1Ò$ÜŸ™¤r§y¡y°°D·O±OÀaÑ4GÓ'HÓI�àŸ™×/Ñ/Ø ´·±°xÓ0@Ø!¨¸&ð 0ó B�ð  %Ÿy™y¨›|�Ü "§	¡	¨$¯/©/¸AÑ*=Ó >ÀÑ F×KÑKÈAÓN�Ø˜\Ñ)¨a°,Ñ.>Ñ?�Ø�ä Ð!>Ó?Ð?Ø�hÒØˆNØ�kÒ!Ü—6‘6˜'“?Ð"Ø�f‹_ØÐ#ÜŸ™ xÓ0‘äŸ™¤r§y¡y°´B·F±F¸4¿:¹:Ó4FÀqÑ4HÓ'IÓJ�Ü—‘˜“¢ D Ñ)ˆBØ�|‰|˜qÒ àŸ™×+Ñ+¨F°B¸¿
¹
ÓC�ð ˆLð —‘ Ò"Ø—O‘O×4Ñ4�ØŸ™×+Ñ+¨F°B¸¸r¹
Ø,-¨t¯z©zó;�ð ˆLô !Ð!8Ó9Ð9à�kÒ!ØÐ#ÜŸ™ HÓ-‘äŸ™ 1¤b§f¡f¨T¯Z©ZÓ&8¸Ñ&:Ó;�à—O‘O×+Ñ+Ø˜T¬B¯F©F°8Ó,<Ø V°fð ,ó >ˆEð ˆLØ�e‹^Ü—‘˜“ˆBÜ—]‘]¤2§9¡9¨Q°·±À!Ñ0CÓ#DÓEˆFà—O‘O×+Ñ+Ø˜T¬B¯F©F°8Ó,<Ø V°fð ,ó >ˆEð !Ÿ9™9 Q›<ˆLÜŸI™I d§o¡o¸Ñ&9Ó:¸UÑB×GÑGÈÓJˆLØ˜Ñ%¨!¨lÑ*:Ñ;ˆDÜŸI™I d§o¡o¸Ñ&9Ó:¸AÑ=Ø!ñ"ß#&¡3 q£6ð à—‘×%Ñ% b¨&Ó1ˆBà˜‘E˜B‘J Ñ-°!°lÑ2BÑCˆDØ�t˜Q‘w‘ˆAØˆHäØ2°UÑ:ó<ð <r-   )r   NNÚnone©	NÚbfgsé#   r7   r7   NÚ	nonrobustNN©Nr�   Údefined_by_methodr7   r7   Nr   Úautog{®Gáz„?g-Cëâ6?g¸…ëQ¸ž?©NNNr£   N)Ú__name__Ú
__module__Ú__qualname__ÚbaseÚ_model_params_docÚ_missing_param_docÚ__doc__r!   r4   r2   rM   r]   r{   r   r”   rŸ   r>   Ú__classcell__©r+   s   @r,   r   r      s¼   ø„ ðð" ×+Ñ+ðð ×
!Ñ
!ñ"ñ#ñ##€Gð6 :>Ø(.õ"ò0/ò*,ò\!òF-ð" =?Ø,0Ø7;õ#ðJ  ×#Ñ#×+Ñ+€C„Kð -1ØIMØIMØõ	#:ðJ ,×;Ñ;×CÑC€OÔò1ð( @DØ'+÷G<r-   r   c                   óh   ‡ — e Zd Zdej                  dej
                  z   dœz  Z	 	 dˆ fd„	Zd„ Zˆ xZ	S )r   a¾  
    Truncated Poisson model for count data

    .. versionadded:: 0.14.0

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    truncation : int, optional
        Truncation parameter specify truncation point out of the support
        of the distribution. pmf(k) = 0 for k <= truncation
    r   r   c           
      ó  •— t        ‰| �  ||f||||dœ|¤Ž t        | j                  | j                  t        | dd «      t        | dd «      ¬«      | _        t        | _        t        | _
        t        | _        t        | _        t        | _        y )N©r   r   r   r   r   r   )r   r   )r    r!   r   r"   r#   rR   r=   r   r¯   ÚTruncatedLFPoissonResultsr€   Ú TruncatedLFGenericResultsWrapperr‚   ÚL1TruncatedLFGenericResultsr•   Ú"L1TruncatedLFGenericResultsWrapperr—   )	r(   r"   r#   r   r   r   r   r)   r+   s	           €r,   r!   zTruncatedLFPoisson.__init__Ð  sŽ   ø€ ä‰ÑØØð	ð ØØ!Øñ	ð ò	ô " $§*¡*¨d¯i©iÜ+2°4¸ÀTÓ+JÜ)0°°xÀÓ)Fô$ˆŒô +ˆŒä5ˆÔÜ$DˆÔ!Ü ;ˆÔÜ(JˆÕ%r-   c                 ób   — dt        j                  | «      z
  }||z  }|d|z
  |dz  z  z
  }||fS )áÓ  Predict mean and variance of zero-truncated distribution.

        experimental api, will likely be replaced by other methods

        Parameters
        ----------
        params : array_like
            The model parameters. This is only used to extract extra params
            like dispersion parameter.
        mu : array_like
            Array of mean predictions for main model.

        Returns
        -------
        Predicted conditional variance.
        r7   r¨   )r0   rS   )r(   r   rµ   ÚwÚmÚvar_s         r,   Ú_predict_mom_trunc0z&TruncatedLFPoisson._predict_mom_trunc0æ  s?   € ð" ”—‘˜˜“‰_ˆØ�‰FˆØ�A˜‘E˜Q ™T‘>Ñ!ˆØ�$ˆwˆr-   )NNr   rÀ   ©
rÉ   rÊ   rË   rÌ   rÍ   rÎ   rÏ   r!   rÞ   rÐ   rÑ   s   @r,   r   r   ´  sG   ø„ ðð" ×+Ñ+ðð ×
!Ñ
!ñ"ñ#ñ##€Gð6 ;?Ø'-õKö,r-   r   c                   óh   ‡ — e Zd Zdej                  dej
                  z   dœz  Z	 	 dˆ fd„	Zd„ Zˆ xZ	S )r   aÔ  
    Truncated Generalized Negative Binomial model for count data

    .. versionadded:: 0.14.0

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    truncation : int, optional
        Truncation parameter specify truncation point out of the support
        of the distribution. pmf(k) = 0 for k <= truncation
    r   r   c           
      óÎ  •— t        ‰	| �  ||f||||dœ|¤Ž t        | j                  | j                  t        | dd «      t        | dd «      |¬«      | _        | j                  j                  | _        | j                  j                  | j                  j                  | j                   d  «       t        | _        t        | _        t        | _        t         | _        t$        | _        y ©NrÔ   r   r   )r   r   r»   )r    r!   r   r"   r#   rR   r=   r}   Ú
exog_namesr&   r   r¯   Ú TruncatedNegativeBinomialResultsr€   rÖ   r‚   r×   r•   rØ   r—   ©
r(   r"   r#   r   r   r   r»   r   r)   r+   s
            €r,   r!   z%TruncatedLFNegativeBinomialP.__init__  sÍ   ø€ ä‰ÑØØð	ð ØØ!Øñ	ð ò	ô ,Ø�J‰JØ�I‰IÜ˜T :¨tÓ4Ü˜4 ¨4Ó0ØôˆŒð —‘×.Ñ.ˆŒØ�‰×Ñ˜tŸ™×9Ñ9¸4¿<¹<¸-¸.ÐIÔJÜ)ˆŒä<ˆÔÜ$DˆÔ!Ü ;ˆÔÜ(JˆÕ%r-   c                 óÄ   — |d   }| j                   j                  }d|||dz
  z  z  z   d|z  z  }d|z
  }||z  }|d|||dz
  z  z  z   z  }|dz  |z   |z  }	|	|dz  z
  }
||
fS )rÚ   r<   r7   r¨   )r=   r°   )r(   r   rµ   r‹   r»   Ú	prob_zerorÛ   rÜ   r½   r¾   rÝ   s              r,   rÞ   z0TruncatedLFNegativeBinomialP._predict_mom_trunc04  s’   € ð& �r‘
ˆØ�O‰O×,Ñ,ˆØ˜  a¨¡c¡Ñ*Ñ*¨c°E©kÑ:ˆ	Ø�	‰MˆØ�‰FˆØ�1�u˜r A a¡C™yÑ(Ñ(Ñ)ˆà�A‘˜‘
˜aÑˆØ�a˜‘d‰{ˆØ�$ˆwˆr-   ©NNr   r¨   rÀ   rß   rÑ   s   @r,   r   r   ý  sG   ø„ ðð" ×+Ñ+ðð ×
!Ñ
!ñ"ñ#ñ##€Gð6 ;?Ø,2õKö6r-   r   c                   ób   ‡ — e Zd Zdej                  dej
                  z   dœz  Z	 	 dˆ fd„	Zˆ xZS )ÚTruncatedLFGeneralizedPoissonaÊ  
    Truncated Generalized Poisson model for count data

    .. versionadded:: 0.14.0

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    truncation : int, optional
        Truncation parameter specify truncation point out of the support
        of the distribution. pmf(k) = 0 for k <= truncation
    r   r   c           
      óÆ  •— t        ‰	| �  ||f||||dœ|¤Ž t        | j                  | j                  t        | dd «      t        | dd «      |¬«      | _        | j                  j                  | _        | j                  j                  | j                  j                  | j                   d  «       d | _
        t        | _        t        | _        t        | _        t"        | _        y râ   )r    r!   r   r"   r#   rR   r=   r}   rã   r&   r¯   rä   r€   rÖ   r‚   r×   r•   rØ   r—   rå   s
            €r,   r!   z&TruncatedLFGeneralizedPoisson.__init__o  sÍ   ø€ ä‰ÑØØð	ð ØØ!Øñ	ð ò	ô -Ø�J‰JØ�I‰IÜ˜T :¨tÓ4Ü˜4 ¨4Ó0ØôˆŒð —‘×.Ñ.ˆŒØ�‰×Ñ˜tŸ™×9Ñ9¸4¿<¹<¸-¸.ÐIÔJØˆŒÜ<ˆÔä$DˆÔ!Ü ;ˆÔÜ(JˆÕ%r-   rè   ©	rÉ   rÊ   rË   rÌ   rÍ   rÎ   rÏ   r!   rÐ   rÑ   s   @r,   rê   rê   S  sH   ø„ ðð" ×+Ñ+ðð ×
!Ñ
!ñ"ñ#ñ##€Gð6 ;?Ø,2÷Kñ Kr-   rê   c                   ó  ‡ — e Zd Zdej                  dej
                  z   dœz  Z	 	 dˆ fd„	Zd„ Zd„ Z	d„ Z
d„ Z	 	 	 dˆ fd	„	Zej                  j                  e_        	 	 	 	 dˆ fd
„	Zej                  j                  e_        d„ Zˆ xZS )Ú_RCensoredGenerica  
    Generic right Censored model for count data

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    r   r   c                 óª   •— t        j                  |dk(  «      d   | _        t        j                  |«      d   | _        t	        ‰| �  ||f|||dœ|¤Ž y )Nr   r   )r0   ÚnonzeroÚzero_idxÚnonzero_idxr    r!   ©r(   r"   r#   r   r   r   r)   r+   s          €r,   r!   z_RCensoredGeneric.__init__¢  s_   ø€ äŸ
™
 5¨A¡:Ó.¨qÑ1ˆŒÜŸ:™: eÓ,¨QÑ/ˆÔÜ‰ÑØØð	ð ØØñ	ð ó	r-   c                 óJ   — t        j                  | j                  |«      «      S )a_  
        Loglikelihood of Generic Censored model

        Parameters
        ----------
        params : array-like
            The parameters of the model.

        Returns
        -------
        loglike : float
            The log-likelihood function of the model evaluated at `params`.
            See notes.

        Notes
        -----

        r/   r3   s     r,   r4   z_RCensoredGeneric.loglike¯  r5   r-   c           
      óð   — | j                   j                  |«      }t        j                  || j                     t        j
                  dt        j                  || j                     «      z
  «      f«      }|S )a…  
        Loglikelihood for observations of Generic Censored model

        Parameters
        ----------
        params : array-like
            The parameters of the model.

        Returns
        -------
        loglike : ndarray (nobs,)
            The log likelihood for each observation of the model evaluated
            at `params`. See Notes

        Notes
        -----

        r7   )r=   r2   r0   Úconcatenaterñ   rC   rS   rò   )r(   r   rD   rI   s       r,   r2   z_RCensoredGeneric.loglikeobsÄ  sc   € ð& —?‘?×-Ñ-¨fÓ5ˆä�n‰nØ�d—m‘mÑ$Ü�V‰V�AœŸ™˜x¨×(8Ñ(8Ñ9Ó:Ñ:Ó;ð=óˆð
 ˆ
r-   c           	      ó�  — | j                   j                  |«      }| j                   j                  |«      }t        j                  || j
                     || j                     j                  t        j                  || j                     «       z  dt        j                  || j                     «      z
  z  j                  f«      }|S )á…  
        Generic Censored model score (gradient) vector of the log-likelihood

        Parameters
        ----------
        params : array-like
            The parameters of the model

        Returns
        -------
        score : ndarray, 1-D
            The score vector of the model, i.e. the first derivative of the
            loglikelihood function, evaluated at `params`
        r7   )	r=   rM   r2   r0   rö   rñ   rò   rT   rS   )r(   r   rU   rD   r]   s        r,   rM   z_RCensoredGeneric.score_obsà  s«   € ð —_‘_×.Ñ.¨vÓ6ˆ
Ø—?‘?×-Ñ-¨fÓ5ˆä—‘Ø�t—}‘}Ñ%Ø˜×(Ñ(Ñ)×+Ñ+Ü�f‰f�X˜d×.Ñ.Ñ/Ó0Ð0ñ1à”"—&‘&˜ $×"2Ñ"2Ñ3Ó4Ñ4ñ6ç78±qð	 ó ˆð ˆr-   c                 óB   — | j                  |«      j                  d«      S )rø   r   r\   r3   s     r,   r]   z_RCensoredGeneric.scoreû  r^   r-   c
           
      ó`  •— |€Àt        | dd«      t        | dd«      z   }t        j                  |«      dk(  r|dk(  rd }| j                  j	                  | j
                  | j                  |¬«      }t        j                  «       5  t        j                  dt        ¬«       |j                  d¬«      j                  }d d d «       t        ‰| �,  d|||||d	„ d
œ|
¤Ž}| j                  | |j                  «      }| j!                  |«      }|€i } |j"                  d|d|	dœ|¤Ž |S # 1 sw Y   ŒixY w)Nr   r   r   r7   r`   ra   rb   rd   c                 ó   — | S rg   rh   ri   s    r,   rk   z'_RCensoredGeneric.fit.<locals>.<lambda>  rl   r-   rm   Trs   rh   )rR   r0   rw   r=   r+   r"   r#   rx   ry   rz   r   r{   r   r    r€   r�   r‚   rƒ   )r(   rn   ro   rp   rq   re   rr   rt   r„   rv   r)   r   rX   r†   r‡   rˆ   r+   s                   €r,   r{   z_RCensoredGeneric.fit  sB  ø€ ð ÐÜ˜T 8¨QÓ/´'¸$À
ÈAÓ2NÑNˆFÜ�w‰w�v‹ !Ò#¨°!ªØ�Ø—O‘O×-Ñ-¨d¯j©j¸$¿)¹)Ø5;ð .ó =ˆEä×(Ñ(Ó*ñ 8Ü×%Ñ% hÔ9KÕLØ$Ÿy™y¨a˜yÓ0×7Ñ7�÷8ô ‘‘ð Ø%ØØØØ#Ù ñð ñˆð ×"Ñ" 4¨¯©Ó9ˆØ×*Ñ*¨6Ó2ˆàÐØˆHà%ˆ×%Ñ%ð 	N¨xØ/3¸5ñ	NØDLò	Nàˆ÷+8ð 8ús   Â8D$Ä$D-c                 óz  •— t        j                  |«      dk(  r6|dk7  r1| j                  j                  d   }|t        j                  |«      z  }|}|€”t        | dd«      t        | dd«      z   }t        j                  |«      dk(  r|dk(  rd }| j                  j                  | j                  | j                  |¬«      } |j                  d	||||d||||	|
|dœ|¤Žj                  }t        t        | �&  d	|||||||||	|
|dœ|¤Ž}|dv r| j                  | |«      }nt        d|z  «      ‚| j                  |«      S rŠ   r’   r˜   s                      €r,   r”   z!_RCensoredGeneric.fit_regularized.  rœ   r-   c                 ó.   — t        || j                  «      S )a†  
        Generic Censored model Hessian matrix of the loglikelihood

        Parameters
        ----------
        params : array-like
            The parameters of the model

        Returns
        -------
        hess : ndarray, (k_vars, k_vars)
            The Hessian, second derivative of loglikelihood function,
            evaluated at `params`

        Notes
        -----
        rž   r3   s     r,   rŸ   z_RCensoredGeneric.hessianU  r    r-   ©NNrÀ   rÁ   rÅ   )rÉ   rÊ   rË   rÌ   rÍ   rÎ   rÏ   r!   r4   r2   rM   r]   r{   r   r”   rŸ   rÐ   rÑ   s   @r,   rî   rî   ‹  sª   ø„ ðð ×+Ñ+ðð ×
!Ñ
!ñ"ñ#ñ#€Gð, ;?Øõò/ò*ò8ò6-ð" =?Ø,0Ø7;õð@  ×#Ñ#×+Ñ+€C„Kð -1ØIMØIMØõ	#:ðJ ,×;Ñ;×CÑC€OÔö1r-   rî   c                   ób   ‡ — e Zd Zdej                  dej
                  z   dœz  Z	 	 dˆ fd„	Zˆ xZS )Ú_RCensoredPoissonzû
    Censored Poisson model for count data

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    r   r   c                 ó  •— t        ‰| �  ||f|||dœ|¤Ž t        t        j                  | j
                  «      | j                  «      | _        d | _        t        | _
        t        | _        t        | _        t        | _        y ©Nr   )r    r!   r   r0   rN   r"   r#   r=   r¯   ÚTruncatedLFGenericResultsr€   rÖ   r‚   r×   r•   rØ   r—   ró   s          €r,   r!   z_RCensoredPoisson.__init__�  sx   ø€ ä‰ÑØØð	
ð ØØñ	
ð ò	
ô "¤"§-¡-°·
±
Ó";¸T¿Y¹YÓGˆŒØˆŒÜ5ˆÔÜ$DˆÔ!Ü ;ˆÔÜ(JˆÕ%r-   rþ   rì   rÑ   s   @r,   r   r   j  sH   ø„ ðð ×+Ñ+ðð ×
!Ñ
!ñ"ñ#ñ#€Gð, ,0Ø(.÷Kñ Kr-   r   c                   ób   ‡ — e Zd Zdej                  dej
                  z   dœz  Z	 	 dˆ fd„	Zˆ xZS )Ú_RCensoredGeneralizedPoissona  
    Censored Generalized Poisson model for count data

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    r   r   c                 ó  •— t        ‰| �  ||f|||dœ|¤Ž t        t        j                  | j
                  «      | j                  «      | _        d | _        t        | _
        t        | _        t        | _        t        | _        y r  )r    r!   r   r0   rN   r"   r#   r=   r¯   r  r€   rÖ   r‚   r×   r•   rØ   r—   ©	r(   r"   r#   r   r»   r   r   r)   r+   s	           €r,   r!   z%_RCensoredGeneralizedPoisson.__init__ª  su   ø€ ä‰ÑØ�4ð	'Ø &°Øñ	'à%ò	'ô -Ü�M‰M˜$Ÿ*™*Ó% t§y¡yó2ˆŒàˆŒÜ5ˆÔÜ$DˆÔ!Ü ;ˆÔÜ(JˆÕ%r-   ©Nr¨   NrÀ   rì   rÑ   s   @r,   r  r  “  sH   ø„ ðð ×+Ñ+ðð ×
!Ñ
!ñ"ñ#ñ#€Gð, 45Ø(.÷Kñ Kr-   r  c                   ób   ‡ — e Zd Zdej                  dej
                  z   dœz  Z	 	 dˆ fd„	Zˆ xZS )Ú_RCensoredNegativeBinomialPa  
    Censored Negative Binomial model for count data

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    r   r   c                 ó
  •— t        ‰| �  ||f|||dœ|¤Ž t        t        j                  | j
                  «      | j                  |¬«      | _        d | _        t        | _
        t        | _        t        | _        t        | _        y )Nr   ©r»   )r    r!   r   r0   rN   r"   r#   r=   r¯   r  r€   rÖ   r‚   r×   r•   rØ   r—   r  s	           €r,   r!   z$_RCensoredNegativeBinomialP.__init__Ð  s€   ø€ ä‰ÑØØð	ð ØØñ	ð ò	ô ,¬B¯M©M¸$¿*¹*Ó,EØ,0¯I©IØ./ô.ˆŒð ˆŒÜ5ˆÔÜ$DˆÔ!Ü ;ˆÔÜ(JˆÕ%r-   r  rì   rÑ   s   @r,   r
  r
  ¹  sH   ø„ ðð ×+Ñ+ðð ×
!Ñ
!ñ"ñ#ñ#€Gð, 45Ø(.÷Kñ Kr-   r
  c                   ón   ‡ — e Zd Zdej                  dej
                  z   dœz  Zeedddfˆ fd„	Z	d„ Z
ˆ xZS )Ú
_RCensoredzó
    Censored model for count data

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    r   r   NrÀ   c                 óª  •— t        ‰
| �  ||f|||dœ|¤Ž  |t        j                  | j                  «      | j
                  «      | _        || _        | j                  j                  x| _        }	|	dkD  r3| j                  j                  | j                  j                  |	 d  «       t        | _        t        | _        t        | _        t"        | _        y )Nr   r   )r    r!   r0   rN   r"   r#   r=   r¯   r}   rã   r&   r  r€   rÖ   r‚   r×   r•   rØ   r—   )r(   r"   r#   rX   Údistributionr   r   r   r)   r}   r+   s             €r,   r!   z_RCensored.__init__ü  s¼   ø€ ô 	‰ÑØØð	ð ØØñ	ð ò	ñ  ¤§¡¨d¯j©jÓ 9¸4¿9¹9ÓEˆŒØ&ˆŒà!%§¡×!8Ñ!8Ð8ˆŒ�wØ�QŠ;Ø�O‰O×"Ñ" 4§?¡?×#=Ñ#=¸w¸h¸iÐ#HÔIä5ˆÔÜ$DˆÔ!Ü ;ˆÔÜ(JˆÕ%r-   c                 ó>   — | j                   j                  ||«      }|S )zrProbability that count is not zero

        internal use in Censored model, will be refactored or removed
        )r=   r«   )r(   rµ   r   Úprob_nzs       r,   r«   z_RCensored._prob_nonzero  s   € ð
 —/‘/×/Ñ/°°FÓ;ˆØˆr-   )rÉ   rÊ   rË   rÌ   rÍ   rÎ   rÏ   r   r   r!   r«   rÐ   rÑ   s   @r,   r  r  å  sN   ø„ ðð ×+Ñ+ðð ×
!Ñ
!ñ"ñ#ñ#€Gð, +2Ø.°tØ¨õKö.r-   r  c                   óÂ   ‡ — e Zd Zdej                  dej
                  z   dœz  Z	 	 	 	 d	ˆ fd„	Zd„ Zd„ Z		 	 	 d
d„Z
ej                  j                  e
_        	 	 dd„Zˆ xZS )r   aª  
    Hurdle model for count data

    .. versionadded:: 0.14.0

    %(params)s
    %(extra_params)s

    Attributes
    ----------
    endog : array
        A reference to the endogenous response variable
    exog : array
        A reference to the exogenous design.
    dist : string
        Log-likelihood type of count model family. 'poisson' or 'negbin'
    zerodist : string
        Log-likelihood type of zero hurdle model family. 'poisson', 'negbin'
    p : scalar
        Define parameterization for count model.
        Used when dist='negbin'.
    pzero : scalar
        Define parameterization parameter zero hurdle model family.
        Used when zerodist='negbin'.
    aJ  offset : array_like
        Offset is added to the linear prediction with coefficient equal to 1.
    exposure : array_like
        Log(exposure) is added to the linear prediction with coefficient
        equal to 1.

    Notes
    -----
    The parameters in the NegativeBinomial zero model are not identified if
    the predicted mean is constant. If there is no or only little variation in
    the predicted mean, then convergence might fail, hessian might not be
    invertible or parameter estimates will have large standard errors.

    References
    ----------
    not yet

    r   c
                 óî   •— |€|�d}t        |«      ‚t        ‰| �  ||f|||	dœ|
¤Ž d| _        d| _        | j                  ||||«       t        | _        t        | _	        t        | _        t        | _        y )Nz+Offset and exposure are not yet implementedr   r   )ÚNotImplementedErrorr    r!   Úk_extra1Úk_extra2Ú_initializeÚHurdleCountResultsr€   ÚHurdleCountResultsWrapperr‚   ÚL1HurdleCountResultsr•   ÚL1HurdleCountResultsWrapperr—   )r(   r"   r#   r   ÚdistÚzerodistr»   Úpzeror   r   r)   Úmsgr+   s               €r,   r!   zHurdleCountModel.__init__J  s‘   ø€ ð
 Ð HÐ$8Ø?ˆCÜ% cÓ*Ð*Ü‰ÑØØð	ð ØØñ	ð ò	ð ˆŒØˆŒà×Ñ˜˜x¨¨EÔ2Ü.ˆÔÜ$=ˆÔ!Ü 4ˆÔÜ(CˆÕ%r-   c                 óð  — |dvs|dvrt        d«      ‚|dk(  r,t        | j                  | j                  t        ¬«      | _        nE|dk(  r@t        | j                  | j                  t        ¬«      | _        | xj                  dz  c_        |dk(  r&t        | j                  | j                  «      | _	        y |dk(  r=t        | j                  | j                  |¬«      | _	        | xj                  dz  c_        y y )N)ÚpoissonÚnegbinz,dist and zerodist must be "poisson","negbin"r"  )rX   r#  r7   r  )r  r  r"   r#   r   Úmodel1r   r  r   Úmodel2r   r  )r(   r  r  r»   r  s        r,   r  zHurdleCountModel._initializec  sÍ   € ØÐ-Ñ-ØÐ 5Ñ5Ü%ð '1ó 2ð 2ð �yÒ Ü$ T§Z¡Z°·±Ä'ÔJˆD�KØ˜Ò!Ü$ T§Z¡Z°·±Ü+<ô>ˆDŒKà�MŠM˜QÑ�Mà�9ÒÜ,¨T¯Z©Z¸¿¹ÓCˆD�KØ�XÒÜ6°t·z±zÀ4Ç9Á9Ø9:ô<ˆDŒKà�MŠM˜QÑŽMð r-   c                 óø   — t        t        |«      | j                  z
  | j                  z
  dz  «      | j                  z   }| j                  j                  |d| «      | j                  j                  ||d «      z   S )a]  
        Loglikelihood of Generic Hurdle model

        Parameters
        ----------
        params : array-like
            The parameters of the model.

        Returns
        -------
        loglike : float
            The log-likelihood function of the model evaluated at `params`.
            See notes.

        Notes
        -----

        r¨   N)ÚintÚlenr  r  r$  r4   r%  )r(   r   Úks      r,   r4   zHurdleCountModel.loglikew  sq   € ô& ”�V“˜tŸ}™}Ñ,¨t¯}©}Ñ<ÀÑAó Ø—M‘Mñ"ˆà—‘×#Ñ# F¨2¨A JÓ/Ø—‘×#Ñ# F¨1¨2 JÓ/ñ0ð 	1r-   c
           
      ó>  — |dk7  rt        d«      ‚ | j                  j                  d|||||d„ dœ|
¤Ž} | j                  j                  d|||||d„ dœ|
¤Ž}t	        |«      }| |j
                  _        |j                  d   |j                  d   g|j                  d<   t        j                  |j
                  j                  |j
                  j                  «      |j
                  _
        |j
                  xj                  |j
                  j                  z  c_        | xj                  t        |j
                  dd«      z  c_        | xj                  t        |j
                  dd«      z  c_        | j                  | j                  z   d	z   | _        | j                  j                   D �cg c]  }d
|z   ‘Œ	 }}|| j                  j                   z   | j                   d d  ddlm} d |j
                  _        	 |j
                  j)                  «       }|j
                  j)                  «       } |||«      |j
                  _        | j-                  | |j
                  ||«      }| j/                  |«      }|S c c}w # t         $ r}dt+        |«      vr‚ Y d }~ŒRd }~ww xY w)NrÄ   z'robust cov_type currently not supportedc                 ó   — | S rg   rh   ri   s    r,   rk   z&HurdleCountModel.fit.<locals>.<lambda>™  ó   € ¸€ r-   rm   c                 ó   — | S rg   rh   ri   s    r,   rk   z&HurdleCountModel.fit.<locals>.<lambda>   r,  r-   Ú	convergedr}   r   r7   Úzm_)Ú
block_diagzneed covariancerh   )r­   r$  r{   r%  r   r�   rX   Úmle_retvalsr0   Úappendr   r|   r  rR   r  r}   rã   Úscipy.linalgr0  Únormalized_cov_paramsÚ
cov_paramsÚstrr€   r‚   )r(   rn   ro   rp   rq   re   rr   rt   r„   rv   r)   Úresults1Úresults2rˆ   ÚnameÚxnames1r0  Úcov1Úcov2ÚeÚmodelfits                        r,   r{   zHurdleCountModel.fit�  sZ  € ð �{Ò"ÜÐFÓGÐGà"�4—;‘;—?‘?ð Ø%Ø 7°Ø#©kñð ñ	ˆð #�4—;‘;—?‘?ð Ø%Ø 7°Ø#©kñð ñ	ˆô ˜(Ó#ˆØ $ˆ�‰ÔØ+3×+?Ñ+?ÀÑ+LØ+3×+?Ñ+?ÀÑ+Lð+Nˆ×Ñ˜;Ñ'ä!#§¡¨8×+<Ñ+<×+CÑ+CØ+3×+<Ñ+<×+CÑ+Có"Eˆ�‰Ôð 	�‰× Ò  H×$5Ñ$5×$>Ñ$>Ñ>Õ à�Šœ ×!2Ñ!2°I¸qÓAÑA�Ø�Šœ ×!2Ñ!2°I¸qÓAÑA�ØŸ™¨¯©Ñ5¸Ñ9ˆŒØ,0¯K©K×,BÑ,BÖC D�5˜4“<ÐCˆÐCØ$ t§{¡{×'=Ñ'=Ñ=ˆ�‰™Ðõ 	,Ø04ˆ�‰Ô-ð	Ø×$Ñ$×/Ñ/Ó1ˆDØ×$Ñ$×/Ñ/Ó1ˆDÙ4>¸tÀTÓ4JˆF�O‰OÔ1ð ×$Ñ$ T¨6¯?©?¸HÀhÓOˆØ×*Ñ*¨8Ó4ˆàˆùò' Døô ò 	Ø ¬¨A«Ñ.àô /ûð	ús   Æ-I6Ç9AI; É;	JÊJÊJc                 óÐ  — |j                  «       }|€dnd}| j                  |||¬«      \  }}}d}|€|r| j                  }n|}t        t	        |«      | j
                  z
  | j                  z
  dz  «      | j
                  z   }	|d|	 }
||	d }t        j                  ||d| j                  j                  d    «      |z   |z   }| j                  j                  |
|¬«      }| j                  j                  j                  ||
«      }d|z
  }t        j                  |«      }| j                  j                  j                  ||«      }|dk(  r|t        j                  |«      z  |z  S |d	k(  rt        j                  |«      S |d
k(  r|S |dk(  rt        j                  |«      |z  S |dk(  r|S |dk(  r|S |dk(  rd|z
  S |dk(  rJt        j                  |«      }| j                  j!                  ||«      \  }}||z  |d|z
  z  |dz  z  z   }|S |dk(  rK| j                  j                  ||t        j                  |«      |d|¬«      }||dd…df   z  }||dd…df<   |S t#        d|z  «      ‚)a  
        Predict response variable or other statistic given exogenous variables.

        Parameters
        ----------
        params : array_like
            The parameters of the model.
        exog : ndarray, optional
            Explanatory variables for the main count model.
            If ``exog`` is None, then the data from the model will be used.
        exog_infl : ndarray, optional
            Explanatory variables for the zero-inflation model.
            ``exog_infl`` has to be provided if ``exog`` was provided unless
            ``exog_infl`` in the model is only a constant.
        offset : ndarray, optional
            Offset is added to the linear predictor of the mean function with
            coefficient equal to 1.
            Default is zero if exog is not None, and the model offset if exog
            is None.
        exposure : ndarray, optional
            Log(exposure) is added to the linear predictor with coefficient
            equal to 1. If exposure is specified, then it will be logged by
            the method. The user does not need to log it first.
            Default is one if exog is is not None, and it is the model exposure
            if exog is None.
        which : str (optional)
            Statitistic to predict. Default is 'mean'.

            - 'mean' : the conditional expectation of endog E(y | x)
            - 'mean-main' : mean parameter of truncated count model.
              Note, this is not the mean of the truncated distribution.
            - 'linear' : the linear predictor of the truncated count model.
            - 'var' : returns the estimated variance of endog implied by the
              model.
            - 'prob-main' : probability of selecting the main model which is
              the probability of observing a nonzero count P(y > 0 | x).
            - 'prob-zero' : probability of observing a zero count. P(y=0 | x).
              This is equal to is ``1 - prob-main``
            - 'prob-trunc' : probability of truncation of the truncated count
              model. This is the probability of observing a zero count implied
              by the truncation model.
            - 'mean-nonzero' : expected value conditional on having observation
              larger than zero, E(y | X, y>0)
            - 'prob' : probabilities of each count from 0 to max(endog), or
              for y_values if those are provided. This is a multivariate
              return (2-dim when predicting for several observations).

        y_values : array_like
            Values of the random variable endog at which pmf is evaluated.
            Only used if ``which="prob"``

        Returns
        -------
        predicted values

        Notes
        -----
        'prob-zero' / 'prob-trunc' is the ratio of probabilities of observing
        a zero count between hurdle model and the truncated count model.
        If this ratio is larger than one, then the hurdle model has an inflated
        number of zeros compared to the count model. If it is smaller than one,
        then the number of zeros is deflated.
        NTFr¢   r¨   r7   )r#   r£   r¦   r¥   zmean-nonzeroz	prob-zeroz	prob-mainz
prob-truncr§   r¤   r9   r   zwhich = %s is not available)Úlowerr©   r#   r'  r(  r  r  r0   rª   r~   r$  r>   r=   r«   rS   r%  rÞ   r­   )r(   r   r#   r   r   r:   r;   Úno_exogÚ	exog_zeroÚk_zerosÚparams_zeroÚparams_mainÚlin_predÚmu1r¶   rç   Úmu2Úprob_ntruncrµ   ÚmtÚvtrÝ   Ú
probs_mains                          r,   r>   zHurdleCountModel.predictÇ  s›  € ðB —‘“ˆØ˜,‘$¨EˆØ!%×!9Ñ!9ØØØð ":ó "Ñˆˆf�hð ˆ	ØÐÙØ ŸI™I‘	à �	ä”s˜6“{ T§]¡]Ñ2°T·]±]ÑBÀaÑGó ØŸ-™-ñ(ˆà˜X˜gÐ&ˆØ˜W˜XÐ&ˆä—F‘F˜4 Ð-@¨d¯i©i¯o©o¸aÑ.@Ð!AÓBØñØ%ñ&ˆð �k‰k×!Ñ! +°DÐ!Ó9ˆà—K‘K×*Ñ*×8Ñ8¸¸kÓJˆ	Ø˜‘]ˆ	ä�f‰f�XÓˆØ—k‘k×,Ñ,×:Ñ:¸3ÀÓLˆà�FŠ?ØœrŸv™v hÓ/Ñ/°+Ñ=Ð=Ø�kÒ!Ü—6‘6˜(Ó#Ð#Ø�hÒØˆOØ�nÒ$Ü—6‘6˜(Ó# kÑ1Ð1Ø�kÒ!ØÐØ�kÒ!ØÐØ�lÒ"Ø�{‘?Ð"à�eŠ^ä—‘˜Ó!ˆBØ—[‘[×4Ñ4°[À"ÓE‰FˆB�Ø˜r‘> I°°Y±Ñ$?À"ÀaÁ%Ñ$GÑGˆDØˆKØ�fŠ_ØŸ™×,Ñ,Ø˜T¤2§6¡6¨(Ó#3°VÀ6Ø!ð -ó #ˆJð ˜)¢A t GÑ,Ñ,ˆJØ(ˆJ’q˜!�tÑØÐäÐ:¸UÑBÓCÐCr-   )Nr"  r"  r¨   r¨   NrÀ   rÁ   rÈ   )rÉ   rÊ   rË   rÌ   rÍ   rÎ   rÏ   r!   r  r4   r{   r   r>   rÐ   rÑ   s   @r,   r   r     s†   ø„ ðð0 ×+Ñ+ðð" ×
!Ñ
!ñ#"ñ#ñ1+#€GðZ ,0Ø*3ØØ(.õDò2ò(1ð0 =?Ø,0Ø7;ó4ðl  ×#Ñ#×+Ñ+€C„Kà26Ø48÷~Dr-   r   c                   ó   — e Zd Zedddœz  Zy)r  z%A results class for Generic TruncatedÚ ©Úone_line_descriptionÚ
extra_attrN)rÉ   rÊ   rË   r   rÏ   rh   r-   r,   r  r  H  s   „ Ø$Ø GØñ(ñ �Gr-   r  c                   ó,   — e Zd Zedddœz  Zed„ «       Zy)rÕ   z%A results class for Truncated PoissonrN  rO  c                 óÔ   — | j                   j                  dk7  rd}t        |«      ‚t        j                  | j                  d¬«      «      }d|t        j                  |«      dz
  z  z
  S )Nr   ú0dispersion is only available for zero-truncationr¥   ©r:   r7   )rX   r$   r  r0   rS   r>   )r(   r   rµ   s      r,   Ú_dispersion_factorz,TruncatedLFPoissonResults._dispersion_factorS  sY   € à�:‰:×Ñ˜qÒ ØDˆCÜ% cÓ*Ð*ä�V‰V�D—L‘L x�LÓ0Ó1ˆà�Bœ"Ÿ&™& ›* q™.Ñ)Ñ)Ð*r-   N©rÉ   rÊ   rË   r   rÏ   r   rV  rh   r-   r,   rÕ   rÕ   N  s+   „ Ø$Ø GØñ(ñ €Gð ñ+ó ñ+r-   rÕ   c                   ó,   — e Zd Zedddœz  Zed„ «       Zy)rä   z/A results class for Truncated Negative BinomialrN  rO  c                 óP  — | j                   j                  dk7  rd}t        |«      ‚| j                  d   }| j                   j                  j
                  }t        j                  | j                  d¬«      «      }d|||dz
  z  z  t        j                  ||dz
  z  «      dz
  z  z
  S )Nr   rT  r<   r¥   rU  r7   )	rX   r$   r  r   r=   r°   r0   rS   r>   )r(   r   r‹   r»   rµ   s        r,   rV  z3TruncatedNegativeBinomialResults._dispersion_factord  s’   € à�:‰:×Ñ˜qÒ ØDˆCÜ% cÓ*Ð*à—‘˜B‘ˆØ�J‰J×!Ñ!×2Ñ2ˆÜ�V‰V�D—L‘L x�LÓ0Ó1ˆà�E˜B  1¡™IÑ%¬¯©°°Q°q±S±	Ó):¸QÑ)>Ñ?Ñ?Ð@r-   NrW  rh   r-   r,   rä   rä   ^  s-   „ Ø$à=Øñ(ñ €Gð
 ñ	Aó ñ	Ar-   rä   c                   ó   — e Zd Zy)r×   N©rÉ   rÊ   rË   rh   r-   r,   r×   r×   q  ó   „ Ør-   r×   c                   ó   — e Zd Zy)rÖ   Nr[  rh   r-   r,   rÖ   rÖ   u  r\  r-   rÖ   c                   ó   — e Zd Zy)rØ   Nr[  rh   r-   r,   rØ   rØ   }  r\  r-   rØ   c                   óR   ‡ — e Zd Zedddœz  Z	 dˆ fd„	Zed„ «       Zed„ «       Zˆ xZ	S )r  z A results class for Hurdle modelrN  rO  c                 óÆ   •— t         ‰| �  |||||¬«       || _        || _        | j                  j
                  j                  d   t        | j                  «      z
  | _	        y )N)rt   r„   rv   r   )
r    r!   Úresults_zeroÚresults_countrX   r"   r~   r(  r   r   )	r(   rX   r†   ra  rb  rt   r„   rv   r+   s	           €r,   r!   zHurdleCountResults.__init__Š  s`   ø€ ä‰ÑØØØØØð 	ô 	ð )ˆÔØ*ˆÔàŸ
™
×(Ñ(×.Ñ.¨qÑ1´C¸¿¹Ó4DÑDˆ�r-   c                 ó„   — | j                   j                  j                  | j                  j                  j                  z   S rg   )ra  r�   Úllnullrb  ©r(   s    r,   rd  zHurdleCountResults.llnull˜  s6   € à×!Ñ!×*Ñ*×1Ñ1Ø×"Ñ"×+Ñ+×2Ñ2ñ3ð 	4r-   c                 ó~   — t        j                  | j                  j                  | j                  j                  «      S rg   )r0   r2  ra  Úbserb  re  s    r,   rg  zHurdleCountResults.bse�  s+   € ä�y‰y˜×*Ñ*×.Ñ.°×0BÑ0B×0FÑ0FÓGÐGr-   )rÄ   NN)
rÉ   rÊ   rË   r   rÏ   r!   r   rd  rg  rÐ   rÑ   s   @r,   r  r  …  sN   ø„ Ø$Ø BØñ(ñ €Gð
 =AõEð ñ4ó ð4ð ñHó ôHr-   r  c                   ó   — e Zd Zy)r  Nr[  rh   r-   r,   r  r  ¢  r\  r-   r  c                   ó   — e Zd Zy)r  Nr[  rh   r-   r,   r  r  ¦  r\  r-   r  c                   ó   — e Zd Zy)r  Nr[  rh   r-   r,   r  r  ®  r\  r-   r  )8Ú__all__rx   Únumpyr0   Ústatsmodels.base.modelrÌ   rX   Ústatsmodels.base.wrapperÚwrapperÚwrapÚ#statsmodels.regression.linear_modelÚ
regressionÚlinear_modelÚlmÚ"statsmodels.distributions.discreter   r   Ú#statsmodels.discrete.discrete_modelr   r	   r
   r   r   r   r   r   Ústatsmodels.tools.numdiffr   Ústatsmodels.tools.decoratorsr   Ústatsmodels.tools.sm_exceptionsr   Úcopyr   r   r   r   rê   rî   r   r  r
  r  r   r  rÕ   rä   r×   ÚRegressionResultsWrapperrÖ   Úpopulate_wrapperrØ   r  r  r  r  rh   r-   r,   ú<module>r}     sá  ðò€ó Û ß %Ð %ß 'Ð 'ß 0Ð 0÷÷	÷ 	ó 	õ 2Ý 7Ý >Ý ôT<˜ô T<ônFÐ+ô FôRSÐ#5ô Sôl5KÐ$6ô 5Kôp\1˜
ô \1ô~&KÐ)ô &KôR#KÐ#4ô #KôL)KÐ"3ô )KôX4Ð"ô 4ôniD�zô iDôX	 ô ô+Ð 9ô +ô AÐ'@ô Aô&	 .Ð2Kô 	ô	 r×'BÑ'Bô 	ð €× Ñ Ð6Ø/ô1ô	¨×)DÑ)Dô 	ð €× Ñ Ð8Ø1ô3ôH˜ô Hô:	˜>Ð+=ô 	ô	 × ;Ñ ;ô 	ð €× Ñ Ð/Ø(ô*ô	 "×"=Ñ"=ô 	ð €× Ñ Ð1Ø*õ,r-   