Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions pyfixest/report/fe_marker_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Examples of using custom fixed effects markers in pyfixest etable

import pyfixest as pf

# Load data
df = pf.get_data()
fit1 = pf.feols("Y~X1 + X2 | f1", df)
fit2 = pf.feols("Y~X1 + X2 | f1 + f2", df)

# Default behavior (x and -)
pf.etable([fit1, fit2])

# Use YES/NO
pf.etable([fit1, fit2], fe_present="YES", fe_absent="NO")

# Use Y/N
pf.etable([fit1, fit2], fe_present="Y", fe_absent="N")

# Use checkmark and cross
pf.etable([fit1, fit2], fe_present="✓", fe_absent="✗")

# Use green check and cross emojis
pf.etable([fit1, fit2], fe_present="✅", fe_absent="❌")

# Use checkmark with blank for absent
pf.etable([fit1, fit2], fe_present="✓", fe_absent="")

# Custom text markers
pf.etable([fit1, fit2], fe_present="Included", fe_absent="Excluded")
12 changes: 10 additions & 2 deletions pyfixest/report/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def etable(
show_fe: Optional[bool] = True,
show_se_type: Optional[bool] = True,
felabels: Optional[dict] = None,
fe_present: str = "x",
fe_absent: str = "-",
notes: str = "",
model_heads: Optional[list] = None,
head_order: Optional[str] = "dh",
Expand Down Expand Up @@ -109,6 +111,12 @@ def etable(
the FE lines with a different label than the one specied for the respective
variable in the labels dictionary.
The command is applied after the `keep` and `drop` commands.
fe_present: str, optional
Symbol to use when a fixed effect is present in a model. Default is "x".
Common alternatives include "Y", "YES", "✓", "✅", or any custom string.
fe_absent: str, optional
Symbol to use when a fixed effect is absent from a model. Default is "-".
Common alternatives include "N", "NO", "✗", "", or any custom string.
digits: int
The number of digits to round to.
thousands_sep: bool, optional
Expand Down Expand Up @@ -327,9 +335,9 @@ def etable(
and fixef in model._fixef.split("+")
and not model._use_mundlak
):
fe_df.loc[i, fixef] = "x"
fe_df.loc[i, fixef] = fe_present
else:
fe_df.loc[i, fixef] = "-"
fe_df.loc[i, fixef] = fe_absent
# Sort by model
fe_df.sort_index(inplace=True)
# Transpose
Expand Down