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

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

Projects

None yet

3 participants

@josef-pkt
Member

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
Member
rgommers commented Jan 4, 2013

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

@josef-pkt
Member

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
Contributor
Padarn 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
Member

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
Contributor
Padarn 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment