Shiny Apps for Service

IOC Summer Fellow Yulan Sun
IOC Summer Fellow Yulan Sun

This summer I worked as the Boston University Initiative on Cities Fellow for the City of Providence’s Department of Innovation. I completed many interesting projects during my Fellowship, including a 311 service request data analysis and predictive youth crime data analysis.

311 is the telephone number for residents in Providence to request city services, including but not limited to reporting a pothole or requesting trash pick up. To make it easier and faster to process, the City of Providence also launched the PVD311 mobile app and PVD311 website to submit and track requests. My 311 service request data analysis aimed to measure and improve the quality of 311 service.

To measure the quality of service, four quality-related metrics were defined: request volume, duration, on-time rate, and efficiency. Request volume is the quantity of requests in the area. Duration is the time spent on completing the request. On-time rate is the ratio of number of on-time request to total number of requests. Efficiency is the ratio of expected time to complete request to actual time to complete request.

Based on the longitude and latitude of request location, I added neighborhood information for each request, and regrouped requests by Providence’s neighborhoods to compare service quality in different areas. In addition, I added neighborhood demographics data, such as population density and family median income, to explore their effect on service quality.

Through conducting a variety of exploratory data analyses, I found it’s better to interpret those metrics by each department and each type within the department. In order to facilitate exploration of result, I built an interactive shiny application in R (a statistical software) to visualize service quality data as Providence maps. This tool can be used for the City of Providence to easily compare service quality in neighborhoods and measure the effectiveness of city service.

shiny app
Figure 1: Providence 311 Shiny application

Predictive data analysis on youth crime was my other major project this summer. From the crime data, I found that the number of youth crime cases has been decreasing for the last few years. I also found that the population composition of suspects and arrestees by age indicates youth between 20 to 24-years-old as the majority of convicted criminals under 25-years-old.

Since the research is focusing on youth crime, it’s important to explore if there is difference in crime between schooldays and holidays. I sorted out schooldays and holidays according to Providence’s public school calendar to compare crime types. The result shows that for some crime types, such as malicious mischief, the number of suspects and arrestees under 25-years-old who committed crimes on holidays are much more than on schooldays. The chi-square test also proves that holidays have a significant effect on those crime types.

Based on the crime data, I analyzed the factors leading to youth crime recidivism and youth violent crime. For youth crime recidivism, I built a logistic regression model to test significance of variables such as gang affiliation, the individual’s age at first arrest, number of times an individual is a suspect prior to first arrest, and other factors. According to the result, for example, controlling for other variables, individuals with gang affiliations are six times as likely to be re-arrested compared to individuals with no gang affiliation. And for every year older at the time of first arrest, the likelihood of re-arrest decreases about 12%.

For youth violent crime, I ran logistic regression on variables such type of crime committed, number of times being arrested, number of times being suspects, and other variables. The result shows, for example, controlling for other variables, that for every additional arrest, the individual’s likelihood to commit violent crime will increase 20.9%. For every additional time an individual is considered a suspect, the likelihood of committing a violent crime will increase 15.3%. Individuals who committed domestic crime were 1.3 times as likely to commit violent crime compared to those who didn’t commit domestic crime.

To better be aware of youth crimes in neighborhoods, I built an interactive shiny application in R to map youth crime location. With an age slider, the data can be filtered by age range. It can also be used to select specific crime location types.

Figure 2: Youth Crime Shiny application
Figure 2: Youth Crime Shiny application

My predictive data analysis on youth crime helps the City of Providence find the roots of problems and to identify and implement preventative measures, thereby ensuring the safety of the city. Besides these projects, I assisted with some other tasks such as testing the Boston CityScore toolkit and tracking rejected recycling loads.

As a graduate student at BU majoring in practical statistics, the various statistical methods I learned from class were helpful for my work. The extensive training on using R to conduct data analysis was especially beneficial for me to complete my projects. Our MSSP statistical consulting program gave me experience selecting appropriate statistical methods to conduct data analysis and presenting research results efficiently prior to my Fellowship.

This Fellowship was a precious opportunity for me to have a better understanding of municipal government. Just like the Innovation Department’s mission, “To work with internal and external stakeholders to streamline the delivery of city services, promote public entrepreneurship, and enhance citizen engagement,” the City of Providence is making great efforts to to make local government more open, accountable, and responsive. Since 2015 the City of Providence has launched 12 new datasets and 3 new data tools, available online, which contributes to Providence’s current rank at #16 in the U.S. City Open Data Census.

Through the Fellowship I also learned new skills such as how to geocode with Google Maps API,  and how to embed HTML widgets such as Plotly, Leaflet in Shiny application to make dashboard more informative. Since my career goal is to become a data scientist, I believe this Fellowship is beneficial for my future career after graduation, and brings me great confidence to keep moving forward.

This post was written by Yulan Sun, the Initiative on Cities’ 2016 Providence Summer Fellow

About Yulan Sun

Yulan graduated from the University of Southern California with a Master of Arts in Economics. Following that, Yulan attended Boston University and graduated with a Master of Science in Statistical Practice.