
    'YHhk+                     j   d dl Zd dlZd dl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mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z  ddgZ! G d	 d
      Z"eeeeeeeeeeeeeeedZ#d4dZ$d 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"      Z0 G d$ d%e"      Z1 G d& d'e"      Z2 G d( d)e"      Z3 G d* d+e"      Z4 G d, d-e"      Z5d. Z6d/ Z7d0 Z8d1 Z9d2 Z:d3 Z;y)5    N)assert_allcloseassert_equalassert_almost_equal)	dmatrices)QuantReg   )biweight_chamberlainbiweight_hsheatherbiweight_bofingercosine_chamberlaincosine_hsheathercosine_bofingergaussian_chamberlaingaussian_hsheathergaussian_bofingerepan2_chamberlainepan2_hsheatherepan2_bofingerparzen_chamberlainparzen_hsheatherparzen_bofingerepanechnikov_hsheather_q75	Rquantregincome	Interceptc                   N    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)CheckModelResultsMixinc                     t        t        j                  | j                  j                  j
                  t                 | j                  j                  d d df   d       y )Nr   MbP?rtol)	r   npravelres1paramslocidxres2tableselfs    n/var/www/html/planif/env/lib/python3.12/site-packages/statsmodels/regression/tests/test_quantile_regression.pytest_paramsz"CheckModelResultsMixin.test_params   s@    !1!1!5!5c!:;		1-D	:    c                    t        | j                  j                  d       t        t	        j
                  | j                  j                  j                  t                 | j                  j                  d d df   d       y )Nr   r   r    )r   r$   scaler   r"   r#   bser&   r'   r(   r)   r*   s    r,   test_bsezCheckModelResultsMixin.test_bse   sP    TYY__a(!2!23!78		1-D	:r.   c                     t        t        j                  | j                  j                  j
                  t                 | j                  j                  d d df   d       y )N   {Gz?r    )	r   r"   r#   r$   tvaluesr&   r'   r(   r)   r*   s    r,   test_tvaluesz#CheckModelResultsMixin.test_tvalues   s@    !2!2!6!6s!;<		1-D	:r.   c                 X   t         j                  j                  j                  | j                  j
                  d d df   | j                  j                        }t        t        j                  | j                  j                  j                  t                 |d       t         j                  j                  j                  | j                  j                  | j                  j                        dz  }t        t        j                  | j                  j                        |dd       y )Nr4   g?r    g&.>g|=r!   atol)scipystatstsfr(   r)   df_rr   r"   r#   r$   pvaluesr&   r'   r6   )r+   pvals_statapvals_ts      r,   test_pvaluesz#CheckModelResultsMixin.test_pvalues#   s    kkmm&&tyyq!t'<diinnM!2!2!6!6s!;<##	/ ++--""499#4#4diinnEI!2!23d	8r.   c                     t        | j                  j                         j                  t           | j
                  j                  d d dd f   d       y )Nr   r    )r   r$   conf_intr&   r'   r(   r)   r*   s    r,   test_conf_intz$CheckModelResultsMixin.test_conf_int-   s<    		**,005		23/d	<r.   c                 p    t        | j                  j                  | j                  j                  d       y Nr   r    )r   r$   nobsr(   Nr*   s    r,   	test_nobsz CheckModelResultsMixin.test_nobs1   s    				$?r.   c                 p    t        | j                  j                  | j                  j                  d       y rI   )r   r$   df_modelr(   df_mr*   s    r,   test_df_modelz$CheckModelResultsMixin.test_df_model4        		**DIINNFr.   c                 p    t        | j                  j                  | j                  j                  d       y rI   )r   r$   df_residr(   r?   r*   s    r,   test_df_residz$CheckModelResultsMixin.test_df_resid7   rQ   r.   c                 p    t        | j                  j                  | j                  j                  d       y rI   )r   r$   	prsquaredr(   
psrsquaredr*   s    r,   test_prsquaredz%CheckModelResultsMixin.test_prsquared:   s"    		++TYY-A-AMr.   c                     t        t        j                  | j                  j                        | j
                  j                  d       y rI   )r   r"   arrayr$   sparsityr(   r*   s    r,   test_sparsityz$CheckModelResultsMixin.test_sparsity=   s.    !3!34		**	7r.   c                     t        t        j                  | j                  j                        | j
                  j                  d       y rI   )r   r"   rZ   r$   	bandwidthr(   kbwidthr*   s    r,   test_bandwidthz%CheckModelResultsMixin.test_bandwidthA   s.    !4!45		))	6r.   N)__name__
__module____qualname__r-   r2   r7   rC   rG   rL   rP   rT   rX   r\   r`    r.   r,   r   r      s=    ::
:8<@GGN76r.   r   ))biwbofinger)re   chamberlain)re   	hsheather)cosrf   )ri   rg   )ri   rh   gaurf   )rk   rg   )rk   rh   )parrf   )rl   rg   )rl   rh   )eparf   )rm   rg   )rm   rh   c                     t         j                  j                  j                         j                  }t        d|d      \  }}t        ||      j                  d| |      }t        | |f   }||fS )Nfoodexp ~ income	dataframereturn_typeiid)vcovkernelr^   )	smdatasetsengelload_pandasdatar   r   fitd)ru   r^   rz   yXstatsmstatas          r,   	setup_funr   a   si    ;;((*//D';GDAqa^U6YOFvy!"E5=r.   c                     t         j                  j                  j                         j                  } t        d| d      \  }}t        ||      j                  d      }t        t        j                  |j                        t        j                  d       t        t        j                  |j                               t        j                  d       t        t        j                  |j                        t        j                  d       y )Nro   rp   rq   皙?)q   )rv   rw   rx   ry   rz   r   r   r{   r   r"   rZ   fittedvaluesr   predictresid	residuals)rz   r}   r~   ress       r,   test_fitted_residualsr   i   s    ;;((*//D';GDAq
1a.

r

"C!1!12I4J4JAN/1G1GK+Y-@-@!Dr.   c                       e Zd Zed        Zy)TestEpanechnikovHsheatherQ75c                     t         j                  j                  j                         j                  }t        d|d      \  }}t        ||      j                  dddd      | _        t        | _
        y )	Nro   rp   rq   g      ?rs   rm   rh   )r   rt   ru   r^   )rv   rw   rx   ry   rz   r   r   r{   r$   r   r(   )clsrz   r}   r~   s       r,   setup_classz(TestEpanechnikovHsheatherQ75.setup_classu   s`    {{  ,,.33+T{K1Aq>%%%0; & =-r.   Nra   rb   rc   classmethodr   rd   r.   r,   r   r   s   s    . .r.   r   c                       e Zd Zed        Zy)TestEpanechnikovBofingerc                 6    t        dd      \  | _        | _        y )Nrm   rf   r   r$   r(   r   s    r,   r   z$TestEpanechnikovBofinger.setup_class       &uj9#(r.   Nr   rd   r.   r,   r   r   ~       : :r.   r   c                       e Zd Zed        Zy)TestEpanechnikovChamberlainc                 6    t        dd      \  | _        | _        y )Nrm   rg   r   r   s    r,   r   z'TestEpanechnikovChamberlain.setup_class       &um<#(r.   Nr   rd   r.   r,   r   r          = =r.   r   c                       e Zd Zed        Zy)TestEpanechnikovHsheatherc                 6    t        dd      \  | _        | _        y )Nrm   rh   r   r   s    r,   r   z%TestEpanechnikovHsheather.setup_class       &uk:#(r.   Nr   rd   r.   r,   r   r          ; ;r.   r   c                       e Zd Zed        Zy)TestGaussianBofingerc                 6    t        dd      \  | _        | _        y )Nrk   rf   r   r   s    r,   r   z TestGaussianBofinger.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestGaussianChamberlainc                 6    t        dd      \  | _        | _        y )Nrk   rg   r   r   s    r,   r   z#TestGaussianChamberlain.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestGaussianHsheatherc                 6    t        dd      \  | _        | _        y )Nrk   rh   r   r   s    r,   r   z!TestGaussianHsheather.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestBiweightBofingerc                 6    t        dd      \  | _        | _        y )Nre   rf   r   r   s    r,   r   z TestBiweightBofinger.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestBiweightChamberlainc                 6    t        dd      \  | _        | _        y )Nre   rg   r   r   s    r,   r   z#TestBiweightChamberlain.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestBiweightHsheatherc                 6    t        dd      \  | _        | _        y )Nre   rh   r   r   s    r,   r   z!TestBiweightHsheather.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestCosineBofingerc                 6    t        dd      \  | _        | _        y )Nri   rf   r   r   s    r,   r   zTestCosineBofinger.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestCosineChamberlainc                 6    t        dd      \  | _        | _        y )Nri   rg   r   r   s    r,   r   z!TestCosineChamberlain.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestCosineHsheatherc                 6    t        dd      \  | _        | _        y )Nri   rh   r   r   s    r,   r   zTestCosineHsheather.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestParzeneBofingerc                 6    t        dd      \  | _        | _        y )Nrl   rf   r   r   s    r,   r   zTestParzeneBofinger.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestParzeneChamberlainc                 6    t        dd      \  | _        | _        y )Nrl   rg   r   r   s    r,   r   z"TestParzeneChamberlain.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                       e Zd Zed        Zy)TestParzeneHsheatherc                 6    t        dd      \  | _        | _        y )Nrl   rh   r   r   s    r,   r   z TestParzeneHsheather.setup_class   r   r.   Nr   rd   r.   r,   r   r      r   r.   r   c                  @   t        j                  ddgddgddgddggt         j                        } t        j                  g dt         j                        }t        ||       j	                  dd	      }|j                          t        |j                  t        j                  d
dg      dd       t        |j                  t        j                  ddg      dd       t        |j                  t        j                  g d      dd       t        j                  ddgddgddgddggt         j                        } t        j                  g dt         j                        }t        ||       j	                  dd	      }|j                          t        |j                  t        j                  ddg      dd       t        |j                  t        j                  ddg      dd       t        |j                  t        j                  g d      dd       y )Nr   r    @@dtyper   r   r4            ?rg   )r^           g|zK?g-C6?g#B;r9   g~w?gjȲ?Ԧ?)r   g'*7+?g]gՐ>r   g6Vz>g'KϦ?gר?)g6Vzg)*?gg/>)
r"   rZ   float64r   r{   summaryr   r%   r1   r   r~   r}   r   s      r,   test_zero_residr      s    	1a&1a&1c(QH5RZZHA
RZZ0A
1a.

SM

:CKKMCJJHHc:./E+ CGGHHi45E+ CIIHH ? @E+
 	1a&3(QHq#h7rzzJA
RZZ0A
1a.

SM

:CKKMCJJ..)I JE+CGGRXXz:&>?d CIIrxx )J  KE+r.   c                  L   t        j                  ddgddgddgddggt         j                        } t        j                  g dt         j                        }t        ||       j	                  ddd	
      }|j                         }dt        |      v sJ dt        |      vsJ y )Nr   r   r   r   r   r   r   rg   Tr^   use_tzP>|t|zP>|z|r"   rZ   r   r   r{   r   str)r~   r}   r   summs       r,   test_use_t_summaryr   
  s    
1a&1a&1c(QH5RZZHA
RZZ0A
1a.

SM

FC;;=Dc$i#d)###r.   c                  P   t        j                  ddgddgddgddggt         j                        } t        j                  g dt         j                        }t        ||       j	                  ddd	
      }|j                  d      }dt        |      vsJ dt        |      v sJ y )Nr   r   r   r   r   r   r   rg   Tr   g?)alphaz[0.025      0.975]z[0.1        0.9]r   )r~   r}   r   summ_20s       r,   test_alpha_summaryr     s    
1a&1a&1c(QH5RZZHA
RZZ0A
1a.

SM

FCkkk#Gs7|333W---r.   c                  
   t        j                  ddgddgddgddggt         j                        } t        j                  g dt         j                        }t        ||       j	                  d      }|j                          y )Nr   r   r   r   r   r   r   )r"   rZ   r   r   r{   remove_datar   s      r,   test_remove_datar     sc    
1a&1a&1c(QH5RZZHA
RZZ0A
1a.

S
!COOr.   c                  8   t        j                  g dg dg dg dgt         j                        } t        j                  g dt         j                        }t        ||       j	                  d      }t        |j                        | j                  d   k(  sJ y )	N)r   r   r   )r   r   g?)r   r   g      ?)r   r   g      ?r   r   r   r   )r"   rZ   r   r   r{   lenr%   shape)r~   r}   res_collinears      r,   test_collinear_matrixr   &  sp    
*j{,35::	?A
RZZ0AQN&&s+M}##$
222r.   c                  \   t         j                  j                  d      } t         j                  j                  d      dz  }t         j                  j                  d      }t        j                  d      }t         j                  j                  d      dz  }t        j                  || ||| f      }t         j                  j                  |      |j                  d   k  sJ t        ||      j                  d      }t        |j                        |j                  d   k(  sJ t         j                  j                  |j                               |j                  d   dz
  k(  sJ t        ||d d d df         j                  d      }t        |j                  |j                  d       y )	Ni  
   r   r   r   r5   r    )r"   randomonescolumn_stacklinalgmatrix_rankr   r   r{   r   r%   
cov_paramsr   r   )x_onex_twox_three	interceptr}   r~   res_singularres_nss           r,   test_nontrivial_singular_matrixr   /  sM   IIT"EIIT"2%Eiit$GI
		q A
E5'5ABA99  #aggaj000Aq>%%c*L|""#qwwqz11199  !8!8!:;qwwqzA~MMM a1crc6#'',FL--v/B/BNr.   rj   )<scipy.statsr;   numpyr"   numpy.testingr   r   r   patsyr   statsmodels.apiapirv   *statsmodels.regression.quantile_regressionr   #results.results_quantile_regressionr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r'   r   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rd   r.   r,   <module>r      s}     L L   ?	+ 	+ 	+ 	+ 	+ .6 .6b ,1-)/++1-)/+ ).*)6E.#9 .:5 :="8 =; 6 ;:1 :=4 =;2 ;:1 :=4 =;2 ;:/ :=2 =;0 ;:0 :=3 =;1 ;* +F$.3Or.   