fredplot

fredplot(
    model,
    x,
    type='kde',
    scale='uniform',
    jitter=False,
    lowess=False,
    frac=2 / 3,
    n=None,
    ax=None,
    **kwargs,
)

Create a Functional REsidual Density (FRED) plot.

This plot shows the density of the functional residuals against a continuous predictor variable, which is useful for identifying model misspecifications like missing non-linear terms.

Parameters

Name Type Description Default
model object A fitted model object from statsmodels. required
x np.ndarray or pd.Series The predictor variable to plot on the x-axis. required
type str The type of density plot to generate. One of {“kde”, “hex”}, by default “kde”. 'kde'
scale str The scale to use for the functional residuals. One of {“uniform”, “normal”}, by default “uniform”. 'uniform'
jitter bool If True, add a small amount of random noise to the predictor x. This is useful for visualizing categorical predictors. By default False. False
lowess bool If True, add a LOWESS smooth to the plot, by default False. False
frac float The fraction of data used when estimating each y-value of the LOWESS smooth, by default 2/3. 2 / 3
n int The number of observations to subsample, by default None (use all). None
ax matplotlib.axes.Axes An existing matplotlib Axes object to plot on. If None, a new figure and axes are created. None
**kwargs dict Additional keyword arguments passed to the seaborn plotting function (e.g., sns.kdeplot or ax.hexbin). {}

Returns

Name Type Description
matplotlib.axes.Axes The matplotlib Axes object containing the plot.