U
    Kvf
                     @   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 )	zTest 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   P/tmp/pip-unpacked-wheel-2v6byqio/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   Z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)Z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   Z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   