Skip to content

Commit 9622c41

Browse files
authored
Add customizable fixed effects markers (fe_present, fe_absent parameters) (#1065)
1 parent e8b9c35 commit 9622c41

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Examples of using custom fixed effects markers in pyfixest etable
2+
3+
import pyfixest as pf
4+
5+
# Load data
6+
df = pf.get_data()
7+
fit1 = pf.feols("Y~X1 + X2 | f1", df)
8+
fit2 = pf.feols("Y~X1 + X2 | f1 + f2", df)
9+
10+
# Default behavior (x and -)
11+
pf.etable([fit1, fit2])
12+
13+
# Use YES/NO
14+
pf.etable([fit1, fit2], fe_present="YES", fe_absent="NO")
15+
16+
# Use Y/N
17+
pf.etable([fit1, fit2], fe_present="Y", fe_absent="N")
18+
19+
# Use checkmark and cross
20+
pf.etable([fit1, fit2], fe_present="✓", fe_absent="✗")
21+
22+
# Use green check and cross emojis
23+
pf.etable([fit1, fit2], fe_present="✅", fe_absent="❌")
24+
25+
# Use checkmark with blank for absent
26+
pf.etable([fit1, fit2], fe_present="✓", fe_absent="")
27+
28+
# Custom text markers
29+
pf.etable([fit1, fit2], fe_present="Included", fe_absent="Excluded")

pyfixest/report/summarize.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def etable(
3636
show_fe: Optional[bool] = True,
3737
show_se_type: Optional[bool] = True,
3838
felabels: Optional[dict] = None,
39+
fe_present: str = "x",
40+
fe_absent: str = "-",
3941
notes: str = "",
4042
model_heads: Optional[list] = None,
4143
head_order: Optional[str] = "dh",
@@ -109,6 +111,12 @@ def etable(
109111
the FE lines with a different label than the one specied for the respective
110112
variable in the labels dictionary.
111113
The command is applied after the `keep` and `drop` commands.
114+
fe_present: str, optional
115+
Symbol to use when a fixed effect is present in a model. Default is "x".
116+
Common alternatives include "Y", "YES", "✓", "✅", or any custom string.
117+
fe_absent: str, optional
118+
Symbol to use when a fixed effect is absent from a model. Default is "-".
119+
Common alternatives include "N", "NO", "✗", "", or any custom string.
112120
digits: int
113121
The number of digits to round to.
114122
thousands_sep: bool, optional
@@ -327,9 +335,9 @@ def etable(
327335
and fixef in model._fixef.split("+")
328336
and not model._use_mundlak
329337
):
330-
fe_df.loc[i, fixef] = "x"
338+
fe_df.loc[i, fixef] = fe_present
331339
else:
332-
fe_df.loc[i, fixef] = "-"
340+
fe_df.loc[i, fixef] = fe_absent
333341
# Sort by model
334342
fe_df.sort_index(inplace=True)
335343
# Transpose

0 commit comments

Comments
 (0)