Skip to content

summary.as_latex() output missing 1 row #7747

Closed

Description

@BecksIsAlreadyTaken

Describe the bug

i compared the console output summary() and summary.as_latex(), found that the last row of result table gone missing.

Code Sample, a copy-pastable example if possible

print(logit.summary().as_latex())
print(logit.summary())
Details

Note: As you can see, there are many issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates.

Note: Please be sure you are using the latest released version of statsmodels, or a recent build of main. If your problem has been fixed in an unreleased version, you might be able to use main until a new release occurs.

Note: If you are using a released version, have you verified that the bug exists in the main branch of this repository? It helps the limited resources if we know problems exist in the current main branch so that they do not need to check whether the code sample produces a bug in the next release.

summary() output

summary().as_latex() output

Here the row containing "Covariance Type:" and "LLR p-value" went missing.

If the issue has not been resolved, please file it in the issue tracker.

Expected Output

A full result table.

Output of import statsmodels.api as sm; sm.show_versions()

Details

[paste the output of import statsmodels.api as sm; sm.show_versions() here below this line]
INSTALLED VERSIONS

Python: 3.9.0.final.0
OS: Linux 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

statsmodels

Installed: 0.12.2 (/home/beck/anaconda3/envs/main/lib/python3.9/site-packages/statsmodels)

Required Dependencies

cython: Not installed
numpy: 1.21.2 (/home/beck/anaconda3/envs/main/lib/python3.9/site-packages/numpy)
scipy: 1.7.1 (/home/beck/anaconda3/envs/main/lib/python3.9/site-packages/scipy)
pandas: 1.3.3 (/home/beck/anaconda3/envs/main/lib/python3.9/site-packages/pandas)
dateutil: 2.8.2 (/home/beck/anaconda3/envs/main/lib/python3.9/site-packages/dateutil)
patsy: 0.5.1 (/home/beck/anaconda3/envs/main/lib/python3.9/site-packages/patsy)

Optional Dependencies

matplotlib: 3.4.3 (/home/beck/anaconda3/envs/main/lib/python3.9/site-packages/matplotlib)
backend: TkAgg
cvxopt: Not installed
joblib: 1.0.1 (/home/beck/anaconda3/envs/main/lib/python3.9/site-packages/joblib)

Developer Tools

IPython: Not installed
jinja2: Not installed
sphinx: Not installed
pygments: Not installed
pytest: Not installed
virtualenv: Not installed

Activity

  1. josef-pkt commented on Sep 23, 2021

    @josef-pkt
    Member

    I don't see it.
    Both pictures show the same 6 parameter rows
    last line of top table is missing.

    It's better to post the text version than a screen shot.

  2. BecksIsAlreadyTaken commented on Sep 23, 2021

    @BecksIsAlreadyTaken
    Author

    image

    missing the "Covariance Type:" and "LLR p-value"

  3. BecksIsAlreadyTaken commented on Sep 23, 2021

    @BecksIsAlreadyTaken
    Author

    \begin{center}
    \begin{tabular}{lclc}
    \toprule
    \textbf{Dep. Variable:} & DEFAULT & \textbf{ No. Observations: } & 9990 \
    \textbf{Model:} & Logit & \textbf{ Df Residuals: } & 9984 \
    \textbf{Method:} & MLE & \textbf{ Df Model: } & 5 \
    \textbf{Date:} & Fri, 24 Sep 2021 & \textbf{ Pseudo R-squ.: } & 0.04225 \
    \textbf{Time:} & 00:06:07 & \textbf{ Log-Likelihood: } & -4068.5 \
    \textbf{converged:} & True & \textbf{ LL-Null: } & -4247.9 \
    \bottomrule
    \end{tabular}
    \begin{tabular}{lcccccc}
    & \textbf{coef} & \textbf{std err} & \textbf{z} & \textbf{P$> |$z$|$} & \textbf{[0.025} & \textbf{0.975]} \
    \midrule
    \textbf{HOUSE} & 0.1795 & 0.066 & 2.729 & 0.006 & 0.051 & 0.308 \
    \textbf{CAR} & -0.6911 & 0.070 & -9.815 & 0.000 & -0.829 & -0.553 \
    \textbf{HOUSE_L} & -0.3912 & 0.085 & -4.623 & 0.000 & -0.557 & -0.225 \
    \textbf{CAR_L} & 0.2089 & 0.124 & 1.684 & 0.092 & -0.034 & 0.452 \
    \textbf{EDUCATION} & -0.6296 & 0.029 & -21.623 & 0.000 & -0.687 & -0.573 \
    \textbf{WORKTIME} & -0.0800 & 0.022 & -3.607 & 0.000 & -0.124 & -0.037 \
    \bottomrule
    \end{tabular}
    %\caption{Logit Regression Results}
    \end{center}

  4. josef-pkt commented on Sep 23, 2021

    @josef-pkt
    Member

    BUG,
    I can replicate it using one of our unit test examples.

    converting only the top table works correctly and includes the last line with LLR p-value:

    summ = t.res1.summary()
    print(summ.tables[0].as_latex_tabular())
    

    Looks like there is a bug in merging the latex tables

    same problem with Probit. and same problem in OLS

  5. added this to the 0.13 milestone on Sep 23, 2021
  6. josef-pkt commented on Sep 23, 2021

    @josef-pkt
    Member

    summary for latex has a del table[-1]
    I guess this was supposed to remove a ====== line

        # join table parts then print
        if return_fmt == 'text':
           ....
        elif return_fmt == 'latex':
            # TODO: insert \hline after updating SimpleTable
            table = copy.deepcopy(tables[0])
            del table[-1]
            for part in tables[1:]:
                table.extend(part)
            return table.as_latex_tabular()
    
  7. josef-pkt commented on Sep 23, 2021

    @josef-pkt
    Member

    After a while of digging
    a possible candidate is
    https://github.com/statsmodels/statsmodels/pull/5814/files#diff-157f412d854ff1baeac4f504cb16fb5c7caf50c3f1762d6658c362cd4468d8ec

    replaces "=" by ":" in defining dict, but replaced "=" also from content, dec_below.
    reformatting doesn't give a useful diff

    But it looks like those mistakes are not in the fmt that are used
    ???

    the del table[-1] is 10 years old from original code, so something else must have changed.

    Problem is that summary has almost only smoke tests.

    removing del table[-1] fixes the problem. But I have no guess how long this bug already occurred.

  8. josef-pkt commented on Sep 23, 2021

    @josef-pkt
    Member

    @BecksIsAlreadyTaken Thanks a lot for reporting, problems in summary and plots are difficult to catch besides visual inspection.

    I will have a PR later today, removing the del, and with unit tests for the number of lines in the latex return, that passes for the test_discrete cases.

  9. josef-pkt commented on Sep 23, 2021

    @josef-pkt
    Member

    I guess this is old,
    There is a unit test for as_latex in regression/test_regression that compares the full latex summary text, added 9 years ago.
    cov_type was added to summary 8 years ago, but that unit test never failed.

    The unit test fails now after fixing this.

    This might even have been wrong since the beginning, initial refactorings.
    #1214 needed to add a line to the latex text in the unit test.

  10. added a commit that references this issue on Sep 23, 2021
    d9e1f5e
  11. josef-pkt commented on Sep 23, 2021

    @josef-pkt
    Member

    I merged the bug fix. It will be in upcoming 0.13 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions