I'm looking for a simple way to store ratios.

For a time component, I must store the average ratio between two behavior. For example the number of people that turn left compared to the number of people that turn right.

I have to detect unusual behavior (people that turn right abnormally).

How should I mathematically compare the average ratio against the analyzed ratio, and how should I display the difference on a graph ?

Thanks a lot in advance.

  • $\begingroup$ Is this compositionnal data (i.e. do the lines sum to a constant)? en.wikipedia.org/wiki/Compositional_data $\endgroup$
    – user603
    Sep 20, 2010 at 17:01
  • $\begingroup$ A typical ratio would be 1042:42. 1042 turn left, 42 turn right. $\endgroup$
    – Pierre 303
    Sep 23, 2010 at 17:13

1 Answer 1


If these are exclusive behaviours - they must either turn left or right and can't go straight on, stop or anything else - then you have data that you might assume are binomially distributed: in the example you give there are then 1042 left turns (the 'ones') in 1084 'runs' which you are implicitly assuming to be independent observations.


You could either use a binomial distribution to test whether this is consistent with a particular true proportion of left turns, say 90%. In R, the test against 90% is

binom.test(1042, n=1084, p=.90)

and is rejected (and chisq.test agrees). You probably have covariates though and perhaps non-independent draws via clustering etc. For these, switch to a binomial logistic regression framework.


For this data you should probably plot the empirical logits: here log(1042/42) = 3.211228, or their posterior means (see below). Visually this quantity represents a proportional increase and decrease in the counts as an equally sized increment up or down. A symmetrical representation in proportional rather than absolute terms is usually what you want for this sort of data.

You can get a quite a well-behaved confidence interval for the empirical logit via a Bayesian argument: the posterior distribution, assuming an invariant 'Jeffreys' Prior of $\text{Beta}(0.5,0.5)$, of the empirical logit is Normal with mean $\mu = \log{(\text{left}/\text{right})}$ and standard deviation $\sigma_\mu = (\text{left} + 0.5)^{-1} + (\text{right} + 0.5)^{-1}$.

  • $\begingroup$ @CP I like your Bayesian approach. You also justify you name! $\endgroup$
    – suncoolsu
    Dec 22, 2010 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy