ó
áp7]c        
   @   s®  d  d l  m Z m Z m Z m Z m Z m Z m Z m Z m	 Z	 d  d l
 m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d d l m Z d d l m Z m Z d e f d „  ƒ  YZ d	 „  Z i d
 d 6d d 6d d 6d d 6d d 6d d 6d d 6Z d „  Z d d d e e d d „ Z  d e d „ Z! d d „ Z" d „  Z# d d& e d d' e d „ Z$ d d  „ Z% d! d e e d" d d" d# d# d$ „	 Z& d d d% „ Z' d S((   iÿÿÿÿ(	   t   lranget   iterkeyst	   iteritemst   lzipt   reducet
   itervaluest   zipt   string_typest   range(   t   OrderedDictNi   (   t   SimpleTable(   t	   fmt_latext   fmt_txtt   Summaryc           B   s­   e  Z d  „  Z d „  Z d „  Z d „  Z e e d d d „ Z d d d „ Z d d	 d d
 „ Z	 d „  Z
 d d d „ Z d d d d d d „ Z d „  Z d „  Z d „  Z RS(   c         C   s1   g  |  _  g  |  _ g  |  _ d  |  _ t |  _ d  S(   N(   t   tablest   settingst	   extra_txtt   Nonet   titlet   Falset   _merge_latex(   t   self(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   __init__   s
    				c         C   s
   |  j  ƒ  S(   N(   t   as_text(   R   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   __str__   s    c         C   s"   t  t |  ƒ ƒ d |  j ƒ  d S(   Ns   
"""
s   
"""(   t   strt   typeR   (   R   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   __repr__   s    c         C   s
   |  j  ƒ  S(   s$   Display as HTML in IPython notebook.(   t   as_html(   R   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   _repr_html_   s    s   %.4ft   rc         C   sF   i | d 6| d 6| d 6| d 6} |  j  j | ƒ |  j j | ƒ d S(   s§  Add the contents of a DataFrame to summary table

        Parameters
        ----------
        df : DataFrame
        header: bool
            Reproduce the DataFrame column labels in summary table
        index: bool
            Reproduce the DataFrame row labels in summary table
        float_format: string
            Formatting to float data columns
        align : string
            Data alignment (l/c/r)
        t   indext   headert   float_formatt   alignN(   R   t   appendR   (   R   t   dfR   R    R!   R"   R   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   add_df#   s    c      
   C   s8   t  j | ƒ } |  j | d t d t d | d | ƒd S(   s  Add the contents of a Numpy array to summary table

        Parameters
        ----------
        array : numpy array (2D)
        float_format: string
            Formatting to array if type is float
        align : string
            Data alignment (l/c/r)
        R   R    R!   R"   N(   t   pdt	   DataFrameR%   R   (   R   t   arrayR"   R!   t   table(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt	   add_array9   s    i   t   lc   
      C   sý   g  t  | ƒ D] } t | | ƒ ^ q } g  t | ƒ D] } t | | ƒ ^ q5 } t j t | | ƒ ƒ } | j d | d k rÂ | | j d | }	 t j | t j |	 d d g g ƒ g ƒ } n  t j | | ƒ } t	 d „  | ƒ } |  j
 | d | ƒd S(   s  Add the contents of a Dict to summary table

        Parameters
        ----------
        d : dict
            Keys and values are automatically coerced to strings with str().
            Users are encouraged to format them before using add_dict.
        ncols: int
            Number of columns of the output table
        align : string
            Data alignment (l/c/r)
        i    t    c         S   s   t  j |  | g ƒ S(   N(   t   npt   hstack(   t   xt   y(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   <lambda>`   R,   R"   N(   R   t
   _formatterR   R-   R(   R   t   shapet   vstackt   splitR   R*   (
   R   t   dt   ncolsR"   R!   R/   t   keyst   valst   datat   pad(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   add_dictI   s    ((.c         C   s   |  j  j | ƒ d S(   s—   Append a note to the bottom of the summary table. In ASCII tables,
        the note will be wrapped to table width. Notes are not indendented.
        N(   R   R#   (   R   t   string(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   add_textc   s    c         C   sk   t  | t ƒ r | |  _ nL y9 | j j j } | t k rF t | } n  d | |  _ Wn d |  _ n Xd S(   s  Insert a title on top of the summary table. If a string is provided
        in the title argument, that string is printed. If no title string is
        provided but a results instance is provided, statsmodels attempts
        to construct a useful title automatically.
        s	   Results: R,   N(   t
   isinstanceR   R   t   modelt	   __class__t   __name__t   _model_types(   R   R   t   resultsR@   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt	   add_titlei   s    gš™™™™™©?c   	      C   s˜   t  | d | d | j ƒ} t | ƒ } | d	 k	 r? | | _ n  | d	 k	 rX | | d <n  |  j | d d ƒ|  j | d | ƒ|  j d | d | ƒ d	 S(
   s_  Try to construct a basic summary instance.

        Parameters
        ----------
        results : Model results instance
        alpha : float
            significance level for the confidence intervals (optional)
        float_formatting: string
            Float formatting for summary of parameters (optional)
        title : string
            Title of the summary table (optional)
        xname : List of strings of length equal to the number of parameters
            Names of the independent variables (optional)
        yname : string
            Name of the dependent variable (optional)
        t   alphat   use_ts   Dependent Variable:R"   R+   R!   R   RD   N(   t   summary_paramsRG   t   summary_modelR   R   R<   R%   RE   (	   R   RD   RF   R!   R   t   xnamet   ynamet   paramt   info(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   add_basez   s    c         C   s†  |  j  } |  j } |  j } |  j } t | | ƒ \ } } } | d } t | | | | ƒ }	 g  |	 D] }
 |
 j ƒ  ^ qb } d j | ƒ } | j d ƒ } | | d <| j	 | ƒ d j | ƒ } | d k	 r| } t | ƒ | k  rd t | d t | ƒ d ƒ | } qn d } g  | D] }
 t j |
 | ƒ ^ q} g  | D] }
 d j |
 ƒ ^ q@} d j | ƒ } d j | | | g ƒ } | S(   s%   Generate ASCII Summary Table
        t   =s   
i    t    i   R,   N(   R   R   R   R   t   _measure_tablest   _simple_tablesR   t   joinR5   R#   R   t   lent   intt   textwrapt   wrap(   R   R   R   R   R   t   pad_colt	   pad_indext   widestt
   rule_equalt   simple_tablesR/   t   tabt   txtt   out(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR   —   s.    				

,%"c         C   s\   |  j  } |  j } |  j } t | | ƒ } g  | D] } | j ƒ  ^ q1 } d j | ƒ } | S(   s$   Generate HTML Summary Table
        s   
(   R   R   R   RR   R   RS   (   R   R   R   R   R\   R/   R]   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR   ¼   s    			c   	      C   sÇ   |  j  } |  j } |  j } | d
 k	 r8 d | d } n d } t | | ƒ } g  | D] } | j ƒ  ^ qT } d j | ƒ } d } |  j r¢ t j	 | d | ƒ } n  d | | d f } d	 j | ƒ } | S(   s%   Generate LaTeX Summary Table
        s	   \caption{t   }s
   \caption{}s   
\hline
s8   \\hline\n\\hline\n\\end{tabular}\n\\begin{tabular}{.*}\ns   \\midrule\ns   \begin{table}s   \end{table}s   
N(
   R   R   R   R   RR   t   as_latex_tabularRS   R   t   ret   sub(	   R   R   R   R   R\   R/   R]   t
   to_replaceR_   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   as_latexË   s    				N(   RB   t
   __module__R   R   R   R   t   TrueR%   R*   R<   R>   R   RE   RN   R   R   Re   (    (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR      s   								%	c         C   s  t  |  | ƒ } g  | D] } | j ƒ  ^ q } g  | D] } t | j ƒ  d ƒ ^ q5 } t | ƒ } g  } g  } x€ t t | ƒ ƒ D]l }	 t |  |	 j d d d ƒ }
 t | | |	 |
 ƒ } | j | ƒ | |	 |
 | } | j | | ƒ q‚ W| | t | ƒ f S(   sô   Compare width of ascii tables in a list and calculate padding values.
    We add space to each col_sep to get us as close as possible to the
    width of the largest table. Then, we add a few spaces to the first
    column to pad the rest.
    i    i   (	   RR   R   RT   t
   splitlinest   maxR   R3   RU   R#   (   R   R   R\   R/   R]   t   lengtht   len_maxt   pad_sepRY   t   it   nsepR;   t   len_new(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyRQ   ç   s    )s   Ordinary least squarest   OLSs   Generalized least squarest   GLSs$   Generalized least squares with AR(p)t   GLSARs   Weighted least squarest   WLSs   Robust linear modelt   RLMs   Negative binomial modelt   NBins   Generalized linear modelt   GLMc         C   sî  d „  } t  ƒ  } d „  | d <d „  | d <d „  | d <d „  | d	 <| | d
 <d „  | d <d „  | d <d „  | d <d „  | d <d „  | d <d „  | d <d „  | d <d „  | d <d „  | d <|  j rÔ d n d } d „  | d  | d! <d" „  | d# | d! <d$ „  | d% <d& „  | d' <d( „  | d) <d* „  | d+ <d, „  | d- <d. „  | d/ <d0 „  | d1 <d2 „  | d3 <d4 „  | d5 <d6 „  | d7 <d8 „  | d9 <t  ƒ  } xK t | ƒ D]= \ } } y | |  ƒ | | <Wq©t t t f k
 råq©Xq©W| S(:   s3   Create a dict with information about the model
    c          _   s   t  j  j ƒ  } | j d ƒ S(   Ns   %Y-%m-%d %H:%M(   t   datetimet   nowt   strftime(   t   argst   kwdsRx   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   time_now  s    c         S   s   |  j  j j S(   N(   R@   RA   RB   (   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s   Model:c         S   s   |  j  j j S(   N(   t   familyt   __classRB   (   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s   Model Family:c         S   s   |  j  j j j S(   N(   R}   t   linkRA   RB   (   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s   Link Function:c         S   s
   |  j  j S(   N(   R@   t   endog_names(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s   Dependent Variable:s   Date:c         S   s   d |  j  S(   Ns   %#6d(   t   nobs(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s   No. Observations:c         S   s   d |  j  S(   Ns   %#6d(   t   df_model(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s	   Df Model:c         S   s   d |  j  S(   Ns   %#6d(   t   df_resid(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s   Df Residuals:c         S   s   |  j  d S(   Nt	   converged(   t   mle_retvals(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s
   Converged:c         S   s   |  j  d S(   Nt
   iterations(   R…   (   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s   No. Iterations:c         S   s   |  j  S(   N(   t   method(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s   Method:c         S   s   |  j  d S(   Nt   norm(   t   fit_options(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   s   Norm:c         S   s   |  j  d S(   Nt	   scale_est(   R‰   (   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1      R,   s   Scale Est.:c         S   s   |  j  d S(   Nt   cov(   R‰   (   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   !  R,   s
   Cov. Type:R,   s    (uncentered)c         S   s   d |  j  S(   Ns   %#8.3f(   t   rsquared(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   $  R,   s	   R-squaredt   :c         S   s   d |  j  S(   Ns   %#8.3f(   t   rsquared_adj(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   %  R,   s   Adj. R-squaredc         S   s   d |  j  S(   Ns   %#8.3f(   t	   prsquared(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   &  R,   s   Pseudo R-squared:c         S   s   d |  j  S(   Ns   %8.4f(   t   aic(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   '  R,   s   AIC:c         S   s   d |  j  S(   Ns   %8.4f(   t   bic(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   (  R,   s   BIC:c         S   s   d |  j  S(   Ns   %#8.5g(   t   llf(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   )  R,   s   Log-Likelihood:c         S   s   d |  j  S(   Ns   %#8.5g(   t   llnull(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   *  R,   s   LL-Null:c         S   s   d |  j  S(   Ns   %#8.5g(   t
   llr_pvalue(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   +  R,   s   LLR p-value:c         S   s   d |  j  S(   Ns   %#8.5g(   t   deviance(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   ,  R,   s	   Deviance:c         S   s   d |  j  S(   Ns   %#6.3g(   t   pearson_chi2(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   -  R,   s   Pearson chi2:c         S   s   d |  j  S(   Ns   %#8.4g(   t   fvalue(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   .  R,   s   F-statistic:c         S   s   d |  j  S(   Ns   %#6.3g(   t   f_pvalue(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   /  R,   s   Prob (F-statistic):c         S   s   d |  j  S(   Ns   %#8.5g(   t   scale(   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   0  R,   s   Scale:(   R	   t
   k_constantR   t   AttributeErrort   KeyErrort   NotImplementedError(   RD   R|   RM   t   rsquared_typeR_   t   keyt   func(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyRI     sJ    		
	gš™™™™™©?s   %.4fc      	   C   sm  t  |  t ƒ r* |  \ }  } } }	 }
 } n3 |  j } |  j } |  j }	 |  j }
 |  j | ƒ } t j | | |	 |
 g ƒ j	 } t j
 | | g ƒ } t j | ƒ } | rã d d d d d t | d ƒ t d | d ƒ d g | _ n; d d d	 d
 d t | d ƒ t d | d ƒ d g | _ | s`y |  j j j | _ Wqit k
 r\|  j j | _ qiXn	 | | _ | S(   s…  create a summary table of parameters from results instance

    Parameters
    ----------
    res : results instance
        some required information is directly taken from the result
        instance
    yname : string or None
        optional name for the endogenous variable, default is "y"
    xname : list of strings or 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.
    float_format : string
        float formatting options (e.g. ".3g")

    Returns
    -------
    params_table : SimpleTable instance
    s   Coef.s   Std.Err.t   ts   P>|t|t   [i   i   t   ]t   zs   P>|z|(   R?   t   tuplet   paramst   bset   tvaluest   pvaluest   conf_intR-   R(   t   TR.   R&   R'   R   t   columnsR@   R:   t   param_namesR   R›   t
   exog_names(   RD   RK   RJ   RF   RG   t   skip_headerR!   R¦   R§   R¨   R©   Rª   R:   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyRH   <  s,    				2/	c            sÊ  t  |  ƒ } x5 | j d  D]& } | | j ‡  f d †  ƒ | | <q Wd | j d d … d f d | j d d … d f <| rt| j d d … d f d k  } | j | | j d	 f d
 | j | | j d	 f <| j d d … d f d k  } | j | | j d	 f d
 | j | | j d	 f <| j d d … d f d k  } | j | | j d	 f d
 | j | | j d	 f <n  | j d d … d d … f } | j ƒ  } t j | ƒ } t |  j	 j
 ƒ g | _ | S(   s<   Stack coefficients and standard errors in single column
    i   c            s   ˆ  |  S(   N(    (   R/   (   R!   (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     R,   t   (Ni   t   )i   gš™™™™™¹?i    t   *gš™™™™™©?g{®Gáz„?(   RH   R¬   t   applyt   iloct   loct   stackR&   R'   R   R@   R€   (   t   resultR!   t   starst   rest   colt   idx(    (   R!   s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   _col_paramsy  s     $4225c         C   s¶   | d k r i  } n  g  } g  } xf | D]^ } t | | t ƒ rG q( n  y | j | | |  ƒ ƒ Wn | j d ƒ n X| j | ƒ q( Wt j i | t |  j j ƒ 6d | ƒ} | S(   s!   Stack model info in a column
    R,   R   N(	   R   R?   t   dictR#   R&   R'   R   R@   R€   (   R·   t	   info_dictR_   R   Rm   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt	   _col_info”  s    	(c         C   s‚   t  t |  ƒ ƒ t  |  ƒ k r" |  Sd d l m } | t ƒ } g  } x7 |  D]/ } | | c d 7<| j | d | | ƒ qK W| S(   Niÿÿÿÿ(   t   defaultdictt   IRP   (   RT   t   sett   collectionsRÀ   R   R#   (   t   list_of_namesRÀ   t   name_counterR    t   _name(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   _make_unique©  s    c         C   s™  t  |  t ƒ s |  g }  n  g  |  D] } t | d | d | ƒ^ q" } | r[ t | ƒ }	 n& t g  | D] } | j d ^ qe ƒ }	 x. t t | ƒ ƒ D] }
 |	 |
 g | |
 _ q” Wd „  } t | | ƒ } | rÄ| j j	 d ƒ j
 ƒ  } g  | D] } | | k rï | ^ qï } g  | D] } | | d g k r| ^ q} | t t j | ƒ ƒ } d „  } | t j | ƒ ƒ | _ | j | | ƒ ƒ } g  | j D] } | d  ^ q’| _ | rÄ| j | } qÄn  t j t | j d ƒ ƒ d d	 k } t j | d | j j	 d ƒ ƒ | _ | rNg  |  D]* } t | | j | j j j | ƒ ƒ ^ q} n. g  |  D]! } t | t | d
 d ƒ ƒ ^ qU} xI t | t g  | D] } | j d ^ qƒ ƒ D] \ } } | g | _ q¬Wd „  } t | | ƒ } t j t j | | g ƒ ƒ } | j | _ t j | j j
 ƒ  | j j
 ƒ  ƒ | _ | } | j d ƒ } t  ƒ  } t! | _" | j# | d t! d d ƒ| j$ d ƒ | r•| j$ d ƒ n  | S(   sØ  
    Summarize multiple results instances side-by-side (coefs and SEs)

    Parameters
    ----------
    results : statsmodels results instance or list of result instances
    float_format : string, optional
        float format for coefficients and standard errors
        Default : '%.4f'
    model_names : list of strings, optional
        Must have same length as the number of results. If the names are not
        unique, a roman number will be appended to all model names
    stars : bool
        print significance stars
    info_dict : dict
        dict of functions to be applied to results instances to retrieve
        model info. To use specific information for different models, add a
        (nested) info_dict with model name as the key.
        Example: `info_dict = {"N":..., "R2": ..., "OLS":{"R2":...}}` would
        only show `R2` for OLS regression models, but additionally `N` for
        all other results.
        Default : None (use the info_dict specified in
        result.default_model_infos, if this property exists)
    regressor_order : list of strings, optional
        list of names of the regressors in the desired order. All regressors
        not specified will be appended to the end of the list.
    drop_omitted : bool, optional
        Includes regressors that are not specified in regressor_order. If False,
        regressors not specified will be appended to end of the list. If True,
        only regressors in regressors_list will be included.
    R¸   R!   i    c         S   s   |  j  | d d d t d t ƒS(   Nt   howt   outert   right_indext
   left_index(   t   mergeRg   (   R/   R0   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   æ  s   R,   c         S   s.   t  g  |  D] } | d | d g ^ q
 g  ƒ S(   Nt   coeft   stde(   t   sum(   R»   R/   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   ð  R,   iüÿÿÿi   i   t   default_model_infosc         S   s   |  j  | d d d t d t ƒS(   NRÈ   RÉ   RÊ   RË   (   RÌ   Rg   (   R/   R0   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1     s   R    R"   R+   s   Standard errors in parentheses.s   * p<.1, ** p<.05, ***p<.01N(%   R?   t   listR¼   RÇ   R¬   R   RT   R   R   t   get_level_valuest   tolistR-   t   uniqueR&   t   reindexRµ   t   SeriesR    R3   t   whereR¿   t   getR@   RA   RB   t   getattrR   R   R'   R4   t   Indext   fillnaR   Rg   R   R%   R>   (   RD   R!   t   model_namesR¸   R¾   t   regressor_ordert   drop_omittedR/   t   colst   colnamesRm   t   mergt   summt   varnamest   orderedt	   unorderedt   ordert   fR»   R$   t   nameRM   t   datt   smry(    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   summary_col¶  sZ    "(&	%,	#&$7+<	(		c         C   s.   y | |  } Wn t  |  ƒ } n X| j ƒ  S(   N(   R   t   strip(   t   elementR!   R_   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR2     s
    R   t   -i    c
      
      s˜  |  j  ƒ  }
 |
 j ‡  f d †  ƒ }
 | rU g  |
 j j ƒ  D] } t | ƒ ^ q: } n d  } | rš g  |
 j j ƒ  D]  } t | ƒ t |	 ƒ d ^ qq } nY g  |
 j d  d  … d f D]  } t | ƒ t |	 ƒ d ^ q´ |
 j d  d  … d f <d  } t	 t
 j |
 ƒ d | d | d t d t ƒ} | | j d d	 <| | j d
 d	 <| | j d
 d <| | j d
 d <| | j d
 d <d t | d ƒ | j d
 d <| S(   Nc            s   t  |  ˆ  ƒ S(   N(   R2   (   R/   (   R!   (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyR1   $  R,   RP   i    t   headerst   stubst   ltx_fmtt   txt_fmtt   latext   data_alignsR^   t   table_dec_abovet   table_dec_belowt   header_dec_belowi   t   colsep(   t   copyt   applymapR¬   RÓ   R   R   R   RU   R´   R
   R-   R(   R   R   t   output_formats(   R$   R"   R!   R    R   Rõ   Rö   R÷   RX   RY   Ré   R/   Rï   Rð   t   st(    (   R!   s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   _df_to_simpletable   s$    +9Sc         C   sî   g  } | r | d d n d } | d  k rB d g t |  ƒ } n  | d  k rd d g t |  ƒ } n  xƒ t |  ƒ D]u \ } } | | d } | | d }	 | | d }
 | j t | d |
 d | d |	 d | d | | d | | ƒƒ qq W| S(	   Ni    R!   s   %.4fR   R    R"   RX   RY   (   R   RT   t	   enumerateR#   Rý   (   R   R   RX   RY   R\   R!   Rm   t   vR   R    R"   (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyRR   9  s     
(    (    ((   t   statsmodels.compat.pythonR    R   R   R   R   R   R   R   R   RÃ   R	   Rw   Rb   RV   t   numpyR-   t   pandasR&   R)   R
   t   tableformattingR   R   t   objectR   RQ   RC   RI   R   Rg   R   RH   R¼   R¿   RÇ   Rë   R2   Rý   RR   (    (    (    s9   lib/python2.7/site-packages/statsmodels/iolib/summary2.pyt   <module>   s<   @Ö	

	1<		a		