Making sense of OECD time use data
Using median polish and non-negative matrix factorization to uncover patterns in time use data
Large numerical tables—especially extensive cross-tabulations—are often challenging to interpret. When there are too many rows and columns, it becomes easy to lose the overall picture. This is a common frustration not just for data scientists or researcher, but for anyone working quantitatively. For example, consider the OECD’s time use data (see here). It has 33 countries and 25 activity categories. That’s merely 825 data points, but, suprisingly, it remains difficult to explore and draw insights from.
One easy solution is throw it in a heatmap:
The dark red shading immediately reveals that, no matter where you live, sleep occupies a large portion of our time. Paid work and routine housework also take up significant chunks. Yet, spotting which countries differ from the rest is surprisingly difficult just by looking at the heatmap or by inspecting the table.
One of my go-to methods for untangling this kind of complex data is to apply a round of median polish. Proposed by John Tukey, median polish is a robust exploratory technique that iteratively removes row and column effects by using medians instead of means, making it less sensitive to outliers. After the final iteration, the data can be summarized by additive components, which makes it easier to spot differences and interactions that aren’t obvious in the raw numbers.
If we denote the observed data as yᵢⱼ for row i and column j, median polish amounts to the following additive decomposition:
in which:
µ is the overall median (the overall effect)
αᵢ is the row effect for row i (in this case, the countries)
βⱼ is the column effect for column j (in our example that would be the activity categories)
𝜀ᵢⱼ is the residual for the cell i, j
In this case, we’re not focusing on the row effects (the countries) because the data represent the 24 hours × 60 minutes of a day. Yet, even here, the published totals don’t sum up to 1,440 minutes exactly — so there’s still a small discrepancy to account for. We’re not even concerned with the column effects (the activity categories), since we already know that sleeping is the dominant activity across all countries. What truly matters here are the residuals — they reveal which countries stand out in specific activity categories. Again, the raw numbers—all 825 of them—are hard to interpret, but a heatmap can help reveal patterns more clearly:
While still somewhat unwieldy, this heatmap quickly highlights standout values (the dark red squares). For example, we immediately see that participating in or attending events—though a relatively short daily activity—is particularly prominent in Ireland. Likewise, Norway scores high on other unpaid work, Turkey shows elevated values for religious/spiritual activities and civic obligations, and other paid work or study-related activities appear especially important in South Africa.
But we can do better than that. By applying non-negative matrix factorization (NMF), we can summarize the matrix of residuals in a more succinct and interpretable way. However, as the name suggests, NMF requires all values in the matrix to be non-negative — and residuals can be negative. To address this, we apply min-max scaling:
This ensures that all values are non-negative and that the maximum is bounded at 1.
We collect those in a matrix M:
In this matrix, the rows represent countries and the columns represent activity categories. We can then apply NMF to decompose the matrix into two smaller matrices whose product approximates the original.
NMF breaks down the data into a set of latent patterns (or "topics") across activities and shows how strongly each country is associated with each of them. In our case, it’s important to remember that we’re decomposing a matrix of residuals, which already express how much more (or less) time a country spends on certain activities compared to others. So, the latent patterns we uncover aren’t just general themes — they’re patterns of behavioral difference relative to the global norm.
The decomposition is:
where n is the number of countries, p the number of activity categories, and k the number of latent patterns we want to extract. Deciding on the optimal value of k involves additional considerations, which are beyond the scope of this blog post. In this case I opted for k=3.
Again, we can inspect the W and H matrices. Together, they contain 33×3+25×3=174 values — less than a fourth of the original 825 data points, but still too many to analyze one by one. So, once more, we turn to heatmaps for a clearer, more intuitive overview. This time we use the clustering option in the heatmap so that rows and columns are rearranged such that common patterns become more obvious1.
We first show matrix H, or more precisely, its transpose, since this layout is more page-friendly:
Then we give the heatmap for the matrix W:
Latent pattern 1, shown on the left side of the H heatmap, has darker (i.e., higher) values for time in school or classes, adult care, paid work (all jobs), travel to and from work/study, and job search. You could summarize this pattern as job, school and adult care related activities. Since we’re analyzing residuals, this indicates that countries associated with this pattern devote even more time to these activities than the global average. The other activities in this pattern show less distinct values, so we won’t interpret them further. The W heatmap reveals that this pattern is most typical for Japan, Korea, Mexico, China, Norway, Sweden and the UK.
Latent pattern 2, by contrast, is less oriented toward work and study. In fact, the 10 most important activity categories in this pattern are unrelated to either. Ranked by their highest values, they are: shopping, sports, travel related to household activities, TV or radio at home, care for household members, child care, Other leisure activities, sleeping, visiting or entertaining friends, and volunteering. You could label this pattern as: leisure, sleeping and care. Here are the 15 countries that are the most associated with that pattern: Ireland, Finland, Spain, Estonia, Germany, New Zealand, Norway, Sweden, Austria, Belgium, Australia, Luxembourg, USA, Denmark, and Poland. Notice again that this doesn’t mean that people work less or that work is less important in those countries, it simply means that, in terms of time use, relatively more time is spend on leisure, care and sleep than in the other countries. Notice also that Sweden and Norway score high, both on pattern 1 and pattern 2. Finally, we observe that South Africa, Japan, India, and Mexico are the least associated with the leisure, sleeping, and care pattern.
Finally, pattern 3 reflects a mix of domestic, caregiving, and personal development activities: research/homework, sleeping, routine housework, job search, care for non household members, visiting or entertaining friends, eating & drinking, TV or radio at home, religious / spiritual activities and civic obligations, child care, and care for household members. This pattern is most common in South Africa, India, Mexico, Turkey, Lithuania, Portugal, Greece, France, Hungary, Slovenia, Latvia, Netherlands, and Italy.
Let’s conclude with a summary of the findings. We identified evidence for three distinct latent activity patterns, each associated with greater time spent on certain types of activities. These three patterns are:
job, school and adult care related activities, mostly in East Asia, Northern Europe and Mexico
leisure, sleeping and care in the USA, New Zealand, Northern Europe, Poland and Germany
domestic, caregiving, and personal development activities, dominant in South Africa, India, Mexico, Turkey and Southern Europe.
You could certainly uncover these patterns by carefully analyzing the raw data, but it would likely take considerably more time. On the other hand, the NMF approach also has a few pitfalls:
Determining the rank (i.e., the number of latent patterns) can be challenging.
NMF is not scale-invariant, meaning that finding a suitable transformation for your data can be difficult and may appear arbitrary.
NMF can be sensitive to starting values. While there are methods to mitigate this, it can still be hard to distinguish meaningful signal from noise.
Nonetheless, the next time you’re confronted with a large cross-tabulation, consider using median polish and/or non-negative matrix factorization as tools to uncover patterns in your data.
The dendrograms on the top and left of the chart can be disregarded—I haven’t found a way to hide them yet.