2/17/2020

Crime Rates

Explore the Data for yourself!

Drills down into many cities, many years:

selectedCity<-sample(dt$agency_jurisdiction,1)
print(selectedCity)
## [1] "Oakland, CA"
datacit<-dt[agency_jurisdiction==selectedCity]
popmod<-glm(population ~ report_year, data=datacit)
l<-datacit[report_year>2004]
l$report_year<-2015:2024
l$agency_code<-as.factor(l$agency_code)
l$population<-as.numeric(predict(popmod,l))
predl<-predict(preproc, l)

Predicting the Future!!

preds<-as.numeric(predict(modelFit,predl))
xs<-c(datacit[,report_year], l$report_year)
ys<-c(datacit[,crimes_percapita], preds)
plot(x=xs,y=ys,col=cs, pch=16, main=selectedCity, ylab = 'Crimes per Capita')
legend('topright',legend=c('Recorded','Predicted'), fill=c('red','blue'))