
    M/Ph?l                        d dl Zd dlmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZ  G d d          Z G d	 d
          ZddZ G d d          Zd Zd Z	 	 ddZ G d d          ZddZ	 	 d dZ	 	 d!dZd Zd"dZ	 	 d"dZdS )#    N)f)t)stats)clean0fullrank)multipletestsc                   B    e Zd ZdZ	 	 d
dZddZd Zd ZddZdd	Z	dS )ContrastResultsaX  
    Class for results of tests of linear restrictions on coefficients in a model.

    This class functions mainly as a container for `t_test`, `f_test` and
    `wald_test` for the parameters of a model.

    The attributes depend on the statistical test and are either based on the
    normal, the t, the F or the chisquare distribution.
    N皙?c                    || _         |Zd| _        || _        | j        | _        || _        || _        t          | _        ||f| _        t          j	        |||          | _
        n|nd| _        || _        || _        || _        || _        t          | _        |f| _        | j        	                    t          j        |          |          dz  | _
        n0d|v r|d         | _        |d         | _        |d         x| _        }	|| _        t!          t"          | j                  | _        |                    dd          | _        | j        dk    r-| j        	                    | j        |          | _
        || _        n	 t          j        |	t          j                  | _
        t          j        |	           }
| j        	                    t          j        |	|
                             dz  | j
        |
<   nt          j        | _
        t          j        | j
                  | _
        | j         2d	 t/          t1          | j                             D             | _        d S d | _        d S )
NFr      	statisticdistribution	dist_args chi2c                     g | ]}d |z  S )zc%dr   ).0iis     Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/stats/contrast.py
<listcomp>z,ContrastResults.__init__.<locals>.<listcomp>D   s    III2EBJIII    )effectr   fvaluer   df_denomdf_numfdistdistr   sfpvaluetvaluesd	student_tnpabsgetattrr   get	full_likenanisnansqueezerangelenc_names)selfr   r   r#   r   r   r   alphakwdsvaluenot_nans              r   __init__zContrastResults.__init__   s    = #DDK![DN$DM DKDI$h/DN(1fh77DKK] #DDKDNDG$DM!DI&[DN),,rvayy(;;a?DKKD   $^ 4D!+.DN"&{"33DK%DGt'899DI!XXk266DN F**"ill4>8DD ( l5"&998E??*'+y||BF5>4J4J'K'Ka'OG$$&DK j--;"IIs4;7G7G1H1HIIIDLLLDLLLr   c                     | j         X | j        j        d|dz  z
  g| j        R  }| j         || j        z  z
  }| j         || j        z  z   }t          j        ||f          S t          d          )a&  
        Returns the confidence interval of the value, `effect` of the constraint.

        This is currently only available for t and z tests.

        Parameters
        ----------
        alpha : float, optional
            The significance level for the confidence interval.
            ie., The default `alpha` = .05 returns a 95% confidence interval.

        Returns
        -------
        ci : ndarray, (k_constraints, 2)
            The array has the lower and the upper limit of the confidence
            interval in the columns.
        N   g       @z!Confidence Interval not available)r   r   ppfr   r#   r%   column_stackNotImplementedError)r0   r1   qloweruppers        r   conf_intzContrastResults.conf_intH   sx    $ ;"	a%"*n>t~>>>AK!dg+-EK!dg+-E?E5>222%&IJJJr   c                 N    |                                                                  S N)summary__str__r0   s    r   rB   zContrastResults.__str__c   s    ||~~%%'''r   c                 Z    t          | j                  dz   |                                 z   S N
str	__class__rB   rC   s    r   __repr__zContrastResults.__repr__f   $    4>""T)DLLNN::r   c           
         | j         }|d}n|dk    rd}| j        dk    }d}|| j        }ddlm} t          j        | j                  } || | j         | j        | j	        || 
                    |          f|||||          }|S t          | d	          r*d
t          | j                  | j        | j        | j        fz  S | j        dk    rd| j        | j	        | j        | j        fz  S d| j	        d| j        dS )a  Summarize the Results of the hypothesis test

        Parameters
        ----------
        xname : list[str], optional
            Default is `c_##` for ## in the number of regressors
        alpha : float
            significance level for the confidence intervals. Default is
            alpha = 0.05 which implies a confidence level of 95%.
        title : str, optional
            Title for the params table. If not None, then this replaces the
            default title

        Returns
        -------
        smry : str or Summary instance
            This contains a parameter results table in the case of t or z test
            in the same form as the parameter results table in the model
            results summary.
            For F or Wald test, the return is a string.
        NzTest for Constraints r   constraintsr   )summary_params)ynamexnameuse_ttitler1   r   z0<F test: F=%s, p=%s, df_denom=%.3g, df_num=%.3g>r   z9<Wald test (%s): statistic=%s, p-value=%s, df_denom=%.3g>z<Wald test: statistic=z
, p-value=>)r   r   r/   statsmodels.iolib.summaryrO   r%   
atleast_1dr!   r#   r   r>   hasattrreprr   r   r   )	r0   rQ   r1   rS   rR   rP   rO   pvaluessumms	            r   rA   zContrastResults.summaryi   sN   , ;" }." &#-EE}@@@@@@mDK00G!>4dgt~#*DMM%,@,@#B(-U%(-U< < <D KT8$$ 	2F%%t{DMK!! " &((O%t~t{M## $ ) NNNDKKK1 2r   c           
          | j         [| j        dk    }d}|| j        }ddlm}  || | j         | j        | j        | j        |                     |          f||||          }|S t          d          )zpReturn the parameter table as a pandas DataFrame

        This is only available for t and normal tests
        Nr   rN   r   )summary_params_frame)rP   rQ   rR   r1   zonly available for t and z)
r   r   r/   rU   r\   r#   r   r!   r>   r:   )r0   rQ   r1   rR   rP   r\   rZ   s          r   summary_framezContrastResults.summary_frame   s    
 ;"&#-EE}FFFFFF''t{DG)-)-u)=)=)?FK/4E/4	6 6 6D
 K &&BCCCr   )NNNNNNr   )r   )Nr   N)Nr   )
__name__
__module____qualname____doc__r5   r>   rB   rJ   rA   r]   r   r   r   r
   r
   
   s          GK$(1  1  1  1 fK K K K6( ( (; ; ;72 72 72 72tD D D D D Dr   r
   c                   :    e Zd ZdZd Z ee          Zd Zd ZdS )ContrastaZ  
    This class is used to construct contrast matrices in regression models.

    They are specified by a (term, design) pair.  The term, T, is a linear
    combination of columns of the design matrix. The matrix attribute of
    Contrast is a contrast matrix C so that

    colspan(dot(D, C)) = colspan(dot(D, dot(pinv(D), T)))

    where pinv(D) is the generalized inverse of D. Further, the matrix

    Tnew = dot(C, D)

    is full rank. The rank attribute is the rank of

    dot(D, dot(pinv(D), T))

    In a regression model, the contrast tests that E(dot(Tnew, Y)) = 0
    for each column of Tnew.

    Parameters
    ----------
    term : array_like
    design : array_like

    Attributes
    ----------
    contrast_matrix

    Examples
    --------
    >>> import statsmodels.api as sm
    >>> from statsmodels.stats.contrast import Contrast
    >>> import numpy as np
    >>> np.random.seed(54321)
    >>> X = np.random.standard_normal((40,10))
    # Get a contrast
    >>> new_term = np.column_stack((X[:,0], X[:,2]))
    >>> c = Contrast(new_term, X)
    >>> test = [[1] + [0]*9, [0]*2 + [1] + [0]*7]
    >>> np.allclose(c.contrast_matrix, test)
    True

    Get another contrast

    >>> P = np.dot(X, np.linalg.pinv(X))
    >>> resid = np.identity(40) - P
    >>> noise = np.dot(resid,np.random.standard_normal((40,5)))
    >>> new_term2 = np.column_stack((noise,X[:,2]))
    >>> c2 = Contrast(new_term2, X)
    >>> print(c2.contrast_matrix)
    [ -1.26424750e-16   8.59467391e-17   1.56384718e-01  -2.60875560e-17
    -7.77260726e-17  -8.41929574e-18  -7.36359622e-17  -1.39760860e-16
    1.82976904e-16  -3.75277947e-18]

    Get another contrast

    >>> zero = np.zeros((40,))
    >>> new_term3 = np.column_stack((zero,X[:,2]))
    >>> c3 = Contrast(new_term3, X)
    >>> test2 = [0]*2 + [1] + [0]*7
    >>> np.allclose(c3.contrast_matrix, test2)
    True
    c                 X    t          | d          s|                                  | j        S )z3
        Gets the contrast_matrix property
        _contrast_matrix)rW   compute_matrixre   rC   s    r   _get_matrixzContrast._get_matrix   s2     t/00 	"!!!$$r   c                 j    t          j        |          | _        t          j        |          | _        d S r@   )r%   asarraytermdesign)r0   rj   rk   s      r   r5   zContrast.__init__  s(    Jt$$	j((r   c                    | j         }|j        dk    r|dddf         }t          |          | _        | j        | _        t          | j        | j                  | _        	 | j        j	        d         | _
        dS #  d| _
        Y dS xY w)z
        Construct a contrast matrix C so that

        colspan(dot(D, C)) = colspan(dot(D, dot(pinv(D), T)))

        where pinv(D) is the generalized inverse of D=design.
        r7   N)rj   ndimr   Trk   Dcontrastfromcolsre   matrixshaperank)r0   rn   s     r   rf   zContrast.compute_matrix
  s     I6Q;;!!!D&	A 0 @ @	)!,DIII	DIIIIs   A8 8	BN)	r^   r_   r`   ra   rg   propertycontrast_matrixr5   rf   r   r   r   rc   rc      s]        ? ?@% % % h{++O) ) )    r   rc   c                    t          j        |           } t          j        |          }|j        \  }}| j        d         |k    r | j        d         |k    rt          d          |t           j                            |          }| j        d         |k    rt          j        ||           j        }n4| }t          j        |t          j        ||j                            j        }t          j        ||j                  }t          |j                  dk    r	|df|_        t           j        	                    |          |j        d         k    r)t          |          }t          j        ||          j        }t          j        |          S )a  
    From an n x p design matrix D and a matrix L, tries
    to determine a p x q contrast matrix C which
    determines a contrast of full rank, i.e. the
    n x q matrix

    dot(transpose(C), pinv(D))

    is full rank.

    L must satisfy either L.shape[0] == n or L.shape[1] == p.

    If L.shape[0] == n, then L is thought of as representing
    columns in the column space of D.

    If L.shape[1] == p, then L is thought of as what is known
    as a contrast matrix. In this case, this function returns an estimable
    contrast corresponding to the dot(D, L.T)

    Note that this always produces a meaningful contrast, not always
    with the intended properties because q is always non-zero unless
    L is identically 0. That is, it produces a contrast that spans
    the column space of L (after projection onto the column space of D).

    Parameters
    ----------
    L : array_like
    D : array_like
    r   r7   zshape of L and D mismatched)r%   ri   rr   
ValueErrorlinalgpinvdotrn   r.   matrix_rankr   r,   )Lro   pseudonpCLps          r   rp   rp      s4   < 	
1A

1A7DAqwqzQ171:??6777~""wqzQF61F626!QS>>**,	13B
28}}q6	yR  BHQK//b\\F62 :a==r   c                   B    e Zd Z	 	 ddZed             Zd Zd Zd ZdS )WaldTestResultsNc                 8   || _         || _        || _        || _        |W|d         j        | _        |d         j        | _        |d         j        | _        | j        dk    r|d         j        | _        d S d S | j        dk    r$t          j	        | _
        | j        d         | _        n@| j        dk    r&t          j        | _
        | j        \  | _        | _        nt          d          |, | j
        j        t          j        |          g|R  | _        d S || _        d S )	Nr   r!   df_constraintr   r   r   r   z)only F and chi2 are possible distribution)tabler   r   r   valuesrY   df_constraintsr   r   r   r   r   rw   r    r%   r&   )r0   r   r   r   r   rY   s         r   r5   zWaldTestResults.__init___  s   
("" ";/6DN ?1DL"'"8"?D C'' %j 1 8 ('  F**!J	&*nQ&7##"c))!G	59^2#T]] !!LMMM+ty|BF9,=,=J	JJJ&r   c                 n    d| j         z  }| j         |dg}| j         dk    r|                    d           |S )z'column names for summary table
        zP>%szdf constraintr   zdf denom)r   append)r0   pr_test	col_namess      r   r   zWaldTestResults.col_names  sH    
 4,,&A	##Z(((r   c                     t          | d          r| j        S t          t          | j        j        | j                            }| j                            |          | _        | j        S )N_dframe)columns)	rW   r   dictzipr   r   r   renamedframe)r0   renamings     r   r]   zWaldTestResults.summary_frame  s\    4## 	 <DJ.??@@j'''99{r   c                 N    |                                                                  S r@   )r]   	to_stringrC   s    r   rB   zWaldTestResults.__str__  s     !!##--///r   c                 Z    t          | j                  dz   |                                 z   S rE   rG   rC   s    r   rJ   zWaldTestResults.__repr__  rK   r   )NN)	r^   r_   r`   r5   rt   r   r]   rB   rJ   r   r   r   r   r   \  s{         BF '  '  '  'D   X  0 0 0; ; ; ; ;r   r   c                 \    t          j        | d          }fdt          | D             }|S )z8helper function for labels for pairwise comparisons
    r7   c                 N    g | ]!}|d                    d|d                   "S )r7   -r   r   )r   namelevel_namess     r   r   z%_get_pairs_labels.<locals>.<listcomp>  sI     / / / T!W%>>DG(<>> / / /r   )r%   triu_indicesr   )k_levelr   idx_pairs_alllabelss    `  r   _get_pairs_labelsr     sH     OGQ//M/ / / /}-/ / /FMr   c                    |dz
  }t          j        |d          }t          |d                   }t          j        ||f          }d|t          j        |          |d         f<   d|t          j        |          |d         f<   t          j        |          }t          j        ||fd          }|j        d         }	t          j        |	| f          }
