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?
-
3$\begingroup$ 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. $\endgroup$– Kees MulderCommented Aug 23, 2016 at 12:29
-
$\begingroup$ 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. $\endgroup$– DaveCommented Dec 31, 2019 at 20:13
-
2$\begingroup$ @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. $\endgroup$– whuber ♦Commented Dec 31, 2019 at 21:10
1 Answer
Yes, the proposed approach makes sense. The data live on a cylinder, and the kernel you described is a local bump on the cylinder. This is analogous to how kernels for noncircular 2d data are local bumps on a plane.
Your kernel will have two bandwidth parameters that control the width separately along each dimension. This means the 'principal axes' of the kernel will always be aligned with the axes of the input space. For example, the kernel may be elongated along the circular direction, or along the length of the cylinder, but cannot be elongated diagonally along the cylinder surface. If this kind of diagonal elongation is needed, the kernel could be modified to include a correlation between the two variables. This may or may not be desirable, depending on how the data are distributed, and how many points are available.
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.