# Deaths from assault over time in 40 relatively rich countries

## At a glance:

Simple but effective graphics showing relative country standings with regard to deaths from assault, and trends over time. Most countries in this group are seeing a decline in deaths from assault, from peaks in the 1970s, '80s or '90s. Data are downloaded from OECD.Stat via their API and SDMX and this post shows how to do this, and also demos screen scraping with {rvest} - not that it needs any demo-ing, it's so user-friendly.

26 Nov 2015

## Deaths from assault

A friend was looking at comparative data on violent deaths in a range of countries and I couldn’t resist the chance to turn out some graphics. The data come from the OECD, who compiles them from contributions by member and associated country governments - effectively, wealthier countries - and makes them available via a web Application Programming Interface in the SDMX format. I ended up with some graphics that I think tell a powerful story.

The data in this post are age-standardised deaths per 100,000 for whole population, male population, and female population; the OECD variables coded as TXCMILTX, TXCMHOTH and TXCMFETF. I’m not an expert in this area - if they mean something else (I’m a little unsure on the age-standardisation) don’t just curse me, let me know.

### Compare across countries and sex

Looking at snapshot cross-sectional average data since 1990 (for which there is more comparable data across countries, with a number of countries such as Germany and Czech Republic only coming into existence at or around that period) we see two things that met the “intra-ocular impact test” ie they hit you between the eyes:

• For nearly all the listed countries, males are much more likely to killed in a assault than are females
• The Americas and the former Soviet Socialist Republics (Russia, Estonia, Latvia, Lithuania) dominate the list of most violent places to live (or rather, to die). Other than countries of these two types, only South Africa makes the top 11 countries. The safer countries include those in eastern Europe (other than former USSR, but including countries that were in its political orbit), Asia, Australasia and western Europe.

Remember that this only shows relatively weathly countries - for a more complete list (but less complete data) check out this Wikipedia list of countries that can be ranked by intentional homicide rates (not quite the same as our data, which includes all deaths from assault, intentional or otherwise) or this report from the UN Office on Drugs and Crime.

In the chart below, the label for each country is centred at the overall population rate of deaths from assault and the red and blue vertical strokes mark the male and female rates respectively. Beware that the scale is logarithmic - this was necessary to stop everywhere except Colombia being squashed into the left of the chart.

### Compare across time

Looking at trends across time we see an encouraging sign. Most countries’ violent death rates peaked in the 1980s or 90s and have been declining, in some cases dramatically, in recent years.

In the chart below the vertical axis for each country has been set to make most use of the plot area and draw attention to trends rather than absolute levels, so you can’t compare the absolute levels of violence across countries. That’s what the first chart was for, so the two charts complement eachother. The facets in the trend chart below have been ordered from lowest to highest rates (1990+ averages), so there is still some visual indicator of absolute size of the problem.

The recent declines are particularly strong in the Eastern Europe and USSR region - Russia, Estonia, Latvia, Lithuania, Poland, Slovak Republic, Slovenia, Czech Republic, and Germany have all seen dramatic drops in rates of death from assault after rapid growth in the early 1990s, associated with the magnitude of the transition in economic and political systems that took place at that time. There’s also the possibility of changing official statistical practice with the changing political system, but there’s no particular reason I know of (I’m not an expert in former and post Soviet statistics systems, either…) to think of that, and the general curve looks plausible given an outsider’s view of the recent history there.

Tragically, Norway’s spike in 2011 is really noticeable to a close viewer, even in a chart like this with 40 countries covering 50 years.

### Secondary point - Catholic countries and gender (more men getting killed) violence patterns?

Looking into the imbalance between the sexes, we see that the countries with consistently high male to female ratios of rates of violent death are Colombia, Brazil, Mexico, Chile, Costa Rica and South Africa, in all of which males are at least 5 times more likely to be killed violently than are females.

