mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.23k stars 1.89k forks source link

regplot fails to pass "order = 2" to statsmodels #2506

Closed javvy closed 3 years ago

javvy commented 3 years ago

seaborn.regplot has option "order", described as "int, optional,. If order is greater than 1, use nuim[y.polyfit to estimate a polynomial regression".

seaborn.regplot also has option "lowess", described as "If True, used stasmodels to estimate a nonprametric lowess model..."

HOWEVER, if both "order = 2" and "lowess = True", seaborn reports error in seaborn line 105: "ValueError: Mutually exclusive regression options."

seaborn should pass the "order = 2" value to statsmodel lowess instead of returning an error message..

sns.regplot(data = sortedbyyear, x = 'YEAR2000', y = 'logeps', scatter = False, order = 2, <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< (causes error) fit_reg = True, logistic = False, robust = False, logx = False, lowess = True, truncate = False, label = 'Lowess', color = 'lime', marker = '^', ax = plotlogeps0, )

mwaskom commented 3 years ago

Indeed, order and lowess are mutually exclusive options.

In general, I would like to have a better separation between the regplot options that relate to the design (order, logx) and those that relate to the estimator (logit, robust).

But the statmodels lowess function does not have an order parameter, so I am not sure how I could implement the specific suggestion here.

javvy commented 3 years ago

You're right!!Sorry-- Do you know of a really good lowess smoother?

"You won't find the right answers if you don't ask the right questions!" (Robert Helmbold, 2013)

On Sunday, March 14, 2021, 10:44:58 AM MST, Michael Waskom ***@***.***> wrote:  

Indeed, order and lowess are mutually exclusive options.

In general, I would like to have a better separation between the regplot options that relate to the design (order, logx) and those that relate to the estimator (logit, robust).

But the statmodels lowess function does not have an order parameter, so I am not sure how I could implement the specific suggestion here.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

mwaskom commented 3 years ago

I don't know of other Python implementations of lowess. I guess the data science stackexchange would be a good place to ask that question. You'll probably want to be clear about the criteria that matter to you. statsmodels also has GAMs, so I guess you could try those.

I'm going to close as it's not possible to satisfy the narrow feature request here.

javvy commented 3 years ago

Agreed.Thanks "You won't find the right answers if you don't ask the right questions!" (Robert Helmbold, 2013)

On Sunday, March 14, 2021, 11:27:20 AM MST, Michael Waskom ***@***.***> wrote:  

I don't know of other Python implementations of lowess. I guess the data science stackexchange would be a good place to ask that question. You'll probably want to be clear about the criteria that matter to you. statsmodels also has GAMs, so I guess you could try those.

I'm going to close as it's not possible to satisfy the narrow feature request here.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.