New York crime rates

While browsing through different sites, I randomly cam across the ominous-sounding disaster center website. There is a fair amount of data that could be analyzed there, but my attention was caught by an entry stating that they had just updated the “1965 to 2012 State Crime Pages”. From there, I chose the completely biased option of analyzing crime rates in my hometown (NYC) from 1965 – 2012.

 

Number of crimes per 100,000 habitants in NYC during 1965 to 2012.

Number of crimes per 100,000 habitants in NYC during 1965 to 2012.

You will notice that I have also added the periods during which various NYC mayors were in office, where I color-coded each period by the party ideologies of each mayor. It’s  already a well-known anecdote, but it is remarkable to see the drop-off in crime rate after Giuliani took office, and how Bloomberg was able to maintain that.

However, it does make us consider the slightly deeper question of whether the crime rate in NYC has converged to a minimum, and whether human nature would ever be capable of reducing that to zero? There’s an interesting prediction problem…

Advertisements

World tourism and country expenditure

I’ve recently come across the https://www.undata-api.org/ website, which makes available all the great data that has been gathered by the UN. There’s literally a thousand different datasets one could analyze, and I intend on doing just that, but for some reason I opted to look at some of the world tourism data they have collected. Perhaps this is my subconscious telling me to travel more, or to get the hell out of the epically horrible winter we’ve been having over here in NYC.

So with no further ado, I present to you a thoroughly incomplete analysis of the UN world tourism data! First I set out to look at the amount of money each country spent on advertising themselves to unsuspecting citizens in other countries during the period of 1995-2012.

Country expenditure on tourism between 1995 and 2012

Country expenditure on tourism between 1995 and 2012

The results above show how the USA is the country that consistently spends the most on tourism advertising in other countries. We can also see that Germany, France and the UK (and to a lesser extent Spain and Italy) are amongst the European nations that spend the most. However, what I find the most interesting is the relative position of China, that starts among the countries that spend the less on tourism in 1995, only to be in second position by the time we reach the year of 2012. It is possible to notice a sharp spending increase by the time 2007-08 comes around, and I would be interested to find out if this may be linked to the Beijing Olympics.

To generate the video above, I simply plotted static images (for example a PNG file) of the data at each timepoint and concatenated everything into GIF format using the following linux command:

convert -delay 100 *.png country_expenditure_by_year.gif

convert is a highly useful function that I call fairly often, and contains many more arguments that allow to tailor very convincing video media. (Note that there are many other ways you could do this, in particular ffmpeg or the animation package in R)

Next, I set out to check whether spending large amounts of money to advertise the virtues of your country abroad is actually worth it. In other words, does more spending abroad equate to more people visiting your country?

Amount of money each country spends on advertising in other countries against the  number of visitors that entered the country (cumulative during the period of 1995-2012)

Amount of money each country spends on advertising in other countries against the number of visitors that entered the country (cumulative during the period of 1995-2012)

 

Overall we see that France can be deemed as the most popular country – not only does it host the most tourist but also while spending far less on tourism than many other countries. As a frenchman, I find this tres naturel, since we do have, after all, the best food, wine, women and weather (some people may also point out the historical culture but I hate museums so there). While Spain and the UK do well, it is disturbing to see how bad the return on investment is for countries such as the USA, Germany and Japan (that surprised me, although geographical distance may be a factor here)

Finally, we can also search for trends in tourism travel over the period of 1995-2012. Here, we can plot the cumulative number of tourist entries recorded in countries across the world during each year:

Cumulative number of tourist entries recorded in countries across the world between 1995 and 2012

Cumulative number of tourist entries recorded in countries across the world between 1995 and 2012

There is noticeable dip of worldwide tourist entries between the year 2007-2009, which may be blamed upon a greedy minority of financial ‘experts’. I have to admit that although I heard and read a lot of about the 2008 financial crisis, it never affected me noticeably. However, it is remarkable to see the extent with which it affected tourism travel, and one can only imagine the knock-on effect it must have had on the economy of entire countries.

Restaurant Inspection Results

Living in NYC is not good for one’s cooking skills. There are just too many mouth-watering options out there that always convince me to eat out rather that stay in line for two hours at Trader Joe’s. Also, this means that my fridge always has room for life essentials such as beer, siracha (aka the juice of gods) and liquor mixers.

Crazy lines at Trader Joe's

Crazy lines at Trader Joe’s

This is why I was both intrigued and amused to find a Restaurant Inspection Results dataset on the NYC open database. Before I walk into any restaurant,  I always look out for the sanitary inspection results just to be sure that if I do get sick that night, it will be from booze rather than food. This dataset contains bundles of information for 20,717 restaurants scattered across the five boroughs, and I thought I’d take a sneak-peek. (Full disclosure: I barely scratched the surface of this dataset, and there are a lot of other things you could do with it!)

With no further ado: first, a distribution of the grades distributed to restaurants in the five boroughs between the span of 2010-2013 (note that P is for “Pending”)

Grades given to restaurants located in the 5 New York borough between 2010 and 2013

Grades given to restaurants located in the 5 New York borough between 2010 and 2013

In addition to categorical grades A, B and C, it turns out that the good people of the NYC Health and Safety Department also issue scores to each restaurant:

Scores given to restaurants located in the 5 New York borough between 2010 and 2013

Scores given to restaurants located in the 5 New York borough between 2010 and 2013

We can also look at the diligence of the inspectors by checking the rate of restaurant inspections during each month of the 2007-2013 period:

Number of visits conducted by the Health and Safety department during each month of 2007-2013

Number of visits conducted by the Health and Safety department during each month of 2007-2013

Finally, we can check the most common infractions that were encountered in restaurants of the five boroughs during the year of 2013:

Year Most common violations
2013 Aisle or workspace inadequate
Personal cleanliness inadequate
Cold food held above 41F