At first glance there looks to be a possible correlation between being predominantly Catholic and a high ratio of male to female violent death rates (as well as the Latin American countries leading the pool, Italy and Ireland are also fairly high up on the list). In an early draft of this post I had a casual mention of this and just a warning against slack inference, but I decided it was irresponsible to leave it at that. To be more professional, I followed up my hunch with data on the proportion of a country that was Catholic in 2005 courtesy of data published by David M. Cheney, a Catholic enthusiast (not sanctioned by any Catholic church authority but good enough for our purposes).

As often proves to be the case, the answer is “I think you’ll find it’s a bit more complicated than that” and in fact there isn’t an easy way to draw a conclusion about whether females are protected, or males picked on, particularly in Catholic countries, just from this aggregated data.

The challenge is that we’ve made up our hypothesis - relationship between Catholicism and males being disproportionately killed in assaults - after peeking at the data. This generally renders post-peek model building difficult if not impossible, at least as a basis of hypothesis testing.

The nub of the issue is that the apparent relationship with Catholicism might be an artefact of the high male murder by assault rates in five specific countries - Colmbia, Brazil, Mexico, etc - where the high Catholicism is highly correlated with other factors, specifically “Latin Americanism”. Any decent model should take this into account - it’s just wrong to treat these five countries as independent observations (as is implicitly done in fitting a simple regression). The image below illustrates the conundrum:

• The top plot ignores the Latin Americanism of those five countries and fits a simple linear regression, which finds (illusory) statistically significant evidence of a link between Catholicism and a higher ratio of male to female death-from-assault rates. As mentioned above, this approach is unsound because it ignores the grouping of the five prominent countries that drag up the slope of the line.
• The second plot controls for this by adding a dummy variable for “Americas”. The result is still statistically significant evidence of a Catholic effect, but interacting with the continent effect ie only in the Americas does it seem to matter being an increasingly Catholic country when wondering if males are more likely to be killed in an assault than females.
• The third plot (which I think is my preferred) adds a dummy variable for “Latin American” and finds no statistically significant relationship between Catholicism and male-female death ratios after that effect is accounted for.

There’s no simple way to solve the correlation of our two explnatory variables - Americanism and Catholicism - and picking which of the second or third model above is best, and the essentially arbitrary nature of our continent-classification variable. There’s no possibility of creating a test-set of data, for example. Even if we brought in what data are available on poorer countries and used them as a test set, the confounding relationship between Latin America and Catholicism would pertain to that dataset too. So until more data or ideas come out (and I’m not claiming to have looked for them, either way) I prefer to stick to the third plot, and say only that male/female assault death ratios are much higher in Latin American countries, we don’t know why from just this dataset, and after we’ve taken that into account there’s no real further evidence in this particular dataset of an additional Catholic effect.

## Arranging the data

Here’s how I import the data into R. If you know exactly what you’re looking for, you can import data directly from OECD.Stat with the rsdmx package by sending an appropriately structured URL (line 18 below) to their website. However, to work out that URL you’ll probably need to navigate their site by hand and choose your particular ‘customising’, then choose the “export” and “SDMX” options, then copy the URL it generates for you. It’s useful for reproducibility purposes (for example, it meant I didn’t need to save a copy of the data anywhere to make the code below reproducible for others).

The country codes provided by the OECD are ISO 3166 three digit country codes and we want to turn them into something more friendly for presentation purposes. We also want to rename the levels of our units (“TXCMILTX” is less friendly than “Deaths per 100 000 population”), order some factor levels for future graphics purposes, and knock out Turkey which only has a few year’s data.

Having created the original object viol I make a few summary and total objects to help with structuring my graphics. In particular, I need a data frame that provides average rates since 1990 for the first chart, and a data frame of totals so I can arrange the plots in order of increasing rates of death from assault.

## The actual plots

Now we’re ready to draw some plots. Here’s the code that makes the main two plots:

To investigate the Catholicism and gender ratio issues in the second set of plots, I had to pull down some data from the web using Hadley Wickham’s amazing rvest package. It’s inspired by Python’s wonderful Beautiful Soup but I have to say is astonishingly user friendly.

Here’s my complete set of code for the gender dot plot, downloading the Catholicism data, and the resulting scatter plot. The web-scraping part occupies a total of two lines of code (21 and 22 in the code below) - amazing:

← Previous post

Next post →