# 2d KDE with one circular dimension

I have a 2d data set where one dimension is circular (direction and speed). I would like to create a kernel density estimate but am unsure how to create a kernel. One idea I had was to use a von mises distribution in one direction, a gaussian in the other and then take the outer product of the results to give a 2d kernel. Would this work or has anyone any other/better ideas?

• It might be possible to circumvent the circular dimension because you are dealing with direction and speed. Regardless of direction, a speed of zero gets you nowhere. You could take speed * cos(direction) and speed * sin(direction) and try a bivariate kernel on that data. Otherwise, you might look into cylindrical distributions, where your suggestion seems reasonable. Aug 23, 2016 at 12:29
• What’s wrong with something like kde2d in R’s MASS package? One axis gets you the speed; the other axis gets you the angle.
– Dave
Dec 31, 2019 at 20:13
• @Dave The problem with that is the artificial break it creates between angles near $2\pi$ and angles near $0.$ That break disappears upon converting from polar (direction+speed) to Cartesian coordinates, as suggested originally by Kees Mulder.
– whuber
Dec 31, 2019 at 21:10

Another approach mentioned in the comments may be easier. Since the data consist of heading $$\theta$$ and speed $$s$$, you can reparametrize to obtain the velocity $$(v_X, v_Y)$$ along the X and Y directions:
$$v_X = s \cos(\theta) \quad v_Y = s \sin(\theta)$$
The velocity $$(v_X, v_Y)$$ lives in the Cartesian plane, so you can estimate the density using an ordinary Gaussian KDE, without worrying about circular variables. If needed, you can use the change of variables formula to transform the KDE back to obtain a density estimate for heading and speed.