
    M/Phuy                         d dl mZmZmZ d dlZd dlmZ d dlZd dlZ	d dl
mZ d dlmZmZmZmZ ddlmZ dd	ZddZ	 	 ddZddZddZ	 	 d dZ	 	 d!dZ	 	 d"dZ	 	 d#dZd$dZd%dZ G d d          ZdS )&    )lmaplrangelzipN)zip_longest)SimpleTable)fmt_2	fmt_2cols
fmt_paramsgen_fmt   )_model_types   c                 H   t          j        |           } |dk    r0t          |           dk    st          |           dk     rd| z  S d| z  S |dk    r0t          |           dk    st          |           dk     rd| z  S d| z  S t          d	                    |
                    )Nr   g     @g-C6?z%9.3gz%9.3f   z%10.4gz%10.4fz1`prec` argument must be either 3 or 4, not {prec}prec)npsqueezeabs
ValueErrorformat)xr   s     Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/iolib/summary.pyforgr      s    

1AqyyFFcMMs1vv}}Q;Q;	FFcMMs1vv}}a<a<L &d&++- - 	-       c                 f    t          j        |           r|dz
  dz  dz   S | dz  | k    rd| z  S d| z  S )am  convert number to string with either integer of float formatting

    This is used internally for nobs and degrees of freedom which are usually
    integers but can be float in some cases.

    Parameters
    ----------
    x : int or float
    width : int
        only used if x is nan

    Returns
    -------
    str : str
        number as formatted string
    r    NaNr   z%#6dz%#8.2f)r   isnan)r   widths     r   d_or_fr"   &   sI    " 
x{{ )	S 5((Av{{z!|r   皙?textc                   !"#$%&' |dk    rt           | j        j        j                 }|Yt	          |          t	          | j                  k    r4t          d                    t	          | j                                      t          | ||          \  }}t          j
                    }t          j        d|          g}t          j        d|          }	| j        j        j        }
| j        }| j        }| j        }d|
gfd|	gfd|fd	|gfg}t          | \  }}|}d}t!          ||||t"          
          }d}|
g||g|gf}t!          ||||t"          
          }|                    |           |"|                                 |                                 |                                 |                                 |                                 |                                 d}| j        | j        | j        | j        | j        | j        d}t+          d|z
  dz            dz   }dddd|dz   gdddd|dz   gdddd|dz   gdddd|dz   gdddd|dz   gdddd|dz   gd}|}| j        $|                     |          !| j        &t1          t	          |                    }||
         '||
         %t3          $fd|D             &fd|D             'fd|D             %fd|D             !fd|D                       }t!          |||
         |dt4          
          #"#fd}"#fd}||d} |d k    r1	  | |
                     S # t6          $ r  | d!                     cY S w xY wdS )"a  
    Parameters
    ----------
    yname : str
            optional, Default is `Y`
    xname : list[str]
            optional, Default is `X.#` for # in p the number of regressors
    Confidance interval : (0,1) not implimented
    title : str
            optional, Defualt is 'Generalized linear model'
    returns : str
              'text', 'table', 'csv', 'latex', 'html'

    Returns
    -------
    Default :
    returns='print'
            Prints the summarirized results

    Option :
    returns='text'
            Prints the summarirized results

    Option :
    returns='table'
             SimpleTable instance : summarizing the fit of a linear model.

    Option :
    returns='csv'
            returns a string of csv of the results, to import into a spreadsheet

    Option :
    returns='latex'
    Not implimented yet

    Option :
    returns='HTML'
    Not implimented yet


    Examples (needs updating)
    --------
    >>> import statsmodels as sm
    >>> data = sm.datasets.longley.load()
    >>> data.exog = sm.add_constant(data.exog)
    >>> ols_results = sm.OLS(data.endog, data.exog).results
    >>> print ols_results.summary()
    ...

    Notes
    -----
    conf_int calculated from normal dist.
    r   Nz`User supplied xnames must have the same number of entries as the number of model parameters ({})%H:%M:%S%a, %d %b %YModel type:Date:Dependent Variable:zdf modeltitletxt_fmt)zMethod:Time:Number of Obs:zdf resid)OLSGLSGLSARWLSRLMGLMr   d   %coefstd errtP>|t|z Conf. IntervalzP>|z|)r0   r1   r2   r3   r5   r4   c                 &    g | ]}d |         z  S )z%#6.4g .0iparamss     r   
<listcomp>zsummary.<locals>.<listcomp>   s"    AAA1F1I.AAAr   c                 &    g | ]}d |         z  S z%#6.4fr?   rA   rB   std_errs     r   rD   zsummary.<locals>.<listcomp>   "    BBBAGAJ/BBBr   c                 &    g | ]}d |         z  S rF   r?   )rA   rB   tstats     r   rD   zsummary.<locals>.<listcomp>   s"    @@@!E!H-@@@r   c                 &    g | ]}d |         z  S rF   r?   )rA   rB   	prob_stats     r   rD   zsummary.<locals>.<listcomp>   s"    DDDaIaL1DDDr   c                 @    g | ]}d t          |                   z  S )z(%#5g, %#5g))tuplerA   rB   conf_ints     r   rD   zsummary.<locals>.<listcomp>   s*    NNNx{););;NNNr   c                  L    t                    dz   t                    z   } | S )z4
        print summary table for ols models
        
strtablegeneral_tableparameter_tables    r   ols_printerzsummary.<locals>.ols_printer   s)     M""4'O(<(<<r   c                  L    t                    dz   t                    z   } | S )NrS   rT   rV   s    r   glm_printerzsummary.<locals>.glm_printer   s'    M""4'O(<(<<r   )r0   r5   printr0   )r   model	__class____name__lenrC   r   r   	_getnamestime	localtimestrftimenobsdf_modeldf_residr   r   r   extend_rightr:   pvaluesrU   rQ   bser   r   r   KeyError)(selfynamexnamer,   alphareturns
model_infotime_nowtime_of_daydate	modeltyperf   rg   rh   gen_leftgen_stubs_leftgen_data_left	gen_title
gen_headergen_table_leftgen_stubs_rightgen_data_rightgen_table_righttstats
prob_statsalpparam_headerparams_stubsexog_lenparams_datarZ   r\   printersrQ   rX   rY   rC   rM   rH   rK   s(                                    @@@@@@@r   summaryr   @   sn   n zzTZ1:;SZZ3t{+;+;;;   &s4;'7'7 8 8: : 	: T5%00LE5~H=X667K=22D
$-I9D}H}H ,4&!&.hZ(H
 %0$:!NMIJ !+!/'0)0	# # #N#O !k!fjN
 ".","1(1*1	$ $ $O 000"M VVXXVVXXvvxxVVXXVVXXVVXX F < J qwm

S
 CIsGS;L5LMIsGS;L5LMIsGS;L5LMIsGS;L5LMIsGS;L5LMIsGS;L5LM L L[F}}U##HhGc%jj!!H9E9%I AAAAAAABBBBBBB@@@@x@@@DDDD8DDDNNNNXNNN	P PK
 "+".y"9".(,*/	$ $ $O            #;77H'	%&8I&((( 	% 	% 	%"8E?$$$$$	% s   6M M#"M#c                     |%t          | j        dd          | j        j        }nd}|Nt          | j        dd          | j        j        }n+d t	          t          | j                            D             }||fS )z0extract names from model or construct names
    Nendog_namesy
exog_namesc                     g | ]}d |z  S )zvar_%dr?   rA   rB   s     r   rD   z_getnames.<locals>.<listcomp>  s    CCCaX\CCCr   )getattrr^   r   r   rangera   rC   )rm   rn   ro   s      r   rb   rb      s     }4:}d33?J*EEE}4:|T22>J)EECC5T[1A1A+B+BCCCE%<r   c                     ||}}t          j                    }t          j        d|          gt          j        d|          t           |          \  }t	          dfdfdfdfd fd	fd
fdfdfdfd fdfd fdfd fdfd fdfd fdfg
          }	| j        j        j        dz   }|+g d}	  j        }
|	                    d           n#  Y nxY wg }|}d}g }|D ].\  }}| |	|                     }|	                    ||f           /|}|r5g }|D ].\  }}| |	|                     }|	                    ||f           /|}d ||z   D             }|g k    s
J |            |rt          |          t          |          k     r'|dgt          |          t          |          z
  z  z  }nFt          |          t          |          k    r&|dgt          |          t          |          z
  z  z  }d |D             }t          | \  }}t          ||||t                    }ng }t          | \  }}t          ||||t                    }|                    |           |}|S ) zgenerate top table(s)


    TODO: this still uses predefined model_methods
    ? allow gleft, gright to be 1 element tuples instead of filling with None?

    r&   r'   rn   ro   r*   c                  
     gS Nr?   rn   s   r   <lambda>zsummary_top.<locals>.<lambda>&  s	    5' r   Dep. Variable:c                  
     gS r   r?   r   s   r   r   zsummary_top.<locals>.<lambda>'  s	    eW r   zModel:c                  (     j         j        j        gS r   )r^   r_   r`   resultss   r   r   zsummary_top.<locals>.<lambda>(  s    gm5>? r   r)   c                  
     gS r   r?   )ru   s   r   r   zsummary_top.<locals>.<lambda>)  s	    TF r   r.   c                       S r   r?   )rt   s   r   r   zsummary_top.<locals>.<lambda>*  s    K r   r/   c                       j         gS r   )rf   r   s   r   r   zsummary_top.<locals>.<lambda>+  s    gl^ r   No. Observations:c                  .    t           j                  gS r   )r"   rf   r   s   r   r   zsummary_top.<locals>.<lambda>,  s    )=)=(> r   z	Df Model:c                  .    t           j                  gS r   )r"   rg   r   s   r   r   zsummary_top.<locals>.<lambda>-  s    (8!9!9 : r   zDf Residuals:c                  .    t           j                  gS r   )r"   rh   r   s   r   r   zsummary_top.<locals>.<lambda>.  s    VG,<%=%=$> r   zLog-Likelihood:c                      d j         z  gS )Nz%#8.5g)llfr   s   r   r   zsummary_top.<locals>.<lambda>/  s    x'+'=&> r   NzRegression Results))r   N)r(   N)r)   N)r   N)z	Df model:N)z	Df resid:N)zLog-LikelihoodNc                     g | ]	\  }}||
S r   r?   rA   kvs      r   rD   zsummary_top.<locals>.<listcomp>Z  s    EEECAa19a999r   )r   r   c                 (    g | ]\  }}d d|z   z  |fS )z%-21sz  r?   r   s      r   rD   zsummary_top.<locals>.<listcomp>h  s*    BBB1ga(!,BBBr   r+   )rc   rd   re   rb   dictr^   r_   r`   r   appendra   r   r   r	   ri   )r   r,   gleftgrightrn   ro   rw   	gen_rightrs   default_itemsr   rz   r{   	gen_left_itemvalue
gen_right_missing_valuesr}   r~   r   rx   ry   r|   rX   ru   rt   s   `   `                    @@r   summary_topr     s     iH ~H=X667K=22DWE???LE5  ////
2____
-????
@NNNN
#''''
(3333
4 > > > >
?::::
;>>>>
?>>>>
?  M }'03GG) ) )	+COO45555	D	IJ I ( (e='M$'))E$''''H 
$ 	- 	-KD%}+d+--tUm,,,,	 FE8i#7EEENR  y>>CMM))*XY)GHHII^^c(mm++IX(FGGH CB	BBB	*5y*A'%n&0&5,5.7	( ( (  %0$:!NM !+!/'0)2	# # #N 000"Ms   C! !C%TFc           
         t          | t                    r
| \  } nt          j        | j                  t          j        | j                  t          j        | j                  t          j        | j                  t          j        |                     |                    j	        dk    rt          dgg          S |r2dddddt          |dz            z   t          d	|dz  z
            d
z   g}n1dddddt          |dz            z   t          d	|dz  z
            d
z   g}|rd}t          | ||          \  }}t          |          t                    k    rt          d          |}	t          t          |                    }
t          j                  t          j                  t          j                  t          j                  t          j                  t!          fd|
D             fd|
D             fd|
D             fd|
D             fd|
D             fd|
D                       }t          |||	|t"                    }|S )a#  create a summary table for the parameters

    Parameters
    ----------
    res : results instance
        some required information is directly taken from the result
        instance
    yname : {str, None}
        optional name for the endogenous variable, default is "y"
    xname : {list[str], None}
        optional names for the exogenous variables, default is "var_xx"
    alpha : float
        significance level for the confidence intervals
    use_t : bool
        indicator whether the p-values are based on the Student-t
        distribution (if True) or on the normal distribution (if False)
    skip_headers : bool
        If false (default), then the header row is added. If true, then no
        header row is added.

    Returns
    -------
    params_table : SimpleTable instance
    r   zNo Model Parametersr8   r9   r:   r;   [   r   ]r<   r=   Nr   z-xnames and params do not have the same lengthc                 >    g | ]}t          |         d           S r   r   r   r@   s     r   rD   z"summary_params.<locals>.<listcomp>  s*    BBBAVAYQ///BBBr   c                 :    g | ]}t          |                   S r?   r   rG   s     r   rD   z"summary_params.<locals>.<listcomp>  %    ;;;QWQZ((;;;r   c                 :    g | ]}t          |                   S r?   r   )rA   rB   tvaluess     r   rD   z"summary_params.<locals>.<listcomp>  r   r   c                 &    g | ]}d |         z  S )z%#6.3fr?   )rA   rB   rj   s     r   rD   z"summary_params.<locals>.<listcomp>  rI   r   c                 >    g | ]}t          |d f                   S )r   r   rP   s     r   rD   z"summary_params.<locals>.<listcomp>  )    >>>Xac]++>>>r   c                 >    g | ]}t          |d f                   S )r   r   rP   s     r   rD   z"summary_params.<locals>.<listcomp>  r   r   r+   )
isinstancerO   r   asarrayrC   rk   r   rj   rQ   sizer   rU   rb   ra   r   r   r   r
   )r   rn   ro   rp   use_tskip_headerr,   r   _r   exog_idxr   rY   rQ   rC   rj   rH   r   s                @@@@@r   summary_paramsr     s   @ '5!! 
7 @G<'7HHGN++*W[))*W_--*W_--:g..u5566{a234555  B	3c%'ll*C%'	NNS,@B 	3c%'ll*C%'	NNS,@B  U;;;HAu
5zzS[[  HIIILc%jj!!HZFj!!Gj!!Gj!!Gz(##HBBBBBBB;;;;(;;;;;;;(;;;BBBBBBB>>>>X>>>>>>>X>>>@ @K "+".".(-*4	$ $ $O r   c                 <   t          | t                    r
| \  } }}}}}	n1| j        }| j        }| j        }| j        }|                     |          }	|rg d}
ng d}
t          | ||          \  }}ddlm	} t          j        |||||	f          } |||
|          S )a(  
    Create a summary table for the parameters

    Parameters
    ----------
    res : results instance
        some required information is directly taken from the result
        instance
    yname : {str, None}
        optional name for the endogenous variable, default is "y"
    xname : {list[str], None}
        optional names for the exogenous variables, default is "var_xx"
    alpha : float
        significance level for the confidence intervals
    use_t : bool
        indicator whether the p-values are based on the Student-t
        distribution (if True) or on the normal distribution (if False)
    skip_headers : bool
        If false (default), then the header row is added. If true, then no
        header row is added.

    Returns
    -------
    params_table : SimpleTable instance
    )r8   r9   r:   r;   Conf. Int. LowConf. Int. Upp.)r8   r9   r<   r=   r   r   r   r   )	DataFrame)columnsindex)r   rO   rC   rk   r   rj   rQ   rb   pandasr   r   column_stack)r   rn   ro   rp   r   rC   rH   r   rj   rQ   r   r   r   rW   s                 r   summary_params_framer     s    B '5!! 
+ @G<'7HH+//##E**  == = == = = U;;;HAu      OVWgwIJJE9UL>>>>r   c                 B    |0d t          j         j        j                  dd         D             }|+d t	          t           j                            D             }d  j        D             }|rc fd|D             }t          |g|R  }d |D             }t          |gdgt          |          z  gt          |          z  R  }d	 |D             }n|}|}t          j	        t                    }	d
g j        j        d         z  |	d<   t          |||||	          S )a  create summary table of regression parameters with several equations

    This allows interleaving of parameters with bse and/or tvalues

    Parameters
    ----------
    result : result instance
        the result instance with params and attributes in extras
    extras : list[str]
        additional attributes to add below a parameter row, e.g. bse or tvalues
    endog_names : {list[str], None}
        names for rows of the parameter array (multivariate endog)
    exog_names : {list[str], None}
        names for columns of the parameter array (exog)
    alpha : float
        level for confidence intervals, default 0.95
    title : None or string

    Returns
    -------
    tables : list of SimpleTable
        this contains a list of all seperate Subtables
    table_all : SimpleTable
        the merged table with results concatenated for each row of the parameter
        array

    Nc                     g | ]}d |z  S )zendog_%dr?   r   s     r   rD   z%summary_params_2d.<locals>.<listcomp>6  s(     : : :!zA~ : : :r   r   c                     g | ]}d |z  S )zvar%dr?   r   s     r   rD   z%summary_params_2d.<locals>.<listcomp>9  s    EEEagkEEEr   c                 &    g | ]}d  |D             S )c                 0    g | ]}t          |d           S r   r   )rA   r   s     r   rD   z0summary_params_2d.<locals>.<listcomp>.<listcomp><  s%    666$41%%%666r   r?   )rA   rows     r   rD   z%summary_params_2d.<locals>.<listcomp><  s'    PPP366#666PPPr   c                 D    g | ]}d  t          |          D             S )c                 &    g | ]}d  |D             S )c                 f    g | ].}d dt          |d                                          z   dz   z  /S )z%10s(r   r   ))r   strip)rA   r   s     r   rD   z;summary_params_2d.<locals>.<listcomp>.<listcomp>.<listcomp>>  sM     ' ' '  3aa)>)>)@)@#@3#FG ' ' 'r   r?   )rA   cols     r   rD   z0summary_params_2d.<locals>.<listcomp>.<listcomp>>  s?     : : :' '"%' ' ' : : :r   )r   )rA   whatresults     r   rD   z%summary_params_2d.<locals>.<listcomp>>  sL         : :#*64#8#8: : :   r   c                     g | ]	}|D ]}|
S r?   r?   rA   jrB   s      r   rD   z%summary_params_2d.<locals>.<listcomp>D  s%    +++a++A++++r    c                     g | ]	}|D ]}|
S r?   r?   r   s      r   rD   z%summary_params_2d.<locals>.<listcomp>F  s%    ---q1--a----r   z%s	data_fmts)headersstubsr,   r-   )r   uniquer^   endogr   ra   rC   r   copydeepcopyr
   shaper   )
r   extrasr   r   r,   
res_paramsextras_listdatar   r-   s
   `         r   summary_params_2dr     s   : : :y!344QRR8: : :EE5V]1C1C+D+DEEE
 QP&-PPPJ     $*  
 J----++4+++[GRD[)9)9$9#:3v;;#FGGG--E---mJ''G 6&-"5a"88GKtZ#(#(%,. . . .r   c           	      6   | }|j         }|j        dk    r;|j        d         }	t          |          |j        d         k    rt	          d          n1t          |          t          |          k    rt	          d          d}	t          |t                    s|d}
n|}
|j        j        dd         }g }t          |	          D ]}||j         dd|f         |j
        dd|f         |j        dd|f         |j        dd|f         |                    |          |         f}d}t          |||         ||||          }|                    |           t          t          |                    D ]}||         ||         _        t#          ||          }||fS )	a  summary table for parameters that are 2d, e.g. multi-equation models

    Parameters
    ----------
    result : result instance
        the result instance with params, bse, tvalues and conf_int
    endog_names : {list[str], None}
        names for rows of the parameter array (multivariate endog)
    exog_names : {list[str], None}
        names for columns of the parameter array (exog)
    alpha : float
        level for confidence intervals, default 0.95
    use_t : bool
        indicator whether the p-values are based on the Student-t
        distribution (if True) or on the normal distribution (if False)
    keep_headers : bool
        If true (default), then sub-tables keep their headers. If false, then
        only the first headers are kept, the other headerse are blanked out
    endog_cols : bool
        If false (default) then params and other result statistics have
        equations by rows. If true, then equations are assumed to be in columns.
        Not implemented yet.

    Returns
    -------
    tables : list of SimpleTable
        this contains a list of all seperate Subtables
    table_all : SimpleTable
        the merged table with results concatenated for each row of the parameter
        array

    r   r   zendog_names has wrong lengthNr   F)rn   ro   rp   r   r   )keep_headers)rC   ndimr   ra   r   r   listr^   r   r   rk   r   rj   rQ   r   r   r,   table_extend)r   r   r   rp   r   r   
endog_colsresrC   n_equendog_basenametableseqrestupskiphtblerB   	table_alls                     r   summary_params_2dflatr  T  s   F CZF{aQ{v|A..;<<< / {s6{{**;<<< k4(( 0$NN(Ni+ABB/FEll 	 	sz!!!B$'2AAAbD8I+aaad#S\\%%8%8%<> fKO$.e5*/1 1 1 	d 3{##$$ ) )%a.q	V,???I9r   c                    ddl m} t          | dd                   D ]\  }} ||          }|d         j        dk    rq|j        |d         d         _        d|d         d         _        |d         d         j        |d         d         _        |s |dk    r|d         dd         D ]	}d|_        
|dk    r|}|d         }|                    dd	
           |	                    |           d|_        |S )a  extend a list of SimpleTables, adding titles to header of subtables

    This function returns the merged table as a deepcopy, in contrast to the
    SimpleTable extend method.

    Parameters
    ----------
    tables : list of SimpleTable instances
    keep_headers : bool
        If true, then all headers are kept. If falls, then the headers of
        subtables are blanked out.

    Returns
    -------
    table_all : SimpleTable
        merged tables as a single SimpleTable instance

    r   )r   Nheaderr   r   txt-)row_dec_below)
r   r   	enumeratedatatyper,   r   	_datatyper   
add_formatextend)r   r   r   iir:   cr  r1s           r   r   r     s   & 6!!!9%%    AHQKK Q4=H$$7AaDGL $AaDGA$q'+AaDGK  R!VV1abb    AAFF 77II2BMM%sM333QIOr   c                    |dk    rEd }d                     t          || d d                   t          | d                   gz             S |dk    r| S |dk    rd                     d | D                       S |dk    rPt          j        | d	                   }| d
d          D ]}|                    |           |                                S |dk    rd                     d | D                       S t          d          )Nr$   c                 T    t          |                               dd          d         S )NrS   r   r   )rU   rsplit)r   s    r   r   z summary_return.<locals>.<lambda>  s    CFFMM$q11!4 r   rS   r	  r   csvc              3   >   K   | ]}|                                 V  d S r   )as_csv)rA   r   s     r   	<genexpr>z!summary_return.<locals>.<genexpr>  s*      44444444r   latexr   r   htmlc              3   >   K   | ]}|                                 V  d S r   as_html)rA   rW   s     r   r  z!summary_return.<locals>.<genexpr>  s*      ==U======r   z3available output formats are text, csv, latex, html)joinr   rU   r   r   r  as_latex_tabularr   )r   
return_fmtstrdroprW   parts        r   summary_returnr&    s   V44yygvcrc{33s6":6GGHHH	x			u		yy44V444444	w		fQi((122J 	 	DLL%%'''	v		yy==f======NOOOr   c                   f    e Zd ZdZd Zd Zd Zd Zd Z	 	 ddZ		 	 ddZ
d Zd Zd Zd Zd ZdS )Summarya  
    Result summary

    Construction does not take any parameters. Tables and text can be added
    with the `add_` methods.

    Attributes
    ----------
    tables : list of tables
        Contains the list of SimpleTable instances, horizontally concatenated
        tables are not saved separately.
    extra_txt : str
        extra lines that are added to the text output, used for warnings
        and explanations.
    c                 "    g | _         d | _        d S r   )r   	extra_txtrm   s    r   __init__zSummary.__init__  s    r   c                 *    |                                  S r   )as_textr+  s    r   __str__zSummary.__str__  s    ||~~r   c                 p    t          t          |                     dz   |                                 z   dz   S )Nz
"""
z
""")rU   typer/  r+  s    r   __repr__zSummary.__repr__  s+    4::*T\\^^;gEEr   c                 *    |                                  S )z$Display as HTML in IPython notebook.r  r+  s    r   _repr_html_zSummary._repr_html_  s    ||~~r   c                 *    |                                  S )z9Display as LaTeX when converting IPython notebook to PDF.)as_latexr+  s    r   _repr_latex_zSummary._repr_latex_  s    }}r   Nc                 d    t          ||||||          }| j                            |           dS )au  
        Add a double table, 2 tables with one column merged horizontally

        Parameters
        ----------
        res : results instance
            some required information is directly taken from the result
            instance
        title : str, optional
            if None, then a default title is used.
        gleft : list[tuple], optional
            elements for the left table, tuples are (name, value) pairs
            If gleft is None, then a default table is created
        gright : list[tuple], optional
            elements for the right table, tuples are (name, value) pairs
        yname : str, optional
            optional name for the endogenous variable, default is "y"
        xname : list[str], optional
            optional names for the exogenous variables, default is "var_xx".
            Must match the number of parameters in the model.
        )r,   r   r   rn   ro   N)r   r   r   )rm   r   r,   r   r   rn   ro   rW   s           r   add_table_2colszSummary.add_table_2cols	  sA    0 CuE&"'u6 6 65!!!!!r   r#   Tc                     |j         j        dk    rt          |||||          }n7|j         j        dk    rt          |||||          \  }}nt	          d          | j                            |           dS )a  create and add a table for the parameter estimates

        Parameters
        ----------
        res : results instance
            some required information is directly taken from the result
            instance
        yname : {str, None}
            optional name for the endogenous variable, default is "y"
        xname : {list[str], None}
            optional names for the exogenous variables, default is "var_xx"
        alpha : float
            significance level for the confidence intervals
        use_t : bool
            indicator whether the p-values are based on the Student-t
            distribution (if True) or on the normal distribution (if False)

        Returns
        -------
        None : table is attached

        r   )rn   ro   rp   r   r   )r   r   rp   r   zparams has to be 1d or 2dN)rC   r   r   r  r   r   r   )rm   r   rn   ro   rp   r   rW   r   s           r   add_table_paramszSummary.add_table_params%  s    0 :?a"3e5).0 0 0EEZ_!!,Se8=38G G GHAuu 89995!!!!!r   c                 :    d                     |          | _        dS )zadd additional text that will be added at the end in text format

        Parameters
        ----------
        etext : list[str]
            string with lines that are added to the text output.

        rS   N)r!  r*  )rm   etexts     r   add_extra_txtzSummary.add_extra_txtH  s     5))r   c                 Z    t          | j        d          }| j        |dz   | j        z   }|S )zreturn tables as string

        Returns
        -------
        txt : str
            summary tables and extra text as one string

        r$   r#  N

r&  r   r*  )rm   r
  s     r   r.  zSummary.as_textS  s5     T[V<<<>%,/C
r   c                     t          | j        d          }| j        !|dz   | j                            dd          z   }|S )aV  return tables as string

        Returns
        -------
        latex : str
            summary tables and extra text as string of Latex

        Notes
        -----
        This currently merges tables with different number of columns.
        It is recommended to use `as_latex_tabular` directly on the individual
        tables.

        r  r@  NrA  rS   z \newline
 r&  r   r*  replace)rm   r  s     r   r6  zSummary.as_latexa  sE     t{w???>%FNT^%;%;D/%R%RREr   c                 Z    t          | j        d          }| j        |dz   | j        z   }|S )zreturn tables as string

        Returns
        -------
        csv : str
            concatenated summary tables in comma delimited format

        r  r@  NrA  rB  )rm   r  s     r   r  zSummary.as_csvu  s5     T[U;;;>%,/C
r   c                     t          | j        d          }| j        !|dz   | j                            dd          z   }|S )zreturn tables as string

        Returns
        -------
        html : str
            concatenated summary tables in HTML format

        r  r@  Nz
<br/><br/>rS   z<br/>rD  )rm   r  s     r   r   zSummary.as_html  sF     dkf===>%,&)?)?g)N)NNDr   NNNNNNNr#   T)r`   
__module____qualname____doc__r,  r/  r2  r4  r7  r9  r;  r>  r.  r6  r  r   r?   r   r   r(  r(    s             F F F     DH*." " " "8 CF#!" !" !" !"F	* 	* 	*    (      r   r(  )r   )r   )NNr   r#   r$   N)NNrH  )NNr#   TFNrI  )NNNN)NNr#   TTF)T)r$   )statsmodels.compat.pythonr   r   r   r   	itertoolsr   rc   numpyr   statsmodels.iolib.tabler   !statsmodels.iolib.tableformattingr   r	   r
   r   summary2r   r   r"   r   rb   r   r   r   r   r  r   r&  r(  r?   r   r   <module>rS     s   8 8 8 8 8 8 8 8 8 8  ! ! ! ! ! !      / / / / / /            # " " " " "- - - -$   4 :='+|% |% |% |%~   $p p p pf FJ,0S S S Sl AD#:? :? :? :?z IM :. :. :. :.z LPDIM M M M`* * * *ZP P P P,h h h h h h h h h hr   