Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: nonparametric: kernel, efficient=True changes bw even if given #597

Closed
josef-pkt opened this issue Jan 4, 2013 · 5 comments

Comments

Projects
None yet
3 participants
@josef-pkt
Copy link
Member

commented Jan 4, 2013

example for KernelCensoredReg, but I think this is generic

using the following changes the bw from the one given

bw=[0.23, 434697.22],
defaults=nparam.EstimatorSettings(efficient=True)

without efficient=True the bandwidth stays the same as the one given

@rgommers

This comment has been minimized.

Copy link
Member

commented Jan 4, 2013

Were you planning to attach an example and/or diff here?

@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Jan 4, 2013

I think I used this example https://gist.github.com/4449108/4f224e41282da9d0edd8e1c56f38f211a2fc1fe4
with and without commenting the line with defaults in model first model in script.

@Padarn

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2014

I took a look into this. It seems like the function _compute_efficient in _kernel_base.py computes a plug-in type bandwidth whether or not there is a bandwidth specified. In fact, it uses the same rule regardless of what 'bw' is specified to be.

Can't quite tell what the code in _compute_efficient is trying to do, but the bug could easily be fixed by adding a flag telling it to return the user selected bandwidth if given.

@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Apr 22, 2014

I opened these issues as a user that was just pushing buttons without understanding the code.

based on a brief look while still not understanding the details:

I guess we have the same problem in KDEMultivariate
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/nonparametric/kernel_density.py#L115

If the user sets bw explicitly, as an array, then we shouldn't call any bandwidth calculation method at all. so we should never even get to _compute_efficient

Can you adjust a KDEMultivariate example or test case, and see if the same problem is there?
and we can covert it to a test case for those options.

@Padarn

This comment has been minimized.

Copy link
Contributor

commented Apr 23, 2014

Sure: https://gist.github.com/Padarn/11231981, this does indeed have the same problem.

I'm going to add a flag to stop _compute_efficient from doing this when a user bw is given, but I don't really like the way the bandwidth is handled anyway.. perhaps I'll submit an enhancement once bug week is over.

@josef-pkt josef-pkt closed this in 3adaa1a May 23, 2014

PierreBdR pushed a commit to PierreBdR/statsmodels that referenced this issue Sep 2, 2014

Merge pull request statsmodels#1629 from Padarn/bug597
BUG fix user-provided bandwidth bug closes statsmodels#597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.