Charts and Graphs
Effect of Vision Zero on Traffic Casualties
In 2014, New York City set a goal of eliminating traffic fatalities and injuries. The Vision Zero initiative reduced the speed limit throughout the city from 35 to 25 miles per hour and changed traffic rules on many roads and many intersections.
We want to test the null hypothesis that Vision Zero had no effect on traffic fatalities and injuries. Since the initiative began at a fixed point in time, one way to explore the question is to compare the two time periods.
As shown in the barplot and the table, the number of "fatalities" and "injuries" has dropped dramatically since the Vision Zero initiative began in 2014.
Between 2013 and 2017, the number of injuries decreased 20 percent and the number of fatalities decreased 35 percent. (I have defined "casualties" as the sum of "fatalities" and "injuries," so it follows the downward trend in "injuries").
To create the table that allows us to make such comparisons, we can use the tapply and cbind functions.
Noting that we want to sum across years, we set the FUN argument to sum, we set the INDEX argument to nycdot$year and we sum over nycdot$Casualties, nycdot$Fatalities and nycdot$Injuries:
## make Casualties, Fatalities and Injuries by Year
Then we cbind the individual tables together, fix the column names and print the result:
## bind them into one table
And we can use the barplot function to plot the trend over the years:
## set colors and text for barplot
Another way of exploring the question is to compare distributions. In our discussion of cross-tabulations, we will show that the distribution of average monthly casualties has shifted towards zero. In other words, the percentage of intersections with fewer than 0.05 average monthly casualties has grown since the Vision Zero initiative began.
Effect of the Minimum Wage on Employment
In recent years, some US states and cities have moved toward raising their minimum wage to $15 per hour. Others have kept their minimum wage at the federal level of $7.25 per hour.
We want to know how the minimum wage affects the opportunities available to workers. In our discussion of regression, we will formally test the null hypothesis of zero correlation between state minimum wage rates and employment rates after controlling other factors.
The time-series graphs below suggest that there is a small, positive correlation. Employment rates in states with "high" minimum wages are about the same as those in "medium" minimum wage states, but employment rates are much lower in "low" minimum wage states.
To create time-series comparisons like these, we first use the weighted.mean function to create a series of tables for each group of states. But to prevent the largest four states -- California, Texas, Florida and New York -- from dominating the weighted average, I have analyzed them separately.
## create table of employment rates over time in "high" minimum wage states
To make it easy to create a large number of time-series graphs, it's helpful to write a few of functions:
## functions to make plotting easy
Then we plot each group of states over time:
## plot the "high" minimum wage states
More detailed examples can be found in the R script that I wrote for this analysis.
In our discussion of regression, we will show that the positive correlation between state minimum wage rates and employment rates remains even after controlling for the effect of other variables, such as inflation, average annual pay and state and year fixed effects.
Copyright © 2002-2020 Eryk Wdowiak