
    !ggi                     H   d Z ddlZddlZddlZddlZddlmc m	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 ddlmc mZ ddlmZ dd	lmZmZmZ ddlm c m!Z" d
dl#m$Z% ejL                  jO                  ejL                  jQ                  e)            Z*ejL                  jW                  e*dd      Z, ejZ                  e,d      Z.e.j_                         Z0e0d   Z1e0dje                            Z3 ee3d      Z4 ejj                  e0d   e6      Z7 ejj                  e0d         Z8 G d d      Z9 G d de9      Z: G d de9      Z; G d de9      Z< G d de9      Z= G d d e9      Z> G d! d"e9      Z? G d# d$e9      Z@ G d% d&e9      ZA G d' d(e9      ZB G d) d*e9      ZC G d+ d,e9      ZD G d- d.e9      ZE G d/ d0e9      ZF G d1 d2e9      ZG G d3 d4e9      ZH G d5 d6e9      ZI G d7 d8e9      ZJ G d9 d:e9      ZK G d; d<      ZL G d= d>eL      ZM G d? d@eL      ZN G dA dBeL      ZO G dC dDeL      ZP G dE dFeL      ZQ G dG dHeL      ZR G dI dJeL      ZS G dK dLeL      ZT G dM dNeL      ZU G dO dPeL      ZV G dQ dReL      ZW G dS dTeW      ZX G dU dVeL      ZY G dW dXeL      ZZ G dY dZeL      Z[y)[z>

Created on Mon Dec 09 21:29:20 2013

Author: Josef Perktold
    N)GLM)families)links)OLSget_robustcov_results)add_constant)assert_allcloseassert_equalassert_   )results_count_robust_clusterresultsz	ships.csvF)	index_colaccidentzyr_con op_75_79)prependshipservicec                   F    e Zd Zd Zed        Zedd       Zd Zd Zd Z	y)	CheckCountRobustMixinc                     | j                   }| j                  }t        |j                        t        |j                        dz
  k(  r[t	        j
                  t        |j                        t        j                        }d|d<   |j                  |   }|j                  |   }n|j                  }|j                  }t        |j                  j                  |d       t        | j                  | j                  z  |d       y )Nr   F-C6?giUMu?)res1res2lenparamsnponesbool_bser
   _resultsbse_rob	corr_fact)selfr   r   maskres2_paramsres2_bses         i/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/statsmodels/discrete/tests/test_sandwich_cov.py
test_basicz CheckCountRobustMixin.test_basic1   s    yyyyt{{DKK 01 45773t{{+RXX6DDH++d+Kxx~H++KxxH,,k4@t~~5xF    c                     | j                   }t        j                  |t              }t        j                  |      | _        | j                  |      | _        y N)r   swcov_clustergroupse_covr#   get_correction_factorr$   )clsr   cov_clus      r)   get_robust_cluz$CheckCountRobustMixin.get_robust_cluC   s=    xx..u-ii(11$7r+   c                     |j                   }|j                  j                  \  }}|rt        |j                        }nd}|dz
  t        ||z
        z  }t        j                  |      S )Nr         ?)modelexogshaper   r   floatr   sqrt)r3   r   sub_kparamsmodnobsk_varsk_paramsr$   s           r)   r2   z+CheckCountRobustMixin.get_correction_factorK   sZ    mmxx~~f 7>>*HHBY%x"88	wwy!!r+   c                     | j                   }| j                  }t        |j                  j                  |j
                  d       t        |j                  j                  |j                  d       y )Nr   )r   r   r
   r"   llfllllnullll_0)r%   r   r   s      r)   test_othzCheckCountRobustMixin.test_oth\   sH    yyyy))477D9,,dii>r+   c                 B    t        j                  | j                         y r-   )smtcheck_ttest_tvaluesr   r%   s    r)   
test_ttestz CheckCountRobustMixin.test_ttestc       		*r+   c                 B    t        j                  | j                         y r-   )rI   check_ftest_pvaluesr   rK   s    r)   test_waldtestz#CheckCountRobustMixin.test_waldtestg   rM   r+   N)T)
__name__
__module____qualname__r*   classmethodr5   r2   rG   rL   rP    r+   r)   r   r   .   s?    G$ 8 8 " " ?++r+   r   c                       e Zd Zed        Zy)TestPoissonCluc                     t         j                  | _        t        j                  t
        t              }|j                  d      | _        | j                          y )NFdisp)

results_stresults_poisson_clur   smdPoissonendogr9   fitr   r5   r3   r>   s     r)   setup_classzTestPoissonClu.setup_classm   s=    11kk%&777&r+   NrQ   rR   rS   rT   rb   rU   r+   r)   rW   rW   k        r+   rW   c                       e Zd Zed        Zy)TestPoissonCluGenericc           	         t         j                  | _        t        j                  t
        t              }|j                  d      x| _        }d}|r| j                  j                  j                         | _        |j                  d      x| _        }| j                          | j                  | _        | j                  j                         | _        |j                  d      x| _        }ddlm}  || j                  j$                  dt&        dddd       | j                  j                  | _        | j)                  | j                        | _        y )NFrY   r   r   clusterTgroupsuse_correctiondf_correctionuse_tuse_self)r[   r\   r   r]   r^   r_   r9   r`   r   r!   copybse_nonrobustr5   res3r#   bse_rob3statsmodels.base.covtyper   r"   r0   r2   r$   )r3   r>   r   debugr   s        r)   rb   z!TestPoissonCluGeneric.setup_classw   s   11kk%&''u'--4 # 1 1 3C!gg5g11CHt xxCH;;++-CL!gg5g11CHtB 	chh//9>AE@D8=;?	A hhll11#((;r+   Nrc   rU   r+   r)   rf   rf   u   s    < <r+   rf   c                       e Zd Zed        Zy)TestPoissonHC1Genericc                 \   t         j                  | _        t        j                  t
        t              }|j                  d      | _        ddl	m
}  || j                  j                  dd       | j                  j                  | _        | j                  | j                  d      | _        y )	NFrY   r   r   HC1Trn   r=   )r[   results_poisson_hc1r   r]   r^   r_   r9   r`   r   rs   r   r"   r!   r#   r2   r$   )r3   r>   r   s      r)   rb   z!TestPoissonHC1Generic.setup_class   sv    11kk%&777&B 	chh//Fhhll11#((1Nr+   Nrc   rU   r+   r)   rv   rv      s    O Or+   rv   c                   "    e Zd Zed        Zd Zy)TestPoissonCluFitc           
         t         j                  | _        t        j                  t
        t              }|j                  j                  \  }}|dz
  t        ||z
        z  }|j                  ddt        t        dd|z  d      d      | _        d | j                  j                  _        | j                  j                  | _        d| _        y )Nr7   Frh   T)rj   rk   scaling_factorrl   rZ   cov_typecov_kwdsrm   r   )r[   r\   r   r]   r^   r_   r9   r:   r;   r`   dictr0   r   r"   normalized_cov_paramsr!   r#   r$   )r3   r>   r?   rA   sc_facts        r)   rb   zTestPoissonCluFit.setup_class   s     11kk%& h 7eD8O4477	$(8<8:W7;%= "'   37/hhll r+   c                    | j                   }| j                  }d}t        |j                  |j                  d       t        |j                  |j                  |       t        |j
                  |j
                  |d       t        |j                  |j                  |d       |j                  d d ddf   }t        |j                         |dd       y )	NHz>g:0yE>rtol)r   atolg#B;      Ơ>)	r   r   r
   r   r!   tvaluespvaluesparams_tableconf_int)r%   r   r   r   cis        r)   test_basic_inferencez&TestPoissonCluFit.test_basic_inference   s    yyyyT[[t<$((6dllDIdllEJq!A#v&$UCr+   N)rQ   rR   rS   rT   rb   r   rU   r+   r)   r}   r}      s     @	Dr+   r}   c                       e Zd Zed        Zy)TestPoissonHC1Fitc                    t         j                  | _        t        j                  t
        t              }|j                  dd      | _        | j                  j                  | _
        | j                  | j                  d      | _        y )NFrx   rZ   r   rz   )r[   r{   r   r]   r^   r_   r9   r`   r   r!   r#   r2   r$   ra   s     r)   rb   zTestPoissonHC1Fit.setup_class   s]    11kk%&7776hhll11#((1Nr+   Nrc   rU   r+   r)   r   r          O Or+   r   c                       e Zd Zed        Zy)TestPoissonHC1FitExposurec                     t         j                  | _        t        j                  t
        t        t              }|j                  dd      | _	        | j                  j                  | _        | j                  | j                  d      | _        y )NexposureFrx   r   rz   )r[   results_poisson_exposure_hc1r   r]   r^   r_   r9   r   r`   r   r!   r#   r2   r$   ra   s     r)   rb   z%TestPoissonHC1FitExposure.setup_class   s_    ::kk%97776hhll11#((1Nr+   Nrc   rU   r+   r)   r   r      r   r+   r   c                       e Zd Zed        Zy)TestPoissonCluExposurec                     t         j                  | _        t        j                  t
        t        t              }|j                  d      | _	        | j                          y Nr   FrY   )r[   results_poisson_exposure_clur   r]   r^   r_   r9   r   r`   r   r5   ra   s     r)   rb   z"TestPoissonCluExposure.setup_class   s?    ::kk%9777&r+   Nrc   rU   r+   r)   r   r      rd   r+   r   c                       e Zd Zed        Zy)TestPoissonCluExposureGenericc           	      x   t         j                  | _        t        j                  t
        t        t              }|j                  d      x| _	        }ddl
