U
    Ãmœd±
  ã                   @   sZ   d Z ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
 ddlm  mZ dd„ ZdS )	z©Test for panel robust covariance estimators after pooled ols
this follows the example from xtscc paper/help

Created on Tue May 22 20:27:57 2012

Author: Josef Perktold
é    )ÚlmapN)Úassert_almost_equal)ÚOLS)Úadd_constantc                  C   sÊ  dd l m  m}  ddlm} | j ¡ }|jd d… }|jd d… }t	|t
|ddg dd�ƒ ¡ }tj|d	g d
d�}|| ¡ 8 }t |¡ t¡}dd„ tdƒD ƒ}tjt |dg d¡dd�\}}	tj|d|dd�}
t|
|jdd� tj|d|dd�}
t|
|jdd� t |d|¡}
t|
|jdd� t ||	¡}t||jdd� t |tt|	ƒ¡}t||jdd� tj|d|dd�}t||j dd� tj|d|dd�}t||j!dd� t |d|¡}t||j"dd� d S )Nr   é   )ÚresultséÈ   ÚvalueZcapitalF)ÚprependÚyearÚW)Úrequirementsc                 S   s    g | ]}|d  d |d  f‘qS )é   r   © )Ú.0Úir   r   úe/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/statsmodels/stats/tests/test_panel_robustcov.pyÚ
<listcomp>$   s     z)test_panel_robust_cov.<locals>.<listcomp>é
   ZfirmZS20T)Zreturn_inverseZhac)Zuse_correctioné   )Údecimal)#Zstatsmodels.datasets.grunfeldZdatasetsZgrunfeldZresults.results_panelrobustr   ÚdataZload_pandasZendogZexogr   r   ÚfitÚnpÚrequireÚminZsqueezeZastypeÚintÚrangeÚuniqueZasarrayÚswZcov_nw_panelr   Zcov_pnw0_stataZcov_pnw1_stataZcov_pnw4_stataZcov_clusterZcov_clu_statar   ÚstrZcov_nw_groupsumZcov_dk0_stataZcov_dk1_stataZcov_dk4_stata)ÚgrZ	res_stataZdtapaZdtapa_endogZ
dtapa_exogÚresÚtimeZtidxZ
firm_namesZfirm_idZcovZcov_cluZrcovr   r   r   Útest_panel_robust_cov   s>    
ÿÿ
r$   )Ú__doc__Zstatsmodels.compat.pythonr   Únumpyr   Znumpy.testingr   Z#statsmodels.regression.linear_modelr   Zstatsmodels.tools.toolsr   Z%statsmodels.stats.sandwich_covarianceÚstatsZsandwich_covariancer   r$   r   r   r   r   Ú<module>   s   