When to Dig - xMRs and Saving Your Sanity

statistics
r
Author

Mark Jurries II

Published

February 6, 2025

In you’ve been in analytics for a while - or even worked with regular reports - you’ve been asked why a certain number moved by x percent last month. So you sit down and you look, and while nothing really jumps out, you also know that management wants something, so you find some subset of the data that looks mildly interesting and scrape together a soundbite after several days of digging.

We can help head this off by displaying what our data looks like over time. In this case, we’ll pretend that I kept track of how many minutes per day it takes me to get to the gym. I don’t actually record this because, well, why would I*, but for an example it will do. I’ve been told that there was a 10% increase in travel time on January 31. What does that look like?

*I mean, I like data and all, but come on.
Show the code
library(ggQC)
library(hrbrthemes)
library(tidyverse)

theme_set(theme_ipsum())

travel <- read_csv('travel.csv')

travel %>%
  ggplot(aes(x = date, y = duration))+
  geom_line()+
  geom_point()

We can get a pretty good feel just looking at this that Jan. 31 was relatively normal. It’s right about the center of the chart, and it also becomes clear that January 30 was a shorter drive than normal. But we’re still eyeballing averages, let’s show those as well as some upper and lower limits.

Show the code
travel %>%
  ggplot(aes(x = date, y = duration))+
  geom_line()+
  geom_point()+
  stat_QC(method="XmR", auto.label = T, label.digits = 2)

Ah, this is better. We can see that the average drive takes about 12 minutes. I simulated the data with an average of 12, so this is expected. The upper bound is 13.5 minutes, since my standard deviation was .5 minutes, this is 13.5 - 12 = 1.5 / .5 = 3 standard deviations, which is what we’d expect. The lower bound is also 3 standard deviations away.

What this means is that I can expected a typical drive to be anywhere from 10.5 to 13.5 minutes, though most days it will be between 11 and 13. It also means that my ride on the 31st was within normal range, and since it was normal, it’d be a waste of time to try to find why it was up, either from the day before of from the average.

Suppose on February 1, my ride took 16 minutes. What would that do to the chart?

Show the code
travel %>%
  add_row(date = as.Date('2025-02-01'), duration = 16) %>%
  ggplot(aes(x = date, y = duration))+
  geom_line()+
  geom_point()+
  stat_QC(method="XmR", auto.label = T, label.digits = 2)

Firstly, notice our limits and average barely moved. But here, we can also see that this drive was well above what I’d typically expect. There may have been heavy snow that day, or perhaps a traffic light was out*. Either way, there was something driving that behavior.

*Perhaps I stayed closed to the speed limit than usual. This is all made up anyway, so that’s possible.

This also helps me set realistic goals. If I decided I wanted my commute time to be under five minutes, I’d have to find a new mode of transportation, find a gym closer to my house, or find a house closer to my gym. 11 minutes is more doable, though the laws of physics suggest it may still prove difficult.

If there are significant changes in your underlying process, you can re-calculate your average at the change point. For instance, if I started taking a helicopter instead of my car, I’d start a new average line on that date as well as upper/lower limits to reflect that. Hopefully, I’d hit my goal of under five minutes per day, mostly because I’d need that seven minutes of time saved to go towards paying down the helicopter.

While my morning commute is a trivial example, xMRs are used quite often in successful companies. Amazon, for instance, uses them to measure hundreds of metrics in their weekly business reviews (read Cedric Chin’s article, which delves much deeper into xMRs and why you should use them). Donald Wheeler has some helpful articles on the subject as well. While much of the literature on xMR comes from the world of Six Sigma and process management, it has direct application to KPI measurement as well and should be in any analyst’s toolbelt.