Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

Context:

I have a group of websites where I record the number of visits on a daily basis:

W0 = { 30, 34, 28, 30, 16, 13, 8, 4, 0, 5, 2, 2, 1, 2, .. } 
W1 = { 1, 3, 21, 12, 10, 20, 15, 43, 22, 25, .. }
W2 = { 0, 0, 4, 2, 2, 5, 3, 30, 50, 30, 30, 25, 40, .. } 
...
Wn 

General Question:

  • How do I determine which sites are the most active?

By this I mean receiving more visits or having a sudden increase in visits during the last few days. For illustration purposes, in the small example above W0 would be initially popular but is starting to show abandoning, W1 is showing a steady popularity (with some isolated peak), and W3 an important raise after a quiet start).

Initial thoughts:

I found this thread on SO where a simple formula is described:

// pageviews for most recent day
y2 = pageviews[-1]
// pageviews for previous day
y1 = pageviews[-2]
// Simple baseline trend algorithm
slope = y2 - y1
trend = slope * log(1.0 +int(total_pageviews))
error = 1.0/sqrt(int(total_pageviews))
return trend, error

This looks good and easy enough, but I'm having a problem with it.

The calculation is based on slopes. This is fine and is one of the features I'm interested in, but IMHO it has problems for non-monotonic series. Imagine that during some days we have a constant number of visits (so the slope = 0), then the above trend would be zero.

Questions:

  • How do I handle both cases (monotonic increase/decrease) and large number of hits?
  • Should I use separate formulas?
share|improve this question
1  
I'm surprised you have not received any answers yet (although it is an obviously popular question). Since each of your four bullets are worth a question in and of themselves, how about limiting this question to one of them and post the others in separate questions. They are all really excellent questions that take distinct approaches, and all four are worthwhile on their own. – Andy W Oct 26 '10 at 0:11
Hi Andy, thanks a lot for your answer. I'll try to rephrase it and focus on a single issue at a time. My initial thought was making it as broad as possible (and avoid repeating the same question afterwards) but given the lack of answers, it seems it is too general for someone to answer. – Dan Oct 26 '10 at 12:56
I edited the question to expose the two main issues I'm mostly interested in. I chose to put them in the same question given their tight relationship. – Dan Oct 26 '10 at 15:03
1  
I'm still failing to understand why having one estimate with a small error makes an approach 'unusable'. – onestop Oct 27 '10 at 20:43
Thanks for the comment. I'm not saying the aproach (trend calculation) was unusable, but its error calculation could have a potential problem. Given that I got no answer so far, I'll remove that item from the question hoping it gets easier to answer. – Dan Oct 28 '10 at 10:05

3 Answers

It sounds like you are looking for an "online changepoint detection method." (That's a useful phrase for Googling.) Some useful recent (and accessible) papers are Adams & MacKay (a Bayesian approach) and Keogh et al. You might be able to press the surveillance package for R into service. Isolated large numbers of hits can be found using statistical process control methods.

share|improve this answer

There are definitely more and less complex ways to address this kind of problem. From the sound of things, you started out with a fairly simple solution (the formula you found on SO). With that kind of simplicity in mind, I thought I would revisit a few key points you make in (the current version of) your post.

So far, you've said you want your measurement of "site activity" to capture:

  • Slope changes in visits/day over "the past few days"
  • Magnitude changes in visits/day over "the past few days"

As @jan-galkowski points out, you also seem to be (at least tacitly) interested in the rank of the sites relative to each other along these dimensions.

If that description is accurate, I would propose exploring the simplest possible solution that incorporates those three measures (change, magnitude, rank) as separate components. For example, you could grab:

  • The results of your SO solution to capture slope variation (although I would incorporate 3 or 4 days of data)
  • Magnitude of each site's most recent visits/day value (y2) divided by the mean visits/day for that site (Y):

y2 / mean(Y)

For W0, W1, and W2 respectively, that yields 0.16, 1.45, and 2.35. (For the sake of interpretation, consider that a site whose most recent visits-per-day value was equal to it's mean visits-per-day would generate a result of 1). Note that you could also adjust this measure to capture the most recent 2 (or more) days:

y2 + y1 / 2 * mean(Y)

That yields: 0.12, 1.33, 1.91 for your three sample sites.

If you do, in fact, use the mean of each site's visit/day distribution for this kind of measure, I would also look at the distribution's standard deviation to get a sense of its relative volatility. The standard deviation for each site's visit/day distribution is: 12.69, 12.12, and 17.62. Thinking about the y2/mean(Y) measure relative to the standard deviation is helpful because it allows you to keep the recent magnitude of activity on site W2 in perspective (bigger standard deviation = less stable/consistent overall).

Finally, if you're interested in ranks, you can extend these approaches in that direction too. For example, I would think that knowing a site's rank in terms of the most recent visits per day values as well as the rank of each site's mean visits per day (the rank of mean (Y) for each W in Wn) could be useful. Again, you can tailor to suit your needs.

You could present the results of all these calculations as a table, or create a regularly-updated visualization to track them on a daily basis.

share|improve this answer

Caution that arrival rates of users at Web sites are nasty series, tend to be overdispersed (from a Poisson standpoint), so consider negative binominal distributions to look at arrivals, and their fitting. Also, you may want to examine the order statistics of the sites on each day rather than their numbers.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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