weitzner weitzner - 5 months ago 58
R Question

Fit a mixture of von Mises distributions in R

I have a set of angular data that I'd like to fit a mixture of two von Mises distributions to. As shown below, the data are clustered at about 0 and ±π, so having a periodic boundary is required for this case. Distribution of data

I have tried using the movMF package to fit a distribution to these data but it seems that it is normalizing each row, and since this is a set of 1D data, the result is a vector of ±1. How are others fitting a mixture of distributions like this in R?


The problem lies with using a vector of angles as the input to the movMF function. Instead, the angles must be converted to points on the unit circle

pts_on_unit_circle <- cbind(cos(angle_in_degrees * pi / 180), 
                            sin(angle_in_degrees * pi / 180))
d <- movMF(pts_on_unit_circle, number_of_mixed_vM_fxns)
mu <- atan2(d$theta[,2], d$theta[,1])
kappa <- sqrt(rowSums(d$theta^2))

Source: Contacted Kurt Hornik, the author of the movMF package.