m}  || j                  j                  dt        dddd       | j                  j                  | _        | j!                  | j                        | _        y )	Nr   FrY   r   r   rh   Tri   )r[   r   r   r]   r^   r_   r9   r   r`   r   rs   r   r"   r0   r!   r#   r2   r$   )r3   r>   r   r   s       r)   rb   z)TestPoissonCluExposureGeneric.setup_class   s    ::kk%9''u'--4B 	chh//9>AE@D8=;?	A hhll11#((;r+   Nrc   rU   r+   r)   r   r      s    < <r+   r   c                       e Zd Zed        Zy)TestGLMPoissonCluc                    t         j                  | _        t        j                  t
        t              }t        t
        t        t        j                               }|j                         | _
        | j                          y )Nfamily)r[   r\   r   r]   r^   r_   r9   r   r   r`   r   r5   ra   s     r)   rb   zTestGLMPoissonClu.setup_class  sO    11kk%&%h&6&6&89779r+   Nrc   rU   r+   r)   r   r     s     r+   r   c                       e Zd Zed        Zy)TestGLMPoissonCluGenericc           	      v   t         j                  | _        t        t        t
        t        j                               }|j                         x| _	        }t        | j                  j                  dt        dddd       | j                  j                  | _        | j                  | j                        | _        y )Nr   rh   TFri   )r[   r\   r   r   r_   r9   r   r^   r`   r   r   r"   r0   r!   r#   r2   r$   r3   r>   r   s      r)   rb   z$TestGLMPoissonCluGeneric.setup_class  s    11%h&6&6&89'')#4chh//9>AE@D8=;?	A hhll11#((;r+   Nrc   rU   r+   r)   r   r         < <r+   r   c                       e Zd Zed        Zy)TestGLMPoissonHC1Genericc                 f   t         j                  | _        t        t        t
        t        j                               }|j                         | _	        t        | j                  j                  dd       | j                  j                  | _        | j                  | j                  d      | _        y )Nr   rx   Try   Frz   )r[   r{   r   r   r_   r9   r   r^   r`   r   r   r"   r!   r#   r2   r$   ra   s     r)   rb   z$TestGLMPoissonHC1Generic.setup_class0  su    11%h&6&6&89779 	chh//Fhhll11#((1Nr+   Nrc   rU   r+   r)   r   r   .  s    	O 	Or+   r   c                       e Zd Zed        Zy)TestGLMPoissonCluFitc                    t         j                  | _        t        t        t
        t        j                               }|j                  dt        t        dd      d      x| _        }d | j                  j                  _        | j                  j                  | _        | j!                  | j                        | _        y )Nr   rh   Trj   rk   rl   F)r   r   rm   )r[   r\   r   r   r_   r9   r   r^   r`   r   r0   r   r"   r   r!   r#   r2   r$   r   s      r)   rb   z TestGLMPoissonCluFit.setup_class@  s    11%h&6&6&89''9+/u?C>B,D ).	 " $ 	$4 37/hhll11#((;r+   Nrc   rU   r+   r)   r   r   >  s    < <r+   r   c                       e Zd Zed        Zy)TestGLMPoissonHC1Fitc                 &   t         j                  | _        t        t        t
        t        j                               }|j                  d      | _	        | j                  j                  | _        | j                  | j                  d      | _        y )Nr   rx   r   Frz   )r[   r{   r   r   r_   r9   r   r^   r`   r   r!   r#   r2   r$   ra   s     r)   rb   z TestGLMPoissonHC1Fit.setup_classW  sb    11%h&6&6&8977E7*hhll11#((1Nr+   Nrc   rU   r+   r)   r   r   U  r   r+   r   c                       e Zd Zed        Zy)TestNegbinCluc                     t         j                  | _        t        j                  t
        t              }|j                  dd      | _        | j                          y )NFr   rZ   gtol)
r[   results_negbin_clur   r]   NegativeBinomialr_   r9   r`   r   r5   ra   s     r)   rb   zTestNegbinClu.setup_classd  sA    00""5$/77D71r+   Nrc   rU   r+   r)   r   r   b  rd   r+   r   c                       e Zd Zed        Zy)TestNegbinCluExposurec                     t         j                  | _        t        j                  t
        t        t              }|j                  d      | _	        | j                          y r   )r[   results_negbin_exposure_clur   r]   r   r_   r9   r   r`   r   r5   ra   s     r)   rb   z!TestNegbinCluExposure.setup_classn  sA    99""5$B777&r+   Nrc   rU   r+   r)   r   r   l  rd   r+   r   c                       e Zd Zed        Zy)TestNegbinCluGenericc           	      h   t         j                  | _        t        j                  t
        t              }|j                  dd      x| _        }t        | j                  j                  dt        dddd       | j                  j                  | _        | j                  | j                        | _        y )NFr   r   rh   Tri   )r[   r   r   r]   r   r_   r9   r`   r   r   r"   r0   r!   r#   r2   r$   r   s      r)   rb   z TestNegbinCluGeneric.setup_class  s    00""5$/''u4'884chh//9>AE@D8=;?	A hhll11#((;r+   Nrc   rU   r+   r)   r   r     r   r+   r   c                       e Zd Zed        Zy)TestNegbinCluFitc           	      :   t         j                  | _        t        j                  t
        t              }|j                  ddt        t        dd      dd      x| _
        }| j                  j                  | _        | j                  | j                        | _        y )NFrh   Tr   r   )rZ   r   r   rm   r   )r[   r   r   r]   r   r_   r9   r`   r   r0   r   r!   r#   r2   r$   r   s      r)   rb   zTestNegbinCluFit.setup_class  s    00""5$/''uy+/u?C>B,D ).'+ " - 	-4 hhll11#((;r+   Nrc   rU   r+   r)   r   r         < <r+   r   c                       e Zd Zed        Zy)TestNegbinCluExposureFitc           	      D   t         j                  | _        t        j                  t
        t        t              }|j                  ddt        t        dd      d      x| _        }| j                  j                  | _        | j                  | j                        | _        y )Nr   Frh   Tr   r   )r[   r   r   r]   r   r_   r9   r   r`   r   r0   r   r!   r#   r2   r$   r   s      r)   rb   z$TestNegbinCluExposureFit.setup_class  s    99""5$B''uy+/u?C>B,D ).	 " $ 	$4 hhll11#((;r+   Nrc   rU   r+   r)   r   r     r   r+   r   c                   $    e Zd Zd Zd Zd Zd Zy)CheckDiscreteGLMc                 V   | j                   }| j                  }t        |j                  | j                         t        |j                  | j                         t	        |dd      }t        |j                  |j                  |       t        |j                  |j                  d       y )Nr   vIh%<=r   绽|=)r   r   r   r   getattrr
   r   r!   )r%   r   r   r   s       r)   r*   zCheckDiscreteGLM.test_basic  sn    yyyyT]]DMM2T]]DMM2tVU+T[[t<$((7r+   c                 @   | j                   }| j                  }t        |j                  t              rd|j
                  i}ni }t        |j                  t              rd}nd}|j                  j                  |j                  dz  |j
                        } |j                  j                  |j                  dz  fi |}t        ||d       |j                  j                  |j                  |j
                        } |j                  j                  |j                  fi |}t        ||d       t        |j                  t              ry |j                  j                  |j                  |j
                        }	 |j                  j                  |j                  fi |}
t        |	|
d       |j                  j                  |j                  |j
                        } |j                  j                  |j                  fi |}t        ||z  |d       y )	Nscaler   \(\?)r   r   r   r   )r   r   
isinstancer8   r   r   scorer   r
   hessianscore_factorhessian_factor)r%   r   r   kwdssgnscore1score2hess1hess2scoref1scoref2hessf1hessf2s                r)   test_score_hessianz#CheckDiscreteGLM.test_score_hessian  s   yyyy djj#&TZZ(DDdjj#&CC!!$++"4DJJ!G!!!$++"4==U3

""4;;djj"A"

""4;;7$7u51djj#&**))$++TZZ)H)$**))$++>>u5**4;;djj*I***4;;?$?ff59r+   c                    | j                   }| j                  }t        |j                  t              ry | j                   j
                  }t        j                  |dz  |dz  f      }|j                  |d      }|j                  |d      }t        t        j                  |      t        j                  |      d       y )N      	nonrobustr   r   r   )r   r   r   r8   r   fittedvaluesr   column_stack
score_testr
   hstack)r%   r   r   fitted
exog_extrares_lm1res_lm2s          r)   test_score_testz CheckDiscreteGLM.test_score_test  s    yyyydjj#&''__fai%;<
//*{/C//*{/C		'*BIIg,>TJr+   c                    t        | j                  j                  t              s t	        | j
                  j                  d      rt        j                  d       | j
                  j                         }| j                  j                         }t        |j                  |j                  d       t        |j                  |j                  d       | j
                  j                  dd      }| j                  j                  dd      }t        |j                  |j                  d       t        |j                  |j                  d       y )Noffsetznot available yetr   r   T)countdummy)r   r   r8   r   hasattrr   pytestskipget_margeffr
   margeff
margeff_se)r%   marg1marg2s      r)   test_margeffzCheckDiscreteGLM.test_margeff  s    tyy,		2KK+,		%%'		%%'u}}5A((%*:*:G		%%D%=		%%D%=u}}5A((%*:*:Gr+   N)rQ   rR   rS   r*   r   r   r  rU   r+   r)   r   r     s    	8 :DKHr+   r   c                       e Zd Zed        Zy)TestGLMPoissonc                    t         j                  j                  d       t         j                  j                  t              }d| _        t        |t        t        j                               }|j                  d      | _        t        j                  |t              }|j                  d      | _        d| j                  _        y )NiW:HC0r   r   gdy=)r   randomseedpoissonr_   r   r   r9   r   r^   r`   r   r]   r   r   )r3   endog_countmod1s      r)   rb   zTestGLMPoisson.setup_class	  s    
		y!ii''.;X-=-=-?@88U8+{{;-88U8+r+   Nrc   rU   r+   r)   r  r    s     r+   r  c                       e Zd Zed        Zy)TestGLMLogitc                    t         t         j                         kD  j                  t              }d| _        t        |t        t        j                               }|j                  dt        t                    | _        t        j                  |t              }|j                  dt        t                    | _        y Nrh   r   rj   r   r   )r_   meanastypeintr   r   r9   r   Binomialr`   r   r0   r   r]   Logitr   r3   	endog_binr  s      r)   rb   zTestGLMLogit.setup_class  s}    UZZ\)11#6	 9d8+<+<+>?88YU9K8LyyD)88YU9K8Lr+   Nrc   rU   r+   r)   r  r    s    M Mr+   r  c                       e Zd Zed        Zy)TestGLMLogitOffsetc                    t         t         j                         kD  j                  t              }d| _        t        j                  |j                  d         }t        |t        t        j                         |      }|j                  dt        t                    | _        t!        j"                  |t        |      }|j                  dt        t                    | _        y )Nrh   r   r   r   r  r  r   )r_   r  r  r  r   r   r   r:   r   r9   r   r  r`   r   r0   r   r]   r  r   r3   r  r   r  s       r)   rb   zTestGLMLogitOffset.setup_class(  s    UZZ\)11#6	 +,9d8+<+<+>vN88YU9K8LyyD888YU9K8Lr+   Nrc   rU   r+   r)   r  r  &  s    	M 	Mr+   r  c                   "    e Zd Zed        Zd Zy)TestGLMProbitc                    t         t         j                         kD  j                  t              }d| _        t        |t        t        j                  t        j                                     }|j                  ddt        t                    | _        t        j                  |t              }|j                  dt        t                    | _        d| _        y )	Nrh   linkr   newtonr  methodr   r   r  ư>)r_   r  r  r  r   r   r9   r   r  r   Probitr`   r   r0   r   r]   r   r   r  s      r)   rb   zTestGLMProbit.setup_class6  s    UZZ\)11#6	 9d8+<+<%,,.+QR888%.U9K  M zz)T*88YU9K8Lr+   c                    | j                   }| j                  }|j                  j                  |j                  dz        }|j                  j                  |j                  dz        }t        ||d       |j                  j                  |j                        }|j                  j                  |j                        }t        ||d       y )Nr   r   r   )r   r   r8   r   r   r
   r   )r%   r   r   r   r   r   r   s          r)   r   z TestGLMProbit.test_score_hessianC  s    yyyy!!$++"45!!$++"45U3

