Skip to content

Summary.as_latex() produces invalid LaTeX for variable names containing underscore #2862

Closed

Description

@khaeru

With statsmodels 0.6.1:

import numpy as np
import statsmodels.api as sm
import statsmodels.formula.api as smf

# Load data
dat = sm.datasets.get_rdataset("Guerry", "HistData").data

# Fit regression model (using the natural log of one of the regressors)
results = smf.ols('Lottery ~ Crime_prop + np.log(Pop1831)', data=dat).fit()

# Inspect the results
print(results.summary().as_latex())

The output contains the line:

\textbf{Crime_prop}      &       0.0029  &        0.001     &     3.887  &         0.000        &         0.001     0.004       \\

This is invalid LaTeX, because the underscore (_) is not set in math mode or escaped (\_).

Activity

  1. theaverageguy commented on Mar 22, 2016

    @theaverageguy

    How can I fix this?

  2. added this to the 0.8 milestone on Mar 29, 2016
  3. added a commit that references this issue on Jun 13, 2016
    e1c7703
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