Skip to content

labels argument fails to rename with etable, iplot, coefplot for interactions #894

@s3alfisc

Description

@s3alfisc

With interacted variables, the labels argument fails for al three functions above as reported by mortizm1988 in #892.

Example:

%load_ext autoreload
%autoreload 2

import pyfixest as pf
from pyfixest.report.utils import rename_categoricals, rename_event_study_coefs
import numpy as np

df = pf.get_data()
fit1 = pf.feols("Y ~ i(f1, X1)", data = df)
fit2 = pf.feols("Y ~ i(f1, X1) + X2", data = df)

pf.etable(
    [fit1, fit2], 
    labels = {"C(f1)[0.0]:X1":"var 1"}, 
    type = "md"
)

# index                   est1        est2
# ----------------  ----------  ----------
# depvar                     Y           Y
# ----------------------------------------
# C(f1)[0.0] x X1   -1.032***   -1.000***
#                      (0.249)     (0.238)
# C(f1)[1.0] x X1      0.541*     0.576**
#                      (0.224)     (0.214)
# C(f1)[2.0] x X1   -1.767***   -1.834***

Works for non-interactions instead:

fit1 = pf.feols("Y ~ i(f1)", data = df)
fit2 = pf.feols("Y ~ i(f1) + X2", data = df)

pf.etable(
    [fit1, fit2], 
    labels = {"C(f1)[T.1.0]":"var 1"}, 
    type = "md"
)

# index                est1        est2
# -------------  ----------  ----------
# depvar                  Y           Y
# -------------------------------------
# var 1           2.544***    2.544***
#                   (0.431)     (0.414)
# C(f1)[T.2.0]   -1.635***   -1.631***
#                   (0.452)     (0.434)
# C(f1)[T.3.0]      -0.464      -0.305

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions