I have dataset such as:

Person  Code  Value       
1         A     5      
1         B     6     
1         C     7     
2         A     10    
2         B     11    
2         C     12     
3         A     10    
4         B     8     

The way to interpret the data is that person 1 performed code A for 5 times and code B for 6 times. I am interested to find the ratio of code A/code B. There are missing codes for certain people, such as person 4 does not have code A. For missing values, I replace with 0, since person 4 does not perform code A. I calculate the ratio A/B for everyone such that:

Person  RatioAB        
1         5/6
2         10/11
3         Inf
4         0

My goal is to find the average ratio A/B for all 4 people.

What is the correct way to do this in statistical study?

  1. Should I only consider person 1,2 and 4 and their mean ratio which is 0.58?
  2. Should I first remove any person without both A and B (person 3 and person 4), and only calculate the average ratio based on person 1 and 2?
  3. Average of A/Average of B

My actual dataset consists of millions of people.

  • 1
    $\begingroup$ Unless you have extra information, why would you assume that a missing entry should be set to $0$? $\endgroup$ – lulu Dec 18 '19 at 19:42
  • 1
    $\begingroup$ But that, seemingly arbitrary, choice badly skews your ratio. I don't know what the data means, of course, nor how you intend to use whatever calculation you do, but my instinct would be to exclude any entry for which you don't have both $A$ and $B$. Even then, if you have a single person with a non-zero $A$ and $B=0$ then the average of ratios will be infinite. Is that an acceptable outcome? $\endgroup$ – lulu Dec 18 '19 at 19:47
  • 1
    $\begingroup$ Well, it's your data, As I say, though, if one person out of "millions" has $A\neq 0 $, $B=0$ then the average ratio is infinite. That doesn't seem like a very good "average" to me. $\endgroup$ – lulu Dec 18 '19 at 19:50
  • 1
    $\begingroup$ People have pointed out the problem with infinities. Another problem is that if you compute the average of the A/B ratios and the average of the B/A ratios, you won't have the useful nice that average A/B = 1/(average B/A). If you instead compute the median of the ratios, it will solve both these problems. $\endgroup$ – Rahul Dec 18 '19 at 19:55
  • 1
    $\begingroup$ As people have already stated in the comments, it depends on what you are trying to find. It might be useful to just look at the total A and the total B across all people. It might be useful to just consider the mode (the most common value of A/B). $\endgroup$ – Moko19 Dec 18 '19 at 21:13

Your Answer

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

Browse other questions tagged or ask your own question.