Difference between circular variables
circdiff theta phi [if exp] [in range] [, generate(newvar) absolute ]
circdiff calculates the circular difference between two arguments theta and phi, and puts it in a new variable newvar. The difference is the shorter of the two rotations taking phi to theta, increasing azimuth or clockwise being positive.
Either or both arguments may be circular variables between 0 and 360 degrees or numeric constants.
Batschelet (1981, p.242) uses the notation |theta, phi| for the absolute value of this difference and points out that it is also arccos(cos(theta - phi)). Another scale on which to measure difference is thus 1 - cos(theta - phi). Yet another is chord length 2 * sin((theta - phi) / 2). The latter two scales both yield results which are 0 when theta = phi and 2 when theta and phi are 180 degrees apart, but results coincide only at those two endpoints.
generate() specifies the name of the new variable and is not optional.
absolute specifies that newvar should contain absolute values. By default newvar is signed.
. circdiff axisasp wallasp, gen(diffasp)
. circdiff axisasp 48.25
Nicholas J. Cox, University of Durham, U.K. email@example.com
Batschelet, E. 1981. Circular statistics in biology. London: Academic Press.
On-line: help for circcentre