
    >h                     R    S r SSKJr  SSKrSSKJr   " S S\5      r " S S5      rg)	zgBase classes for statistical test results

Created on Mon Apr 22 14:03:21 2013

Author: Josef Perktold
    )lzipN)Holderc                   L   ^  \ rS rSrSrS	U 4S jjrS rS rS rS
S jr	Sr
U =r$ )HolderTuple   z Holder class with indexing

    c                    >^  [         TT ]  " S0 UD6  Ub  [        U 4S jU 5       5      T l        g T R                  T R                  4T l        g )Nc              3   <   >#    U  H  n[        TU5      v   M     g 7fN)getattr).0attselfs     iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\statsmodels/stats/base.py	<genexpr>'HolderTuple.__init__.<locals>.<genexpr>   s     DVcwtS11Vs    )super__init__tuple	statisticpvalue)r   tuple_kwds	__class__s   `  r   r   HolderTuple.__init__   s?     4 DVDDDJ..$++6DJ    c              #   8   #    U R                    S h  vN   g  N7fr
   r   r   s    r   __iter__HolderTuple.__iter__   s     ::s   c                      U R                   U   $ r
   r   )r   idxs     r   __getitem__HolderTuple.__getitem__   s    zz#r   c                 ,    [        U R                  5      $ r
   )lenr   r   s    r   __len__HolderTuple.__len__   s    4::r   c                 R    [         R                  " [        U R                  5      XS9$ )N)dtypecopy)nparraylistr   )r   r+   r,   s      r   	__array__HolderTuple.__array__!   s    xxTZZ(AAr   r   r
   )NT)__name__
__module____qualname____firstlineno____doc__r   r    r$   r(   r0   __static_attributes____classcell__)r   s   @r   r   r      s(    7B Br   r   c                   B    \ rS rSrSr  S
S jrSS jrS rS rS r	S	r
g)AllPairsResults%   aB  Results class for pairwise comparisons, based on p-values

Parameters
----------
pvals_raw : array_like, 1-D
    p-values from a pairwise comparison test
all_pairs : list of tuples
    list of indices, one pair for each comparison
multitest_method : str
    method that is used by default for p-value correction. This is used
    as default by the methods like if the multiple-testing method is not
    specified as argument.
levels : {list[str], None}
    optional names of the levels or groups
n_levels : None or int
    If None, then the number of levels or groups is inferred from the
    other arguments. It can be explicitly specified, if the inferred
    number is incorrect.

Notes
-----
This class can also be used for other pairwise comparisons, for example
comparing several treatments to a control (as in Dunnet's test).

Nc           	      6   Xl         X l        Uc  [        R                  " U5      S-   U l        OXPl        X0l        X@l        Uc  U Vs/ s H  of< PM     snU l        g U Vs/ s H  nSR                  XFS      XFS      5      PM!     snU l        g s  snf s  snf )N   z{}-{}r   )		pvals_raw	all_pairsr-   maxn_levelsmultitest_methodlevelsall_pairs_namesformat)r   r>   r?   rB   rC   rA   pairss          r   r   AllPairsResults.__init__@   s    ""FF9-1DM$M 0>*3$*3))$D   )$  )e 8$f1X&6($D 	$$s   B"&Bc                 l    SSK Js  Jn  Uc  U R                  nUR	                  U R
                  US9S   $ )zp-values corrected for multiple testing problem

This uses the default p-value correction of the instance stored in
``self.multitest_method`` if method is None.

r   N)methodr=   )statsmodels.stats.multiteststats	multitestrB   multipletestsr>   )r   rI   smts      r   pval_correctedAllPairsResults.pval_correctedW   s9     	21>**F   ?BBr   c                 "    U R                  5       $ r
   )summaryr   s    r   __str__AllPairsResults.__str__d   s    ||~r   c                     U R                   n[        R                  " X45      nU R                  5       U[	        U R
                  6 '   U$ )zqcreate a (n_levels, n_levels) array with corrected p_values

this needs to improve, similar to R pairwise output
)rA   r-   zerosrO   r   r?   )r   k	pvals_mats      r   
pval_tableAllPairsResults.pval_tableg   s?    
 MMHHaV$	+/+>+>+@	$'(r   c           	      *   SSK Js  Jn  [        S U R                   5       5      nSUR
                  U R                     -  nUSSUS-
  S-   -  -   S	-   -  nUS
R                  S [        U R                  U R                  5       5       5       5      -  nU$ )z}returns text summarizing the results

uses the default pvalue correction of the instance stored in
``self.multitest_method``
r   Nc              3   8   #    U  H  n[        U5      v   M     g 7fr
   )r'   )r   sss     r   r   *AllPairsResults.summary.<locals>.<genexpr>y   s     >)=2s2ww)=s   z0Corrected p-values using %s p-value correction

Pairs    r=   z	p-values

c              3   6   #    U  H  u  pU S US 3v   M     g7f)z  z6.4gNr   )r   rF   pvs      r   r   r^   ~   s(      LJ 5@UUG2bY/Js   )
rJ   rK   rL   r@   rD   multitest_methods_namesrB   joinziprO   )r   rN   maxleveltexts       r   rR   AllPairsResults.summaryr   s     	21>)=)=>>D--d.C.CDE3(Q,"234|CC		 Ld22D4G4G4IJL L 	Lr   )r?   rD   rC   rB   rA   r>   )hsNNr
   )r2   r3   r4   r5   r6   r   rO   rS   rY   rR   r7   r   r   r   r:   r:   %   s*    4 ?C'+.C	r   r:   )	r6   statsmodels.compat.pythonr   numpyr-   statsmodels.tools.testingr   r   r:   r   r   r   <module>ro      s/    +  ,B& B2[ [r   