Plot model coefficients with confidence intervals.
Parameters
Name
Type
Description
Default
models
A supported model object (Feols, Fepois, Feiv, FixestMulti) or a list of
Feols, Fepois & Feiv models.
required
figsize
tuple or None
The size of the figure. If None, the default size is used.
None
alpha
float
The significance level for the confidence intervals.
0.05
yintercept
float or None
The value at which to draw a horizontal line on the plot. Default is 0.
0
xintercept
float or None
The value at which to draw a vertical line on the plot. Default is None.
None
rotate_xticks
float
The angle in degrees to rotate the xticks labels. Default is 0 (no rotation).
0
title
str
The title of the plot.
None
coord_flip
bool
Whether to flip the coordinates of the plot. Default is True.
True
keep
Optional[Union[list, str]]
The pattern for retaining coefficient names. You can pass a string (one pattern) or a list (multiple patterns). Default is keeping all coefficients. You should use regular expressions to select coefficients. “age”, # would keep all coefficients containing age r”^tr”, # would keep all coefficients starting with tr r”\d$“, # would keep all coefficients ending with number Output will be in the order of the patterns.
None
drop
Optional[Union[list, str]]
The pattern for excluding coefficient names. You can pass a string (one pattern) or a list (multiple patterns). Syntax is the same as for keep. Default is keeping all coefficients. Parameter keep and drop can be used simultaneously.
None
exact_match
bool
Whether to use exact match for keep and drop. Default is False. If True, the pattern will be matched exactly to the coefficient name instead of using regular expressions.
False
plot_backend
str
The plotting backend to use between “lets_plot” (default) and “matplotlib”.
'lets_plot'
labels
Optional[dict]
A dictionary to relabel the variables. The keys are the original variable names and the values the new names. The renaming is applied after the selection of the coefficients via keep and drop.
None
joint
Optional[Union[str, bool]]
Whether to plot simultaneous confidence bands for the coefficients. If True, simultaneous confidence bands are plotted. If False, “standard” confidence intervals are plotted. If “both”, both are plotted in one figure. Default is None, which returns the standard confidence intervals. Note that this option is not available for objects of type FixestMulti, i.e. multiple estimation.
None
seed
Optional[int]
The seed for the random number generator. Default is None. Only required / used when joint is True.
None
Returns
Name
Type
Description
object
A lets-plot figure.
Examples
import pyfixest as pffrom pyfixest.report.utils import rename_categoricalsdf = pf.get_data()fit1 = pf.feols("Y ~ X1", data = df)fit2 = pf.feols("Y ~ X1 + X2", data = df)fit3 = pf.feols("Y ~ X1 + X2 | f1", data = df)fit4 = pf.feols("Y ~ C(X1)", data = df)pf.coefplot([fit1, fit2, fit3])pf.coefplot([fit4], labels = rename_categoricals(fit1._coefnames))pf.coefplot([fit1], joint ="both")