I have a dataset with page view data for about 500,000 users, divided into two groups. Each user can visit up to 5 pages, each as many or as few times as they want. So for each user, I have the distribution of number of visits to each page. I would like to compare the 'average skew' in distribution between the two groups. Roughly, users in one group are more likely to have distributions that look like this {3,0,0,0,0} and users in the other group are more likely to have distributions like this {1,1,0,1,0}. How can I compare the degree of skewness between the two groups? I thought of using the average Gini coefficient or entropy for each group, but each user has so few observations. How can I do this?

  • $\begingroup$ Not easily . . . The skewness coefficient is a pretty flaky statistic. I suggest avoiding it. Are you sure you wouldn't do just as well comparing their ranges, or number of different pages visited? And is it the same 5 pages for each? If not, what is the meaning of "(1,1,0,1,0)" versus "(1,1,1,0,0)"? $\endgroup$ – Russ Lenth Jul 27 '14 at 19:24
  • $\begingroup$ It is not the same 5 pages for each; there is no difference between (1,1,0,1,0) and (1,1,1,9,0). It's just the distribution of how many views they did for each of the 5 pages they were offered. Neither number of pages nor range is exactly what I want, since neither fully captures the difference between someone who looks at many pages once each and someone who looks at one page several times. Maybe I can report both? $\endgroup$ – bsg Jul 28 '14 at 6:07
  • 1
    $\begingroup$ What does "skewness" mean when we're looking at counts in nominal (i.e. unordered) categories? Do you mean something more like "concentration" into few categories rather than spread over many? I guess you could think of that as skewness in the values of the counts. $\endgroup$ – Glen_b Jul 29 '14 at 23:19
  • $\begingroup$ Yes, that's what I mean. $\endgroup$ – bsg Jul 30 '14 at 5:57

Seems like all you need is a reasonable score that quantifies how much disparity there is between site visits. Since you need to compute 500000 such scores, something simple seems best.

  1. Maybe your first thought is the best one - the Gini index.
  2. Here's another simple one: After ordering the counts $y_1<y_2<\ldots<y_5$, compute $$\frac{y_5-y_3+1}{y_3-y_1+1}$$ So for (3,0,0,0,0) the score is $\frac{3+1}{0+1}=4$, and for (1,1,1,0,0) it is $\frac{0+1}{1+1}=0.5$. The idea is that $y_5-y_3$ is the difference between the max and the median, and $y_3-y_1$ is the difference between the min and the median, so you're comparing the two halves of the distribution. $1$ is added to each so you never end up dividing by $0$. Like then Gini index, this is a function of the order statistics.
  3. Another simple measure of disparity is the SD of the logs. For nonzero data, $SD(\log ay)=SD(\log y)$ for any $a > 0$, so it is scale-invariant. It measures relative variation in the data. However, you'd have to add some constant before logging to avoid taking the log of $0$. In your examples, the SDs of $\log(y_i+1)$ are $0.62$ and $0.38$ respectively.

Note that options 2 and 3 are not scale-invariant, due to adding $1$ (or something) before dividing or logging, whereas the Gini index can be computed without any adjustment for the zeros, and is scale-invariant. So the choice might be based on that. Is (10,0,0,0,0) really the same as (3,0,0,0,0), in terms of your behavioral model? And is (4,4,4,0,0) the same as (1,1,1,0,0)?

| cite | improve this answer | |
  • $\begingroup$ Thank you so much for these excellent suggestions! With regard to the Gini index, is it reasonable to use with so few observations (5)? Will it be at all meaningful? $\endgroup$ – bsg Jul 28 '14 at 19:14
  • $\begingroup$ Well, I think so. You're not analyzing each one, you're just using it as a way to score the respondents. $\endgroup$ – Russ Lenth Jul 28 '14 at 19:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.