<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/deaths-per-firearm-violence-event-by-ellis2013nz/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://freerangestats.info/blog/2018/04/01/truncated-negbin-gun-violence"> free range statistics - R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><em>Caution – this blog post discusses homicide and suicide statistics and could be upsetting. If you feel disturbed or unhappy then <a rel="nofollow" href="https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines" target="_blank">here is a list of ways to get some emergency counselling help</a> around the world.</em></p>
<h2>A grim research question</h2>
<p>In my last post I looked at fitting a Poisson distribution to a set of count data that had been truncated so that observations below a certain threshold were not available. My reason for doing that was as a small step forward to today’s task, which is to model the number of deaths per “firearm violence incident” in the United States of America.</p>
<p>My original research question was “what is the distribution of number of fatalities per incident in USA firearm-related violence?”. The motivation was to better understand how material mass shooting or multiple-shooting events are in a broader context, and what proportion of violence is in smaller events than those that get the headlines.</p>
<p>Of course, there’s a lot written on this topic already. For example, Five Thirty Eight addressed the question in Maggie Koerth-Baker’s piece <a rel="nofollow" href="https://fivethirtyeight.com/features/mass-shootings-are-a-bad-way-to-understand-gun-violence/" target="_blank">Mass shootings are a bad way to understand gun violence</a>. Some of the important points made there:</p>
<ul>
<li>Mass shootings are rare despite the publicity they get; and the people doing them are different from most firearm violence perpetrators</li>
<li>Two-thirds of firearm deaths are suicides (which may or may not be part of an incident involving other injuries and fatalities)</li>
<li>Most firearm homicide victims are men between the ages of 15 and 34, and two-thirds are black; again, the profile of most firearm homicide victims differs from that of mass shootings (where 50% of victims are women, and around have of mass shootings involve domestic or family violence)</li>
</ul>
<p>Putting aside the natural interest, importance and indeed horror that firearm violence in the USA attracts around the world, my question was more about the number of deaths as interesting <a rel="nofollow" href="https://cran.r-project.org/web/views/ExtremeValue.html" target="_blank">extreme values</a>. Most firearm incidents have few if any deaths, but some have very many; how can this be statistically modelled?</p>
<p>Some final bits of context. I wrote about <a rel="nofollow" href="https://freerangestats.info/blog/2015/11/26/violent-deaths" target="_blank">violent deaths as a percentage of population</a> in an earlier post. The USA has more homicides per capita than other rich countries, although less than the front runners Colombia, Brazil and Russia. Here’s a key graphic from that post:</p>
<p><img width="100%" src="http://ellisp.github.io/img/0020-deaths-trends.svg"></p>
<p>On the particular issue of suicides that make up so many firearm-related deaths, here is a new chart along similar lines to the assaults graphic from that earlier post:</p>
<p><img width="100%" src="http://ellisp.github.io/img/0119-suicides.svg"></p>
<p>Note that I’ve chosen to keep the vertical scales “fixed” this time, to give a better sense of comparison across countries. Also that the suicide numbers are higher for many countries than they are for deaths from assault, but less variable (both between countries, and over time), which is why fixed vertical scales is more of an option here.</p>
<p>Like the earlier post, this is based on the OECD’s synthesis of data from national governments. I can’t vouch for the data’s comparability across countries – there are some definite surprises here – other than to say that I’m sure every possible effort has been made by the various national statistical offices to get it right. Here’s the code to download and draw the chart of suicide rates:</p>
<figure>
<pre><code data-lang="r"><span>library</span><span>(</span><span>tidyverse</span><span>)</span><span>
</span><span>library</span><span>(</span><span>scales</span><span>)</span><span>
</span><span>library</span><span>(</span><span>readr</span><span>)</span><span>
</span><span>library</span><span>(</span><span>lubridate</span><span>)</span><span>
</span><span>library</span><span>(</span><span>ggrepel</span><span>)</span><span>
</span><span>library</span><span>(</span><span>viridis</span><span>)</span><span>
</span><span>library</span><span>(</span><span>rstan</span><span>)</span><span>
</span><span>library</span><span>(</span><span>rsdmx</span><span>)</span><span>
</span><span>library</span><span>(</span><span>ISOcodes</span><span>)</span><span>
</span><span>#----------contextual data on suicides---------------
</span><span>url</span><span> </span><span>&lt;-</span><span> </span><span>&quot;http://stats.oecd.org/restsdmx/sdmx.ashx/GetData/HEALTH_STAT/CICDHARM.TXCMFETF+TXCMHOTH+TXCMILTX.AUS+AUT+BEL+CAN+CHL+CZE+DNK+EST+FIN+FRA+DEU+GRC+HUN+ISL+IRL+ISR+ITA+JPN+KOR+LVA+LUX+MEX+NLD+NZL+NOR+POL+PRT+SVK+SVN+ESP+SWE+CHE+TUR+GBR+USA+NMEC+BRA+CHN+COL+CRI+IND+IDN+LTU+RUS+ZAF/all?startTime=2000&amp;endTime=2020&quot;</span><span>
</span><span># Deaths per 100,000 population, standardised only
</span><span>if</span><span>(</span><span>!</span><span>exists</span><span>(</span><span>&quot;suic_sdmx&quot;</span><span>)){</span><span>
</span><span>dataset</span><span> </span><span>&lt;-</span><span> </span><span>readSDMX</span><span>(</span><span>url</span><span>)</span><span> </span><span>suic_sdmx</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>dataset</span><span>)</span><span>
</span><span>}</span><span>
</span><span>data</span><span>(</span><span>ISO_3166_1</span><span>)</span><span>
</span><span>suicide</span><span> </span><span>&lt;-</span><span> </span><span>suic_sdmx</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>variable</span><span> </span><span>=</span><span> </span><span>ifelse</span><span>(</span><span>UNIT</span><span> </span><span>==</span><span> </span><span>&quot;TXCMILTX&quot;</span><span>,</span><span> </span><span>&quot;All&quot;</span><span>,</span><span> </span><span>&quot;&quot;</span><span>),</span><span>
</span><span>variable</span><span> </span><span>=</span><span> </span><span>ifelse</span><span>(</span><span>UNIT</span><span> </span><span>==</span><span> </span><span>&quot;TXCMHOTH&quot;</span><span>,</span><span> </span><span>&quot;Males&quot;</span><span>,</span><span> </span><span>variable</span><span>),</span><span>
</span><span>variable</span><span> </span><span>=</span><span> </span><span>ifelse</span><span>(</span><span>UNIT</span><span> </span><span>==</span><span> </span><span>&quot;TXCMFETF&quot;</span><span>,</span><span> </span><span>&quot;Females&quot;</span><span>,</span><span> </span><span>variable</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>rename</span><span>(</span><span>year</span><span> </span><span>=</span><span> </span><span>obsTime</span><span>,</span><span> </span><span>value</span><span> </span><span>=</span><span> </span><span>obsValue</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>select</span><span>(</span><span>year</span><span>,</span><span> </span><span>COU</span><span>,</span><span> </span><span>value</span><span>,</span><span> </span><span>variable</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>left_join</span><span>(</span><span>distinct</span><span>(</span><span>ISO_3166_1</span><span>[</span><span> </span><span>,</span><span> </span><span>c</span><span>(</span><span>&quot;Alpha_3&quot;</span><span>,</span><span> </span><span>&quot;Alpha_2&quot;</span><span>,</span><span> </span><span>&quot;Name&quot;</span><span>)]),</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;COU&quot;</span><span> </span><span>=</span><span> </span><span>&quot;Alpha_3&quot;</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>year</span><span> </span><span>=</span><span> </span><span>as.numeric</span><span>(</span><span>year</span><span>),</span><span>
</span><span>country</span><span> </span><span>=</span><span> </span><span>Name</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>as_tibble</span><span>()</span><span>
</span><span>suicide</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>
</span><span>variable</span><span> </span><span>=</span><span> </span><span>fct_reorder</span><span>(</span><span>variable</span><span>,</span><span> </span><span>-</span><span>value</span><span>),</span><span>
</span><span>country</span><span> </span><span>=</span><span> </span><span>fct_reorder</span><span>(</span><span>country</span><span>,</span><span> </span><span>value</span><span>)</span><span>
</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>year</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>value</span><span>,</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>variable</span><span>))</span><span> </span><span>+</span><span>
</span><span>facet_wrap</span><span>(</span><span>~</span><span>country</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>()</span><span> </span><span>+</span><span>
</span><span>scale_colour_manual</span><span>(</span><span>&quot;&quot;</span><span>,</span><span> </span><span>values</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;blue&quot;</span><span>,</span><span> </span><span>&quot;grey10&quot;</span><span>,</span><span> </span><span>&quot;red&quot;</span><span>))</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;Deaths per 100,000 population (standardised rates)&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Suicide rates around the world (all methods)&quot;</span><span>,</span><span>
</span><span>&quot;USA is moderately high, but not as high as it features when compared on firearm-related deaths&quot;</span><span>)</span></code></pre>
</figure>
<h2>Data sources</h2>
<p>The <a rel="nofollow" href="http://www.gunviolencearchive.org/" target="_blank">Gun Violence Archive</a> aims to record every firearm violence event in the USA, certainly all those with fatalities. However, it won’t let you do a bulk download; and my requests for a way to do this have not gotten anywhere. The database query tool is set up to return individual cases rather than aggregate statistics, which is a shame for my purposes. In fact, only 500 incidents can be downloaded at once, and as far as I can tell it will give you the most recent 500 incidents matching your criteria. Because of the astonishing number of firearm violence incidents in the USA (the database includes non-lethal incidents), this makes downloading them all an impractical proposition without breaching the intent of the original limitation.</p>
<p>I tried a couple of things to get around this.</p>
<p>First, I queried the Gun Violence Archive database for each month in 2017 for incidents with at least one victim, and downloaded the c. 6,000 incidents it gave me as 12 CSV files (the latest 500 in the relevant month). This isn’t a simple random sample – events closer to the end of each month are more likely to be chosen; and events in shorter months eg February are more like to be chosen – but I thought it was close enough to act as though it was. I’ve saved all the data I got from this (and a few abortive additional efforts) in a zip file accessible from this website</p>
<p>Second, I queried the database for incidents with at least four victims (which could include both killed and injured) in each year from 2014 to 2018. Unless I misunderstood how the database worked, this returned less than 500 incidents each year. I then counted on screen (having first sorted by <code># Killed</code>) the frequency of events with 4, 5, 6 or more people killed, and manually entered the data myself.</p>
<p>My plan was to treat 2017 as my year for a representative sample, then to supplement that with a special census of all the large events over a longer period. Then I could combine the two datasets for a model of the overall distribution that paid due attention to the rare, large events.</p>
<h2>The 2017 data</h2>
<p>Here’s how it looks if you just take the sample I got of 2017 data, from the first, simple method. In all the analysis that follows I exclude events with zero deaths. This is because I distrust the boundaries that need to be crossed for such events to get into the archive. I suspect there are large numbers of zero-death events that fail to make it to the archive due to the limitations of the reporting process. In fact, it is difficult even to define a zero-death violent event (how violent? how much does it need to be known to the authorities?); whereas once at least one death has taken place, the chances of reporting become much greater, and certainly the definition is clearer. This difficulty of counting zero-death events has big implications when we come to modelling the data later.</p>
<p>First, a histogram of the distribution of number of deaths in each event:</p>
<p><img width="100%" src="http://ellisp.github.io/img/0119-histogram.svg"></p>
<p>We can see that my sample missed the two rare events of 2017: 59 deaths at Las Vegas and 27 in the attack on at the church in Sutherland Springs, Texas. This is a nice illustration of how many events we have – even with a sample of 6,000 firearm incidents causing injury or death, we didn’t pick up the two highest profile such events in the year.</p>
<p>Then if we look at a scatterplot to get a sense of the basic question of what proportion of deaths come from different scale incidents:</p>
<p><img width="100%" src="http://ellisp.github.io/img/0119-scatterplot.svg"></p>
<p>Not only are single death incidents 80% of all firearm violence events with fatalities (remember, in this analysis I am excluding zero-death incidents), more than 80% of fatalities come from such events.</p>
<p>Or even a humble pie chart (yes, I believe they do have their purposes, if done properly):</p>
<p><img width="100%" src="http://ellisp.github.io/img/0119-pie.svg"></p>
<p>Here’s the code to download the data and draw those charts.</p>
<figure>
<pre><code data-lang="r"><span>#===============downloading gun violence archives==============
</span><span>
</span><span># to download these files you need to go to http://www.gunviolencearchive.org/query/
# and do a query, then choose download to CSV. It only downloads 500 at a time.
# &quot;Save&quot; actually means &quot;Execute the query&quot;. Then you need to explicitly download CSV.
# And then you need to pick &quot;download&quot; (even though you're already in the &quot;download CSV&quot;
# environment and it has downloaded it = &quot;download&quot; here means &quot;yes, really download it,
# and save it to my local drive&quot;)
</span><span>
</span><span># to save others doing this, a subset of the data is on my website
</span><span>
</span><span># download the data
</span><span>try</span><span>(</span><span>unlink</span><span>(</span><span>&quot;gun-violence&quot;</span><span>,</span><span> </span><span>recursive</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>))</span><span>
</span><span>dir.create</span><span>(</span><span>&quot;gun-violence&quot;</span><span>)</span><span>
</span><span>download.file</span><span>(</span><span>&quot;http://freerangestats.info/data/gva.zip&quot;</span><span>,</span><span> </span><span>destfile</span><span> </span><span>=</span><span> </span><span>&quot;gun-violence/gva.zip&quot;</span><span>,</span><span> </span><span>mode</span><span> </span><span>=</span><span> </span><span>&quot;wb&quot;</span><span>)</span><span>
</span><span>unzip</span><span>(</span><span>&quot;gun-violence/gva.zip&quot;</span><span>,</span><span> </span><span>exdir</span><span> </span><span>=</span><span> </span><span>&quot;gun-violence&quot;</span><span>)</span><span>
</span><span># read into a list in R
</span><span>files</span><span> </span><span>&lt;-</span><span> </span><span>list.files</span><span>(</span><span>&quot;gun-violence&quot;</span><span>,</span><span> </span><span>full.names</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span>pattern</span><span> </span><span>=</span><span> </span><span>&quot;.csv$&quot;</span><span>)</span><span>
</span><span>gva_l</span><span> </span><span>&lt;-</span><span> </span><span>lapply</span><span>(</span><span>files</span><span>,</span><span> </span><span>read_csv</span><span>)</span><span>
</span><span># convert into a data frame and do a bit of tidying up of dates etc
</span><span>gva</span><span> </span><span>&lt;-</span><span> </span><span>do.call</span><span>(</span><span>&quot;rbind&quot;</span><span>,</span><span> </span><span>gva_l</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>date</span><span> </span><span>=</span><span> </span><span>as.Date</span><span>(</span><span>`Incident Date`</span><span>,</span><span> </span><span>format</span><span> </span><span>=</span><span> </span><span>&quot;%B %d, %Y&quot;</span><span>),</span><span>
</span><span>year</span><span> </span><span>=</span><span> </span><span>year</span><span>(</span><span>date</span><span>),</span><span>
</span><span>month</span><span> </span><span>=</span><span> </span><span>month</span><span>(</span><span>date</span><span>))</span><span> </span><span>%>%</span><span>
</span><span># filter out zero deaths incidents, which we can't exclude from the original query
</span><span> </span><span># (can only filter by number of victims, not number killed)
</span><span> </span><span>filter</span><span>(</span><span>`# Killed`</span><span> </span><span>></span><span> </span><span>0</span><span>)</span><span> </span><span>%>%</span><span>
</span><span># remove duplicates in case I downloaded some data twice or there is a database error:
</span><span> </span><span>distinct</span><span>()</span><span>
</span><span># this next graph not shown in the blog post, is just to illustrate that the data
# includes some non-2017 points to be wary of
</span><span>gva</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>date</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>`# Killed`</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_jitter</span><span>(</span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.1</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Fatal firearm incidents in the USA; 500 sampled from selected months&quot;</span><span>,</span><span>
</span><span>&quot;Points are jittered to give a sense of how much concentration there is in '1 death per incident'&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;Number killed in each incident&quot;</span><span>,</span><span>
</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;Searches from Gun Violence Archive&quot;</span><span>)</span><span>
</span><span># Only 2014 onwards is complete data
# Only 2017 is at all representative; the rest includes various other downloads!
</span><span>
</span><span># Histogram
</span><span>gva</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>year</span><span> </span><span>==</span><span> </span><span>2017</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>`# Killed`</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_histogram</span><span>(</span><span>binwidth</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>aes</span><span>(</span><span>y</span><span> </span><span>=</span><span> </span><span>..density..</span><span>),</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;steelblue&quot;</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.8</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_x_continuous</span><span>(</span><span>breaks</span><span> </span><span>=</span><span> </span><span>1</span><span>:</span><span>8</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_y_continuous</span><span>(</span><span>&quot;Percentage of events&quot;</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>percent</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Random sample of firearm-events in 2017&quot;</span><span>,</span><span>
</span><span>&quot;Excludes events with zero people killed&quot;</span><span>)</span><span>
</span><span># Scatterplot
</span><span>gva</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>year</span><span> </span><span>==</span><span> </span><span>2017</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>n_killed</span><span> </span><span>=</span><span> </span><span>paste0</span><span>(</span><span>&quot;'&quot;</span><span>,</span><span> </span><span>ifelse</span><span>(</span><span>`# Killed`</span><span> </span><span></span><span> </span><span>5</span><span>,</span><span> </span><span>`# Killed`</span><span>,</span><span> </span><span>&quot;More than 4&quot;</span><span>),</span><span> </span><span>&quot; death' incidents&quot;</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>group_by</span><span>(</span><span>n_killed</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>summarise</span><span>(</span><span>incidents</span><span> </span><span>=</span><span> </span><span>n</span><span>(),</span><span>
</span><span>deaths</span><span> </span><span>=</span><span> </span><span>sum</span><span>(</span><span>`# Killed`</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>ungroup</span><span>()</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>incidents</span><span> </span><span>=</span><span> </span><span>incidents</span><span> </span><span>/</span><span> </span><span>sum</span><span>(</span><span>incidents</span><span>),</span><span>
</span><span>deaths</span><span> </span><span>=</span><span> </span><span>deaths</span><span> </span><span>/</span><span> </span><span>sum</span><span>(</span><span>deaths</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>incidents</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>deaths</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>n_killed</span><span>,</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>n_killed</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>2</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_text_repel</span><span>()</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>&quot;none&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_x_continuous</span><span>(</span><span>&quot;Proportion of incidents&quot;</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>percent</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_y_continuous</span><span>(</span><span>&quot;Proportion of deaths&quot;</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>percent</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;The vast majority of firearm deaths come from single-death incidents.&quot;</span><span>,</span><span>
</span><span>&quot;Estimated firearms incidents and deaths in the USA in 2017, aggregated by number of deaths per incident&quot;</span><span>
</span><span>)</span><span> </span><span>+</span><span>
</span><span># scale_color_viridis(discrete = TRUE, option = &quot;D&quot;)
</span><span> </span><span>scale_color_brewer</span><span>(</span><span>palette</span><span> </span><span>=</span><span> </span><span>&quot;Set2&quot;</span><span>)</span><span>
</span><span># Pie chart
</span><span>blank_theme</span><span> </span><span>&lt;-</span><span> </span><span>theme_minimal</span><span>()</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>
</span><span>axis.title.x</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.title.y</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>panel.border</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>panel.grid</span><span>=</span><span>element_blank</span><span>(),</span><span>
</span><span>axis.ticks</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>plot.title</span><span>=</span><span>element_text</span><span>(</span><span>size</span><span>=</span><span>14</span><span>,</span><span> </span><span>face</span><span>=</span><span>&quot;bold&quot;</span><span>),</span><span>
</span><span>axis.text.x</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>()</span><span>
</span><span>)</span><span>
</span><span>gva</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>year</span><span> </span><span>==</span><span> </span><span>2017</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>n_killed</span><span> </span><span>=</span><span> </span><span>paste0</span><span>(</span><span>&quot;'&quot;</span><span>,</span><span> </span><span>ifelse</span><span>(</span><span>`# Killed`</span><span> </span><span></span><span> </span><span>5</span><span>,</span><span> </span><span>`# Killed`</span><span>,</span><span> </span><span>&quot;More than 4&quot;</span><span>),</span><span> </span><span>&quot; death' incidents&quot;</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>group_by</span><span>(</span><span>n_killed</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>summarise</span><span>(</span><span>incidents</span><span> </span><span>=</span><span> </span><span>n</span><span>(),</span><span>
</span><span>deaths</span><span> </span><span>=</span><span> </span><span>sum</span><span>(</span><span>`# Killed`</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>ungroup</span><span>()</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>incidents</span><span> </span><span>=</span><span> </span><span>incidents</span><span> </span><span>/</span><span> </span><span>sum</span><span>(</span><span>incidents</span><span>),</span><span>
</span><span>deaths</span><span> </span><span>=</span><span> </span><span>deaths</span><span> </span><span>/</span><span> </span><span>sum</span><span>(</span><span>deaths</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>weight</span><span> </span><span>=</span><span> </span><span>deaths</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>n_killed</span><span>,</span><span> </span><span>stat</span><span> </span><span>=</span><span> </span><span>&quot;identity&quot;</span><span>))</span><span> </span><span>+</span><span>
</span><span># make width 0.5 if prefer a donut...
</span><span> </span><span>geom_bar</span><span>(</span><span>width</span><span> </span><span>=</span><span> </span><span>1</span><span>)</span><span> </span><span>+</span><span>
</span><span>coord_polar</span><span>(</span><span>&quot;y&quot;</span><span>,</span><span> </span><span>start</span><span> </span><span>=</span><span> </span><span>0</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_fill_brewer</span><span>(</span><span>&quot;Number of deaths per incident&quot;</span><span>,</span><span> </span><span>palette</span><span> </span><span>=</span><span> </span><span>&quot;Set2&quot;</span><span>,</span><span>
</span><span>guide</span><span> </span><span>=</span><span> </span><span>guide_legend</span><span>(</span><span>reverse</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>))</span><span> </span><span>+</span><span>
</span><span>blank_theme</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;The vast majority of firearm deaths come from single-death incidents.&quot;</span><span>,</span><span>
</span><span>&quot;Estimated firearms deaths in the USA in 2017, aggregated by number of deaths per incident&quot;</span><span>)</span></code></pre>
</figure>
<h2>Truncated negative binomial distribution</h2>
<p>My starting point for modelling the count of deaths per event was a negative binomial distribution. This is often a good model for counts that vary more than a Poisson distribution would predict, which I was certain would be the case here. In fact, one way of deriving a negative binomial distribution is as a whole collection of different Poisson distributions, whose means themselves have a Gamma distribution. This lets a negative binomial distribution cover quite a variety of types of count data.</p>
<p>I have two datasets to fit with this distribution:</p>
<ul>
<li>a sample from 2017 truncated so only those with one or more deaths were observed (ie I have discarded the zero-killed events as probably incomplete, as mentioned above)</li>
<li>a census from 2014 to 2018 that is complete for high-death events but truncated so only those with four or more deaths were observed.</li>
</ul>
<p>Both are cases of truncated data for which we are interested in the underlying negative binomial distribution that plausibly could have generated it. Even the 2017 dataset of incidents with one or more deaths is truncated, by failing to include the great number of zero death incidents. Remember, I had doubts about whether these could be archived sufficiently comprehensively, hence decided to exclude them systematically.</p>
<p>There are a variety of ways to fit this model, but I chose to write a simple Stan program. I started with a very broad prior distribution for my expectation of what the underlying negative binomial distribution might be, and refined this by fitting the first, large set of 2017 data to it. Then I took the posterior distribution for the parameters of that negative binomial distribution and used them as the prior when fitting the model to just the larger, rarer events of four deaths or more per incident. My strategy here was to first get a broad sense of the distribution from the random sample, then to refine it so it matches with the extreme events.</p>
<p>As things turned out, the estimation tactic worked fine but the model didn’t work particularly well. I think no simple negative binomial distribution will adequately model this data. Here’s a comparison of the two original datasets (truncated at 1+ deaths for 2017, and truncated at 4+ deaths for all available years) with data for 100,000 events simulated from the model after fitting it in this two-step process:</p>
<p><img width="100%" src="http://ellisp.github.io/img/0119-results.svg"></p>
<p>It fits badly in two aspects noticeable to the human eye:</p>
<ul>
<li>There are too <em>many</em> predicted incidents with between 2 and 10 people killed. This is most obvious in the left-most panels, where we can see the actual distribution has much more probability mass concentrated at 1 death, and drops off more rapidly, compared to the data simulated from the model.</li>
<li>There are too <em>few</em> predicted incidents with 50+ people killed. Effectively none of the mass of the modelled distribution is to the right of 20 deaths, and it has no explanation for two events with 50+ people killed in the space of two years (Orlando and Las Vegas), or even three others between 15 and 30 in the past three years.</li>
</ul>
<p>Instead, the response variable should have a distribution that varies conditional on which part of the mixture the event is. I suspect a plausible model might be something like five types of incidents:</p>
<ul>
<li>suicides that don’t involve homicides</li>
<li>family and intimate partner related violence</li>
<li>aimless non-family inter-personal violence (eg road rage, argument at the pub)</li>
<li>related to crimes other than family violence (eg theft, drugs, turf wars)</li>
<li>mass shootings</li>
</ul>
<p>The last of these stands out as an event where the perpetrator aims for as many deaths as possible. However, there are obvious grey areas and overlaps between several of the categories (as noted earlier, family violence is a factor in about half of mass shootings). And for my purposes, I simply don’t have access to the explanatory variables necessary to do this kind of modelling.</p>
<p>I made one half-hearted attempt at modelling the data as a mixture of two distributions but it wasn’t much better than what I had originally. As well as the mixture question, I’m pretty sure a more skewed right-tailed distribution than the negative binomial will be needed, and that takes me well beyond this blog post.</p>
<p>Anyway, here’s how I did the two stage modelling. Perhaps it will be more useful in other situations with truncated count data. First, here’s the program written in Stan that fits a negative binomial model to truncated count data. It’s quite similar to the program in my last blog on fitting a model to truncated Poisson count data.</p>
<figure>
<pre><code data-lang="stan">data {
  int n;
  int lower_limit;
  int <null lower="lower_limit"> x[n];
real mu_prior_mean;
real mu_prior_sd;
real phi_prior_mean;
real phi_prior_sd;
}
parameters {
real&lt;lower=0>mu;
real&lt;lower=0>phi;
}
model {
mu ~ normal(mu_prior_mean, mu_prior_sd);
phi ~ normal(phi_prior_sd, phi_prior_sd);
for(i in 1:n){
x[i] ~ neg_binomial_2(mu, phi) T[lower_limit, ];
}
}

<p>And here’s the R code that fits two sets of data to two models</p>
<figure>
<pre><code data-lang="r"><span>#=================neg binomial modelling====================
</span><span>options</span><span>(</span><span>mc.cores</span><span> </span><span>=</span><span> </span><span>8</span><span>)</span><span>
</span><span>#------------------2017 sample first--------------------
</span><span>data</span><span> </span><span>&lt;-</span><span> </span><span>list</span><span>(</span><span>
</span><span># x = sample(filter(gva, year == 2017)$`# Killed`, 100),
</span><span> </span><span>x</span><span> </span><span>=</span><span> </span><span>filter</span><span>(</span><span>gva</span><span>,</span><span> </span><span>year</span><span> </span><span>==</span><span> </span><span>2017</span><span>)</span><span>$</span><span>`# Killed`</span><span>,</span><span>
</span><span>lower_limit</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span>
</span><span>mu_prior_mean</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span>
</span><span>mu_prior_sd</span><span> </span><span>=</span><span> </span><span>10</span><span>,</span><span>
</span><span>phi_prior_mean</span><span> </span><span>=</span><span> </span><span>5</span><span>,</span><span>
</span><span>phi_prior_sd</span><span> </span><span>=</span><span> </span><span>20</span><span>
</span><span>)</span><span>
</span><span>data</span><span>$</span><span>n</span><span> </span><span>&lt;-</span><span> </span><span>length</span><span>(</span><span>data</span><span>$</span><span>x</span><span>)</span><span>
</span><span>fit1</span><span> </span><span>&lt;-</span><span> </span><span>stan</span><span>(</span><span>&quot;0119-trunc-negbin.stan&quot;</span><span>,</span><span> </span><span>data</span><span> </span><span>=</span><span> </span><span>data</span><span>)</span><span>
</span><span>#----------------------2016 data second-------------------
# hand comparisons of the CSV download data with that on the screen at GVA show that
# some kind of unusual sampling is going on with dispoprotionate numbers of # incidents with 4 deaths being dropped from the data. It's not possible to download # reliably as a CSV so we'll just enter the values.
</span><span>
</span><span>other_years</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>
</span><span>data_frame</span><span>(</span><span>
</span><span>killed</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>4</span><span>,</span><span> </span><span>5</span><span>,</span><span> </span><span>6</span><span>,</span><span>7</span><span>,</span><span>8</span><span>),</span><span>
</span><span>freq</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>25</span><span>,</span><span> </span><span>8</span><span>,</span><span> </span><span>1</span><span>,</span><span> </span><span>1</span><span>,</span><span> </span><span>1</span><span>),</span><span>
</span><span>year</span><span> </span><span>=</span><span> </span><span>2014</span><span>
</span><span>),</span><span> </span><span>data_frame</span><span>(</span><span>
</span><span>killed</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>4</span><span>,</span><span> </span><span>5</span><span>,</span><span> </span><span>6</span><span>,</span><span> </span><span>8</span><span>,</span><span> </span><span>9</span><span>,</span><span> </span><span>10</span><span>,</span><span> </span><span>16</span><span>),</span><span>
</span><span>freq</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>31</span><span>,</span><span> </span><span>7</span><span>,</span><span> </span><span>2</span><span>,</span><span> </span><span>2</span><span>,</span><span> </span><span>3</span><span>,</span><span> </span><span>1</span><span>,</span><span> </span><span>1</span><span>),</span><span>
</span><span>year</span><span> </span><span>=</span><span> </span><span>2015</span><span>
</span><span>),</span><span> </span><span>data_frame</span><span>(</span><span>
</span><span>killed</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>4</span><span>,</span><span>5</span><span>,</span><span>6</span><span>,</span><span>8</span><span>,</span><span>50</span><span>),</span><span>
</span><span>freq</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>23</span><span>,</span><span>13</span><span>,</span><span>3</span><span>,</span><span>1</span><span>,</span><span>1</span><span>),</span><span>
</span><span>year</span><span> </span><span>=</span><span> </span><span>2016</span><span>
</span><span>),</span><span>
</span><span>data_frame</span><span>(</span><span>
</span><span>killed</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>4</span><span>,</span><span>5</span><span>,</span><span>6</span><span>,</span><span>8</span><span>,</span><span>9</span><span>,</span><span>27</span><span>,</span><span>59</span><span>),</span><span>
</span><span>freq</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>33</span><span>,</span><span> </span><span>4</span><span>,</span><span> </span><span>2</span><span>,</span><span> </span><span>1</span><span>,</span><span> </span><span>1</span><span>,</span><span> </span><span>1</span><span>,</span><span> </span><span>1</span><span>),</span><span>
</span><span>year</span><span> </span><span>=</span><span> </span><span>2017</span><span>
</span><span>),</span><span>
</span><span>data_frame</span><span>(</span><span>
</span><span>killed</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>4</span><span>,</span><span> </span><span>5</span><span>,</span><span> </span><span>17</span><span>),</span><span>
</span><span>freq</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>11</span><span>,</span><span> </span><span>3</span><span>,</span><span> </span><span>1</span><span>),</span><span>
</span><span>year</span><span> </span><span>=</span><span> </span><span>2018</span><span>
</span><span>)</span><span>
</span><span>)</span><span>
</span><span>data</span><span> </span><span>&lt;-</span><span> </span><span>list</span><span>(</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>rep</span><span>(</span><span>other_years</span><span>$</span><span>killed</span><span>,</span><span> </span><span>other_years</span><span>$</span><span>freq</span><span>),</span><span>
</span><span>lower_limit</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span>
</span><span>mu_prior_mean</span><span> </span><span>=</span><span> </span><span>summary</span><span>(</span><span>fit1</span><span>)</span><span>$</span><span>summary</span><span>[</span><span>&quot;mu&quot;</span><span>,</span><span> </span><span>&quot;mean&quot;</span><span>],</span><span>
</span><span>mu_prior_sd</span><span> </span><span>=</span><span> </span><span>summary</span><span>(</span><span>fit1</span><span>)</span><span>$</span><span>summary</span><span>[</span><span>&quot;mu&quot;</span><span>,</span><span> </span><span>&quot;sd&quot;</span><span>],</span><span>
</span><span>phi_prior_mean</span><span> </span><span>=</span><span> </span><span>summary</span><span>(</span><span>fit1</span><span>)</span><span>$</span><span>summary</span><span>[</span><span>&quot;phi&quot;</span><span>,</span><span> </span><span>&quot;mean&quot;</span><span>],</span><span>
</span><span>phi_prior_sd</span><span> </span><span>=</span><span> </span><span>summary</span><span>(</span><span>fit1</span><span>)</span><span>$</span><span>summary</span><span>[</span><span>&quot;phi&quot;</span><span>,</span><span> </span><span>&quot;sd&quot;</span><span>]</span><span>
</span><span>)</span><span>
</span><span>data</span><span>$</span><span>n</span><span> </span><span>&lt;-</span><span> </span><span>length</span><span>(</span><span>data</span><span>$</span><span>x</span><span>)</span><span>
</span><span>fit2</span><span> </span><span>&lt;-</span><span> </span><span>stan</span><span>(</span><span>&quot;0119-trunc-negbin.stan&quot;</span><span>,</span><span> </span><span>data</span><span> </span><span>=</span><span> </span><span>data</span><span>)</span><span>
</span><span>#---------------comparison of modelled to actual-----------
</span><span>phi</span><span> </span><span>&lt;-</span><span> </span><span>summary</span><span>(</span><span>fit2</span><span>)</span><span>$</span><span>summary</span><span>[</span><span>&quot;phi&quot;</span><span>,</span><span> </span><span>&quot;mean&quot;</span><span>]</span><span>
</span><span>mu</span><span> </span><span>&lt;-</span><span> </span><span>summary</span><span>(</span><span>fit2</span><span>)</span><span>$</span><span>summary</span><span>[</span><span>&quot;mu&quot;</span><span>,</span><span> </span><span>&quot;mean&quot;</span><span>]</span><span>
</span><span>x_sim</span><span> </span><span>&lt;-</span><span> </span><span>rnbinom</span><span>(</span><span>100000</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>phi</span><span>,</span><span> </span><span>mu</span><span> </span><span>=</span><span> </span><span>mu</span><span>)</span><span>
</span><span>comp_data</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>
</span><span>data_frame</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>rep</span><span>(</span><span>other_years</span><span>$</span><span>killed</span><span>,</span><span> </span><span>other_years</span><span>$</span><span>freq</span><span>),</span><span> </span><span>source</span><span> </span><span>=</span><span> </span><span>&quot;Actual, 4+ deaths&quot;</span><span>),</span><span>
</span><span>data_frame</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>filter</span><span>(</span><span>gva</span><span>,</span><span> </span><span>year</span><span> </span><span>==</span><span> </span><span>2017</span><span>)</span><span>$</span><span>`# Killed`</span><span>,</span><span> </span><span>source</span><span> </span><span>=</span><span> </span><span>&quot;Actual, 1+ deaths&quot;</span><span>),</span><span>
</span><span>data_frame</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>x_sim</span><span>[</span><span>x_sim</span><span> </span><span>>=</span><span> </span><span>1</span><span>],</span><span> </span><span>source</span><span> </span><span>=</span><span> </span><span>&quot;Simulated, 1+ deaths&quot;</span><span>),</span><span>
</span><span>data_frame</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>x_sim</span><span>[</span><span>x_sim</span><span> </span><span>>=</span><span> </span><span>4</span><span>],</span><span> </span><span>source</span><span> </span><span>=</span><span> </span><span>&quot;Simulated, 4+ deaths&quot;</span><span>)</span><span>
</span><span>)</span><span> </span><span>comp_data</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>x</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>..density..</span><span>))</span><span> </span><span>+</span><span>
</span><span>facet_wrap</span><span>(</span><span>~</span><span>source</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_histogram</span><span>(</span><span>binwidth</span><span> </span><span>=</span><span> </span><span>1</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Comparison of actual and simulated deaths per incident&quot;</span><span>,</span><span>
</span><span>&quot;Negative binomial model fit iteratively to two sets of truncated data.
Simulated data based on the model does not feature the rare, large events observed in reality.&quot;</span><span>)</span></code></pre>
</figure>
<h2>Summary</h2>
<p>To recap:</p>
<ul>
<li>I wanted to characterise the distribution of deaths per firearm incident the USA, and in particular try to model it with a single negative binomial distribution.</li>
<li>I couldn’t get the full data I needed from the Gun Violence Archive, aggregated by deaths per incident. So I downloaded a representative sample of data from 2017 for incidents with at least 1 death, and a census sample of data for 2014 to present (early 2018) for incidents with at least 4 deaths.</li>
<li>I used Bayesian methods to fit negative binomial distributions to the truncated data. I started with a very broad prior distribution for the mean and shape, and narrowed down estimates for those parameters by fitting to the data truncated at 1 death. Then I used the posterior distribution for the parameters from that model as the prior distribution for fitting to the data truncated at 4 deaths.</li>
<li>The estimation method worked, but showed that a single negative binomial distribution is too simple a model to fit this data. There is a wider dispersal of counts of deaths per incident than the model allows for. In particular, in reality there are even more incidents with one death than modelled; and also a small number of high-death incidents that do not fit well into the model. An alternative model that takes into account the mixture of several different distributions, and that is better at predicting rare, large events, is needed.</li>
</ul>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://freerangestats.info/blog/2018/04/01/truncated-negbin-gun-violence"> free range statistics - R</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/-cnpIa1Z8wI" height="1"></a></div></null></code></pre></figure>