""4;;/

""4;;/u51r+   N)rQ   rR   rS   rT   rb   r   rU   r+   r)   r"  r"  4  s    
 

2r+   r"  c                       e Zd Zed        Zy)TestGLMProbitOffsetc                    t         t         j                         kD  j                  t              }d| _        t        j                  |j                  d         }t        |t        t        j                  t        j                               |      }|j                  ddt        t                     | _        t%        j                  |t        |      }|j                  dt        t               	      | _        d
| _        y )Nrh   r   r$  r  r&  r  r'  r  r  r)  )r_   r  r  r  r   r   r   r:   r   r9   r   r  r   r*  r`   r   r0   r   r]   r   r   r   s       r)   rb   zTestGLMProbitOffset.setup_classR  s    UZZ\)11#6	 +,9d"++@ " 888%.U9K  M zz)T&988YU9K8Lr+   Nrc   rU   r+   r)   r-  r-  P  s     r+   r-  c                       e Zd Zed        Zy)TestGLMGaussNonRobustc                     d| _         t        t        t        t	        j
                               }|j                         | _        t        t        t              }|j                         | _	        y )Nr   r   
r   r   r_   r9   r   Gaussianr`   r   r   r   r3   r  mod2s      r)   rb   z!TestGLMGaussNonRobust.setup_classe  sF    "5$x'8'8':;88:5$88:r+   Nrc   rU   r+   r)   r0  r0  c  s     r+   r0  c                       e Zd Zed        Zy)TestGLMGaussCluc                 "   d| _         t        t        t        t	        j
                               }|j                  dt        t                    | _	        t        t        t              }|j                  dt        t                    | _        y r  )r   r   r_   r9   r   r3  r`   r   r0   r   r   r   r4  s      r)   rb   zTestGLMGaussClu.setup_classr  s^     5$x'8'8':;88YU9K8L5$88YU9K8Lr+   Nrc   rU   r+   r)   r7  r7  p  s    M Mr+   r7  c                       e Zd Zed        Zy)TestGLMGaussHCc                     d| _         t        t        t        t	        j
                               }|j                  d      | _        t        t        t              }|j                  d      | _	        y )Nr  r   r   r2  r4  s      r)   rb   zTestGLMGaussHC.setup_class  sP    5$x'8'8':;88U8+5$88U8+r+   Nrc   rU   r+   r)   r:  r:  }  s    , ,r+   r:  c                       e Zd Zed        Zy)TestGLMGaussHACc                     d| _         ddi}t        t        t        t	        j
                               }|j                  d|      | _        t        t        t              }|j                  d|      | _	        y )NHACmaxlagsr   r   r  r2  r3   r   r  r5  s       r)   rb   zTestGLMGaussHAC.setup_class  s_     ]5$x'8'8':;88UT8:5$88UT8:r+   Nrc   rU   r+   r)   r=  r=    s    	; 	;r+   r=  c                       e Zd Zed        Zy)TestGLMGaussHAC2c                     d| _         ddd}t        t        t        t	        j
                               }|j                  d|      | _        t        t        t              }ddi}|j                  d|      | _	        y )Nr?  bartlettr   kernelr@  r   r  r@  r2  r3   r   r  r5  kwds2s        r)   rb   zTestGLMGaussHAC2.setup_class  sk      %35$x'8'8':;88UT8:5$A88UU8;r+   Nrc   rU   r+   r)   rC  rC    r   r+   rC  c                   "    e Zd Zed        Zd Zy)TestGLMGaussHACUniformc                 D   d| _         t        j                  dd}t        t        t
        t        j                               }|j                  d|      | _	        t        t        t
              }|j                  d|      | _        |j                  dddi      | _        y )Nr?  r   rF  r   r  r@  )r   r.   weights_uniformr   r_   r9   r   r3  r`   r   r   r   rq   rA  s       r)   rb   z"TestGLMGaussHACUniform.setup_class  s     ))Q75$x'8'8':;88UT8:5$88UT8: 88Ui]8Cr+   c                    t         j                  dd}| j                  j                  j	                  d|      }| j
                  j                  j	                  d|      }t        |j                  | j                  j                  d       t        |j                  | j
                  j                  d       t        j                  g d      }t        |j                  |d       t        |j                  d	   t         j                  u        t         j                  dd
}| j                  j                  j	                  d|      }| j
                  j                  j	                  d|      }t        |j                  |j                  d       t        j                  g d      }t        |j                  |d       y )Nr   )weights_funcr@  r?  r  -q=r   )g+O@gqh@g,{@&@r)  rO  rF  )gG@g[@go^b"@)r.   rM  r   r8   r`   r   r
   r!   r   arrayr   r   weights_bartlett)r%   kwdsares1ares2ar!   kwdsbs         r)   test_cov_optionsz'TestGLMGaussHACUniform.test_cov_options  s:    "$!3!3B		##UU#C		##UU#C		499==u=		499==u= hhAB		3T2~."2D2DDE..1=		##UU#C		##UU#C		59959 hh9:		3T2r+   N)rQ   rR   rS   rT   rb   rW  rU   r+   r)   rK  rK    s    D D3r+   rK  c                       e Zd Zed        Zy)TestGLMGaussHACUniform2c                    d| _         t        j                  dd}t        t        t
        t        j                               }|j                  d|      | _	        t        t        t
              }ddd}|j                  d|      | _        y )Nr?  r   rF  r   r  uniform)r   r.   rM  r   r_   r9   r   r3  r`   r   r   r   rH  s        r)   rb   z#TestGLMGaussHACUniform2.setup_class  sr     **q95$x'8'8':;88UT8: 5$$388UT8:r+   Nrc   rU   r+   r)   rY  rY    s    ; ;r+   rY  c                   "    e Zd Zed        Zd Zy)TestGLMGaussHACPanelc                    d| _         t        j                  t        j                  d      d      d d }t	        t
        j                         t        j                         t        j                               }t        |dt        j                  dd	      }|j                  d|
      | _        |j                  d|
      | _        t!        t
        t              }|j                  d|
      | _        y )N	hac-panel      r   r   r   hacF)timer@  rG  rk   rl   r  znw-panel)r   r   tilearanger   r_   ro   r9   r   r3  r   r.   rM  r`   r   res1br   r   r3   rc  r  r   r5  s        r)   rb   z TestGLMGaussHACPanel.setup_class  s    "wwryy|Q',5::<X5F5F5HI--#("'	)
 88[48@HHj4H@	5$88[48@r+   c                 p    t        | j                  j                  | j                  j                  d       y NrP  r   r
   rf  r!   r   rK   s    r)   test_kwdzTestGLMGaussHACPanel.test_kwd      

		EBr+   NrQ   rR   rS   rT   rb   rk  rU   r+   r)   r]  r]    s    A A Cr+   r]  c                       e Zd Zed        Zy)TestGLMGaussHACPanelGroupsc                    d| _         t        j                  t        j                  d      d      d d }t	        t
        j                         t        j                         t        j                               }t        t        j                  |      dt        j                  dd	      }|j                  d|
      | _        t#        t
        t              }|j                  d|
      | _        y )Nr_  ra  r`  r   r   r   rb  F)rj   r@  rG  rk   rl   r  )r   r   repeatre  r   r_   ro   r9   r   r3  r   pdSeriesr.   rM  r`   r   r   r   )r3   rj   r  r   r5  s        r)   rb   z&TestGLMGaussHACPanelGroups.setup_class  s    "299Q<+CR05::<X5F5F5HI299V,--#("'	)
 88[48@5$88[48@r+   Nrc   rU   r+   r)   ro  ro    s    A Ar+   ro  c                   "    e Zd Zed        Zd Zy)TestGLMGaussHACGroupsumc                    d| _         t        j                  t        j                  d      d      d d }t	        t
        t        t        j                               }t        t        j                  |      ddd	      }|j                  d|
      | _        |j                  d|
      | _        t        t
        t              }|j                  d|
      | _        y )Nzhac-groupsumr`  ra  r   r   r   rb  F)rc  r@  rk   rl   r  znw-groupsum)r   r   rd  re  r   r_   r9   r   r3  r   rr  rs  r`   r   rf  r   r   rg  s        r)   rb   z#TestGLMGaussHACGroupsum.setup_class  s    %wwryy|Q',5$x'8'8':;4#("') 88^d8CHHmdHC	5$88^d8Cr+   c                 p    t        | j                  j                  | j                  j                  d       y ri  rj  rK   s    r)   rk  z TestGLMGaussHACGroupsum.test_kwd$  rl  r+   Nrm  rU   r+   r)   ru  ru    s    D DCr+   ru  )\__doc__osnumpyr   pandasrr  r   #statsmodels.discrete.discrete_modeldiscretediscrete_modelr]   +statsmodels.genmod.generalized_linear_modelr   statsmodels.genmodr   statsmodels.genmod.familiesr   #statsmodels.regression.linear_modelr   rs   r   %statsmodels.stats.sandwich_covariancestatssandwich_covariancer.   statsmodels.tools.toolsr	   numpy.testingr
   r   r   statsmodels.tools._testingtools_testingrI   r   r   r[   pathdirnameabspath__file__cur_dirjoinfilepathread_csvdata_rawdropnadatar_   split	exog_datar9   asarrayr  r0   r   r   rW   rf   rv   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r"  r-  r0  r7  r:  r=  rC  rK  rY  r]  ro  ru  rU   r+   r)   <module>r     s   
    1 1 ; ' - 3 : 2 2 0 A @ ( ( @
''//"''//(3
477<<K82;;x51 	Z"((*+	Iu-

4<%2::d9o&:+ :+z* <1 <@O1 O$,D- ,D^
O- 
O
O 5 
O2 <$9 <,- <4 <&O4 O <0 <.
O0 
O) 1 0<0 <&<, <"<4 <"KH KH\% "M# MM) M2$ 28* &
, 

M& 
M
,% 
,;& ;<' <"(3- (3X;4 ;"C+ C0A!1 A&C. Cr+   