Skip to content

ENH: add more premade plot elements like add_lowess #6434

Open

Description

@josef-pkt

add_lowess is very convenient, just one line to add it to a new plot

e.g. smoothed endog for Logit as a function of predicted probabilities
(usecase calibration or reset plots #6430 or regression plot for models like Logit, GLM )

from statsmodels.graphics.regressionplots import add_lowess
plt.plot(fitted[sort_idx], endog[sort_idx], '|')
ax = plt.gca()
add_lowess(ax),

We also have adding a line in prob plots qqline which includes a regression line, but is written specifically for qq plots (includes also 45 degree line)

Other convenient ones would be fitted polynomials or splines for which we would have some confidence intervals.

Activity

  1. josef-pkt commented on Jan 18, 2020

    @josef-pkt
    MemberAuthor

    lowess smoothing of exog does not seem to observe boundaries, i.e. values can be outside support of data.
    using default setting for add_lowess as in previous comment, simulated random sample with nobs=5000

    logit_regplot

  2. josef-pkt commented on Feb 16, 2020

    @josef-pkt
    MemberAuthor

    seaborn uses lowess, but we don't have confint for it and bootstrap is slow.

    We could add some helper functions for the equivalent of lowess using splines for the plot usecase but with optional confint.
    This would be fast with fixed "bandwidth", i.e. df or number of knots, using OLS and a bit slower using RLM. GLMGam would be an option with data driven bandwidth selection, but slower.

    aside:
    predict should (optionally) use a grid of exog and not just the original data, There was an issue or stackoverflow question that regression plots are not smooth when there are few exog points in some areas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions