kernels cosine differs from Stata #1245

josef-pkt opened this Issue Dec 17, 2013 · 3 comments


None yet

1 participant


Our definition of the sandbox.nonparametric.kernels.Cosine differes from Stata

Stata uses
1 + cos(2� pi z) for |z| < 1/2 and 0 otherwise

I don't know what the normalization and _L2Norm is

we use

CustomKernel.__init__(self, shape=lambda x: 0.78539816339744828 *
                np.cos(np.pi/2.0 * x), h=h, domain=[-1.0, 1.0], norm = 1.0)
        self._L2Norm = np.pi**2/16.0

has our Cosine kernel


I added Stata's version as Cosine2 kernel, unit tests for weighted kde pass against Stata's version in PR #1240


Stata also has a different epa kernel
and has parzen kernel, but no triweight kernel


has the same Cosine as Stata, now Cosine2 in sandbox kernels,
epa is the same (and the same as epan2 in Stata)
it also has parzen

@josef-pkt josef-pkt closed this in 1aa494f Dec 18, 2013
@PierreBdR PierreBdR pushed a commit to PierreBdR/statsmodels that referenced this issue Sep 2, 2014
@josef-pkt josef-pkt ENH: add Cosine2 kernel, same cosine kernel as Stata closes #1245 3b71505
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment