How the Olympics explains multidimensional data
How the Olympics explains multidimensional data - Swirrl is now TPXimpact
How the fortunes of different countries can explain multidimensional dataWhether you’re celebrating Fiji’s first gold, Michael Phelps’ 23rd or a cracking cycling GB result, relatable statistics bring data to life. Here we share a tutorial-style post on multidimensional data using statistics from previous Olympic Games (written and illustrated by our designer, Guy, originally as part of the help documentation for our PublishMyData product).Statistical data is facts as figures and a dataset is a collection of related data. Statistical data is often published in the form of a multidimensional dataset and, whilst this may be unfamiliar jargon, it’s a familiar and very useful idea.After reading this tutorial, you’ll:Understand the idea of multidimensional dataUnderstand the technical terminology of multidimensional dataBe able to find the precise data you need inside a multidimensional datasetBe ready to use PublishMyData to explore multidimensional data in detail, for example on Scotland’s statistics.gov.scot, or DCLG’s OpenDataCommunities.Tabular dataAs an example, consider these Olympic medal results, shown in familiar tabular form.The rows and columns format is familiar from the spreadsheets we use every day, but this is in fact, multidimensional data.These data have two dimensions, country and medal colour. The country dimension is shown as rows, and the medal colour dimension as columns.It’s often convenient to use a geographic dimension, such as country: we call these the Reference Area dimension of the dataset.By convention in PublishMyData we usually show the Reference Area as rows. See, for example, this table of ranks of Scottish deprivation in 2012).So we’re already very comfortable with working with two-dimensional data, but these data show medal results for the 2012 Olympics, so we can think of the data as including a third dimension, the year of the results. We call a time-based dimension the Reference Period.Here, Reference Period, the year dimension has the same value for all the data in our table, so we describe this dimension as locked to a value (in this case, 2012). By contrast, the country and medal dimensions can take different values. We call these free dimensions.To obtain a value we lock one dimension at a time — by choosing what value it takes — until all the dimensions are locked. Here, we choose:year = 2012country = USAmedal = goldWhere our locked dimension values intersect, we have located the observation we’re interested in.We call the number in the cell the measure. The measure has a value (46) and a unit (medals won). This measure is, intuitively, a count — i.e. how many of something were there?. It’s also very common to encounter ratios, expressed as a percentage or as somethings per something.Two dimensions, plus oneLet’s imagine that we obtain two more spreadsheets of medal data, covering 2008 and 2004.Note that our observation from before — because it locked values for all of its dimensions — remains valid, but we’ve added a bunch of new observations.Now, suppose we are interested in how the number of gold medals won by each team has changed over time. Our data set contains all this data, but it’s not very convenient to extract it (even in a small toy data set like this).Ugh. Wouldn’t it be more convenient to have a table which locked the medal dimension to ‘gold’ and then showed us how that changed over time?This is more like it, but if all you have is spreadsheets, you’ll need some Excel skills, and maybe a little bit of trial and error to get here. There’s a better way to do it.Data CubesFirst of all, let’s make our illustrations a bit clearer by getting rid of the numbers, and just using colour to show what’s in each cell. This is just for the illustration though — bear in mind that the measures are all still there!And finally, let’s adjust how we draw it a little bit. Imagine stacking the spreadsheets front to back. Notice that the data isn’t changing, just we’re adding a third dimension to the illustration.Here we have a data cube. The one illustrated is a cube, but in practice, the dimensions don’t need to be — and indeed most likely won’t be the same size. For instance, we’ve only shown three countries, but the example could include a hundred more rows.The important change here is that the data are no longer tied to a two dimensional representation, they fill space.Let’s look more closely at what we have here.Our three original spreadsheets, showing the free dimensions Reference Area and Medal and the locked dimension, Years are still here……but we now realise that they are slices through the cube, and that there are other ways of slicing the cube…Each of these slices is a potential two dimensional spreadsheet.Sliced one direction (top 3), we lock Year and have Reference Area and Medal free.Remember that free dimension are what we tabulate, so our spreadsheets of these is Reference Area (rows) and Medal (columns) for a particular year — the original setup.Sliced another way (middle 3), we lock Medal, and have Reference Area and Medal free. Our tabular view will show Reference Area (rows) and Year (cols) for a particular medal colour.Sliced still another way (bottom 3), we lock Reference Area and have Year and Medal free. Our table will show Medal and Year for a particular country.This is where we start to see the usefulness of arranging our data as a cube. By choosing a dimension to lock, and its value, we can obtain a table of exactly the view onto our data that we need.As we’ve seen, by locking all but two dimensions, we end up with a 2-D table that is a cross-section through the cube. When one of the two free dimensions is the Reference Period, the cross-section can be more precisely described as a time series — because it shows change over time.More than three dimensionsSo what’s all the fuss about? After all it’s pretty common to see Excel workbooks that do just this — a different slice on each worksheet.Recall how, a little earlier, looking at our 2-D table we realised we’d been assuming a third (year) dimension? Perhaps we might now realise that there’s a fourth dimension — the gender of the athlete. Our tables so far have locked the gender dimension to ‘All’ but maybe we also want to provide charts for male and female athletes.Recall too how we redrew our table to add the new dimension. Clearly that’s not possible this time — we’ve reached the limits of what can be drawn on a screen — and its not necessarily easy to visualise in your mind’s eye either, but it’s not necessary to visualise it — just keep locking down dimensions, slicing through the hypercube until you have something with just two free dimensions and you’ll have a spreadsheet.There’s no reason to stop with just four dimensions. We can go on to imagine datasets of any dimensionality. Let’s add a fifth.It’s almost impossible to visualise this, but again, you don’t need to — just apply the dimension locking trick to slice up the n-dimensional cube and PublishMyData will reduce it to an easily-handled table.We’ve now reached the limit of what would be practical in Excel — this would need 54 worksheets, but the Data Cube can keep on adding dimensions indefinitely.And what about our example observation? It’s still there, at the co-ordinates: year = 2012, gender = all, competition = Summer Olympics, country = USA, medal = gold. Turns out it was 5-dimensional all along.SparsenessLet’s consider the fortunes of some different countries in the former Yugoslavia. From the examples above, we might expect to see something like this:However, technically this diagram is not correct. The real position is a little bit more complicated. Serbia and Montenegro competed as a single team in the 2004 Olympics, but as separate countries subsequently. It doesn’t make sense to have an observation for just Serbia or just Montenegro in 2004 for any medal, and it doesn’t make sense to have observations with a Reference Area of ‘Serbia AND Montenegro’ in 2008 or 2012. There are holes in our cube: It is sparse.Note that this is not the same as winning, say, zero gold medals in a given year — which would be a perfectly valid observation. These are holes in the cube because they represent impossible co-ordinates, combinations of dimension that make no real-world sense. Reference Area is particularly prone to this sort of change over time, and its very common to see this pattern in real-world data. Moreover real-world data may include gaps because for some reason (including error) no observation was recorded for a particular combination of dimensions. Sparse cubes are very much the rule, rather than the exception, and sparse tables will result from this.There is, therefore, no guarantee that a data cube will have an observation for every possible combination of dimensions.You can find multidimensional cubes in the wild on PublishMyData powered sites such as Scotland’s statistics.gov.scot, or DCLG’s OpenDataCommunities.If you’re sharing statistical data like this, get in touch with us at hello@swirrl.com.