You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But the fit function after the reg throws the following IndexError message:
Traceback (most recent call last):
File "", line 1, in
kr_pts = kr.fit(index_a)
File "/anaconda3/lib/python3.6/site-packages/statsmodels/nonparametric/kernel_regression.py", line 370, in fit
data_predict=data_predict[i, :])
File "/anaconda3/lib/python3.6/site-packages/statsmodels/nonparametric/kernel_regression.py", line 154, in _est_loc_linear
tosum=False) / float(nobs)
File "/anaconda3/lib/python3.6/site-packages/statsmodels/nonparametric/_kernel_base.py", line 513, in gpke
dens = Kval.prod(axis=1) / np.prod(bw[iscontinuous])
IndexError: boolean index did not match indexed array along dimension 0; dimension is 2 but corresponding boolean dimension is 1
The function was working OK previously. For some reason, it is no longer working.
Thanks so much for the reply.
Below is the version of statsmodels and numpy
print(statsmodels.__version__)0.9.0
print(numpy.version.version)1.14.3
On Friday, August 10, 2018, 1:03:33 PM EDT, Josef Perktold <[email protected]> wrote:
This sounds like a numpy incompatibility.
Which version of numpy and of statsmodels are you using?
Most likely it is fixed in 0.9.0 or in master.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
I don't have time to check this right now, but it needs to be checked before the next release.
KernelReg unit test coverage is not as good as it is supposed to be. So I wouldn't rely on seeing a test failure if this is not yet fixed
Sorry. Just found that the version of package tested was 0.9.0. Kernel regression is now working for version 0.10.0. The weight bw now required to be fully specified. See example below.
Activity
josef-pkt commentedon Aug 10, 2018
This sounds like a numpy incompatibility.
Which version of numpy and of statsmodels are you using?
Most likely it is fixed in 0.9.0 or in master.
visitor54 commentedon Aug 11, 2018
josef-pkt commentedon Aug 11, 2018
temporarily prio-high
I don't have time to check this right now, but it needs to be checked before the next release.
KernelReg unit test coverage is not as good as it is supposed to be. So I wouldn't rely on seeing a test failure if this is not yet fixed
AmazingAbhi commentedon May 27, 2019
Hi, I am facing the same issue. Could you please tell me how this can be fixed. I have statsmodels 0.9.0 and numpy 1.15.4.
visitor54 commentedon Jul 4, 2019
The bug is still not fixed in 0.10
visitor54 commentedon Jul 4, 2019
Need some work around or other pakcages
kshedden commentedon Jul 5, 2019
Please provide a reproducible example. The code fragments above contain undefined variables.
visitor54 commentedon Jul 6, 2019
Sorry. Just found that the version of package tested was 0.9.0. Kernel regression is now working for version 0.10.0. The weight bw now required to be fully specified. See example below.
bw_1=np.full((1, 5), .5)
bw_1
index1=[1, 1.2, 3.2, 4, 5.1]
values=[23, 17, 12, 27, 8]
#values=list(map(f,index1))
print(values)
kr = KernelReg(values, index1, var_type='c', bw=bw_1)
print(values)
print(index1)
print([index1])
kr_pts = kr.fit([index1])
type(index1)
fig, ax = plt.subplots()
#plot sine wave
ax.plot(index1, kr_pts[0], label = "K Estimate")
kr_pts[0]
ax.plot(index1, values, label = "Y")
ax.set(xlabel='X', ylabel='Y',
title='Kernel reg')
#ax.grid()
#show the legend
plt.legend()
plt.show()