I’ve attempted to translate a previously published algorithm into R code, but I’m not sure if I’ve got it right. I’d be very grateful for some feedback. I’ve posted the algorithm and my code here: http://stats.stackexchange.com/q/249525/7744

Thanks!

Ben