||
dd|||z   f<   |
S )a  create pairwise contrast for reference coding

    currently not used,
    using encoding contrast matrix is more general, but requires requires
    factor information from patsy design_info.


    Parameters
    ----------
    k_params : int
        number of parameters
    k_level : int
        number of levels or categories (including reference case)
    idx_start : int
        Index of the first parameter of this factor. The restrictions on the
        factor are inserted as a block in the full restriction matrix starting
        at column with index `idx_start`.

    Returns
    -------
    contrasts : ndarray
        restriction matrix with k_params columns and number of rows equal to
        the number of restrictions.
    r7   r   )axisN)r%   r   r.   zerosarangeeyeconcatenaterr   )k_paramsr   	idx_start
k_level_m1	idx_pairskc_pairsc_referenceck_all	contrastss              r   _contrast_pairsr     s    2 1J
A..IIaLAh:''G*,GBIaLL)A,&'*+GBIaLL)A,&'&$$K
W-A666AGAJE%*++I78IaaaY3334r   hsr   c                     |                      |          }|                    |          }t          |          t          ur|g}|D ]5}t	          |j        ||          }	|	d         |d|z  <   |	d         |d|z  <   6|S )a  perform t_test and add multiplicity correction to results dataframe

    Parameters
    ----------
    result results instance
        results of an estimated model
    contrasts : ndarray
        restriction matrix for t_test
    method : str or list of strings
        method for multiple testing p-value correction, default is'hs'.
    alpha : float
        significance level for multiple testing reject decision.
    ci_method : None
        not used yet, will be for multiplicity corrected confidence intervals
    contrast_names : {list[str], None}
        If contrast_names are provided, then they are used in the index of the
        returned dataframe, otherwise some generic default names are created.

    Returns
    -------
    res_df : pandas DataFrame
        The dataframe contains the results of the t_test and additional columns
        for multiplicity corrected p-values and boolean indicator for whether
        the Null hypothesis is rejected.
    )rQ   )methodr1   r7   z	pvalue-%sr   z	reject-%s)t_testr]   typelistr   r!   )
resultr   r   r1   	ci_methodcontrast_namesttres_dfmethmts
             r   t_test_multir     s    6 
y	!	!BN33FF||4 + +29T???%'U{T!"%'U{T!""Mr   c                       e Zd ZdZd ZdS )MultiCompResultzdclass to hold return of t_test_pairwise

    currently just a minimal class to hold attributes.
    c                 :    | j                             |           d S r@   )__dict__update)r0   kwargss     r   r5   zMultiCompResult.__init__  s    V$$$$$r   N)r^   r_   r`   ra   r5   r   r   r   r   r     s-         % % % % %r   r   c                 z    | j         \  }}t          j        ||f          }|| |dd|||z   f<   n	| |dd|f<   |S )aq  helper function to expand constraints to a full restriction matrix

    Parameters
    ----------
    contrasts : ndarray
        restriction matrix for t_test
    k_params : int
        number of parameters
    idx_start : int
        Index of the first parameter of this factor. The restrictions on the
        factor are inserted as a block in the full restriction matrix starting
        at column with index `idx_start`.
    index : slice or ndarray
        Column index if constraints do not form a block in the full restriction
        matrix, i.e. if parameters that are subject to restrictions are not
        consecutive in the list of parameters.
        If index is not None, then idx_start is ignored.

    Returns
    -------
    contrasts : ndarray
        restriction matrix with k_params columns and number of rows equal to
        the number of restrictions.
    N)rr   r%   r   )r   r   r   indexk_ck_pr   s          r   _embed_constraintsr     s\    4 HC
#x!!A},5!!!YS(
())!!!U(Hr   pairwisec                     | }|j         \  }}ddlmc mc m} |dv r|                    |           }nt          d          |                    |          }	|"|t          d          t          |	||          }	|	S )a  helper function to create constraints based on encoding matrix

    Parameters
    ----------
    encoding_matrix : ndarray
        contrast matrix for the encoding of a factor as defined by patsy.
        The number of rows should be equal to the number of levels or categories
        of the factor, the number of columns should be equal to the number
        of parameters for this factor.
    comparison : str
        Currently only 'pairwise' is implemented. The restriction matrix
        can be used for testing the hypothesis that all pairwise differences
        are zero.
    k_params : int
        number of parameters
    idx_start : int
        Index of the first parameter of this factor. The restrictions on the
        factor are inserted as a block in the full restriction matrix starting
        at column with index `idx_start`.

    Returns
    -------
    contrast : ndarray
        Contrast or restriction matrix that can be used in hypothesis test
        of model results. The number of columns is k_params.
    r   N)r   pwpairsz!currentlyonly pairwise comparisonz3if k_params is not None, then idx_start is required)
rr   #statsmodels.sandbox.stats.multicompsandboxr   	multicompcontrast_allpairsr:   rz   rw   r   )
encoding_matrix
comparisonr   r   cmr   r   mcc_allr   s
             r   _constraints_factorr   &  s    : 
B8LGS444444444444000%%g...!"EFFF		"I ( ) ) )&y(IFF	r   Fc                 @   | j         j        j        }|j                            |          }|j        |         }|j        |         j        }	|s't          |j	                  dk    rt          d          |j	        d         }
|j        |
         j        }|Bt          |          t          |          k    r|}nt          dt          |          z            t          |          }|j        |         d         j        |
         j        }t          | j                  }t#          ||          }ddlmc mc m} |                    |           }|                    |          }t1          |||	          }t3          | ||d||          }t5          |||||          }|S )a  
    Perform pairwise t_test with multiple testing corrected p-values.

    This uses the formula design_info encoding contrast matrix and should
    work for all encodings of a main effect.

    Parameters
    ----------
    result : result instance
        The results of an estimated model with a categorical main effect.
    term_name : str
        name of the term for which pairwise comparisons are computed.
        Term names for categorical effects are created by patsy and
        correspond to the main part of the exog names.
    method : {str, list[str]}
        multiple testing p-value correction, default is 'hs',
        see stats.multipletesting
    alpha : float
        significance level for multiple testing reject decision.
    factor_labels : {list[str], None}
        Labels for the factor levels used for pairwise labels. If not
        provided, then the labels from the formula design_info are used.
    ignore : bool
        Turn off some of the exceptions raised by input checks.

    Returns
    -------
    MultiCompResult
        The results are stored as attributes, the main attributes are the
        following two. Other attributes are added for debugging purposes
        or as background information.

        - result_frame : pandas DataFrame with t_test results and multiple
          testing corrected p-values.
        - contrasts : matrix of constraints of the null hypothesis in the
          t_test.

    Notes
    -----

    Status: experimental. Currently only checked for treatment coding with
    and without specified reference level.

    Currently there are no multiple testing corrected confidence intervals
    available.
    r7   z%interaction effects not yet supportedr   Nz0factor_labels has the wrong length, should be %d)r   r   r1   r   )result_framer   rj   contrast_labelsterm_encoding_matrix)modeldatadesign_info
term_namesr   termsterm_slicesstartr.   factorsrw   factor_infos
categoriesterm_codingscontrast_matricesrq   paramsr   r   r   r   r   r   rz   r   r   r   )r   	term_namer   r1   factor_labelsignoredesinfoterm_idxrj   r   factorcatr   r   r   r   r   c_all_pairscontrasts_subr   r   ress                         r   t_test_pairwiser   U  s   b l+G!''	22H="D#D)/I Bc$,''!++@AAA\!_F

v
&
1C }S))CCORUVYRZRZZ[[[ #hhG		d	#A	&	8	@	GB6=!!Hw,,F444444444444''000KOOB''M"=(IFFI&)Fd %f> > >F
v$-#*0/1	3 3 3C
 Jr   c                      | |z  }| |z  }||z
  S )zoffset to the value of a linear constraint for new params

    usage:
    (cm, v) is original constraint

    vo = offset_constraint(cm, res2.params, params_alt)
    fs = res2.wald_test((cm, v + vo))
    nc = fs.statistic * fs.df_num

    r   )r_matrix
params_est
params_altdiff_estdiff_alts        r   _offset_constraintr     s#     *$H*$Hhr   Tc                     ||| z  |z
  }|                     |          }|r$|t          j                            ||          z  }n)|t          j        t          j        |                    z  }|S )a!  Moncentrality parameter for a wald test in model results

    The null hypothesis is ``diff = r_matrix @ params - value = 0``

    Parameters
    ----------
    params : ndarray
        parameters of the model at which to evaluate noncentrality. This can
        be estimated parameters or parameters under an alternative.
    r_matrix : ndarray
        Restriction matrix or contrasts for the Null hypothesis
    value : None or ndarray
        Value of the linear combination of parameters under the null
        hypothesis. If value is None, then it will be replaced by zero.
    results : Results instance of a model
        The results instance is used to compute the covariance matrix of the
        linear constraints using `cov_params.
    diff : None or ndarray
        If diff is not None, then it will be used instead of
        ``diff = r_matrix @ params - value``
    joint : bool
        If joint is True, then the noncentrality parameter for the joint
        hypothesis will be returned.
        If joint is True, then an array of noncentrality parameters will be
        returned, where elements correspond to rows of the restriction matrix.
        This correspond to the `t_test` in models and is not a quadratic form.

    Returns
    -------
    nc : float or ndarray
        Noncentrality parameter for Wald tests, correspondig to `wald_test`
        or `t_test` depending on whether `joint` is true or not.
        It needs to be divided by nobs to obtain effect size.


    Notes
    -----
    Status : experimental, API will likely change

    N)r   )
cov_paramsr%   rx   solvesqrtdiag)r   r   r3   resultsdiffjointcov_cncs           r   wald_test_noncentr    st    R |& 5(11E ,BIOOE4000BGBGENN+++Ir   c                    |d}||| z  |z
  }|}|                     |                               |j                  }|r$|t          j                            ||          z  }n)|t          j        t          j        |                    z  }|S )a  noncentrality parameter for a wald test

    The null hypothesis is ``diff = r_matrix @ params - value = 0``

    Parameters
    ----------
    params : ndarray
        parameters of the model at which to evaluate noncentrality. This can
        be estimated parameters or parameters under an alternative.
    r_matrix : ndarray
        Restriction matrix or contrasts for the Null hypothesis

    value : None or ndarray
        Value of the linear combination of parameters under the null
        hypothesis. If value is None, then it will be replace by zero.
    cov_params : ndarray
        covariance matrix of the parameter estimates
    diff : None or ndarray
        If diff is not None, then it will be used instead of
        ``diff = r_matrix @ params - value``
    joint : bool
        If joint is True, then the noncentrality parameter for the joint
        hypothesis will be returned.
        If joint is True, then an array of noncentrality parameters will be
        returned, where elements correspond to rows of the restriction matrix.
        This correspond to the `t_test` in models and is not a quadratic form.

    Returns
    -------
    nc : float or ndarray
        Noncentrality parameter for Wald tests, correspondig to `wald_test`
        or `t_test` depending on whether `joint` is true or not.
        It needs to be divided by nobs to obtain effect size.


    Notes
    -----
    Status : experimental, API will likely change
    Nr   )rz   rn   r%   rx   r   r  r  )	r   r   r3   r   r  r  r   r  r  s	            r   wald_test_noncent_genericr
    s    R }|& 5(AEE*!!!#&&E ,BIOOE4000BGBGENN+++Ir   r@   )r   r   NN)r   NN)r   r   NF)NT)numpyr%   scipy.statsr   r   r   r$   scipyr   statsmodels.tools.toolsr   r   statsmodels.stats.multitestr   r
   rc   rp   r   r   r   r   r   r   r   r   r   r  r
  r   r   r   <module>r     s        " " " " " " & & & & & &       4 4 4 4 4 4 4 4 5 5 5 5 5 5mD mD mD mD mD mD mD mDbb b b b b b b bJ8 8 8 8x?; ?; ?; ?; ?; ?; ?; ?;J  ' ' 'T HL $$ $ $ $N% % % % % % % %       F JN"&, , , ,^ ;?/4Q Q Q Qh   1 1 1 1h IM$(5 5 5 5 5 5r   