<h2>Abstract</h2>
<p>Inspired by the recent <strong>March For Science</strong> we look into methods for the statistical estimation of the number of people participating in a demonstration organized as a march. In particular, we provide R code to reproduce the <strong>two on-the-spot counting method</strong> analysis of <span>Yip et al. (2010)</span> for the data of the July 1 March in Hong Kong 2006.</p>
<p><br><a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"></a> This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>. The markdown+Rknitr source code of this blog is available under a <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU General Public License (GPL v3)</a> license from <a href="https://github.com/hoehleatsu/hoehleatsu.github.io"></a>.</p>
<h2>Introduction</h2>
<p>Exercising your democratic right to express support for a cause by demonstration has found anew usage. The <a href="https://en.wikipedia.org/wiki/March_for_Science">March for Science</a> is a recent examples of such a demonstration inspired by recent political developments. The number of persons participating in such marches is the indicator by which the support of the cause is measured. Crowd size estimates have therefore always been subject to political interpretation and, hence, possible politically motivated bias. In this work we focus on what statistics has to offer with respect to finding the <strong>true number</strong> of participants. A good overview of this task's challenges is given in <span>Watson and Yip (2011)</span>. A particular difficulty is the size estimation of moving crowds as seen in marches.</p>
<p>As case study we replicate the analysis of <span>Yip et al. (2010)</span> on estimating the number of participants in the <a href="https://en.wikipedia.org/wiki/Hong_Kong_1_July_marches#2006">1st of July Marches</a> in Hong Kong. Since the handover to China in 1997 these marches have been conducted yearly to demonstrate for democracy and freedom of speech in Hong Kong. Below is shown the 3.6 km long demonstration route from <a href="https://de.wikipedia.org/wiki/Victoria_Park_(Hongkong)">Victoria Park</a> to Government Headquarters for the 2006 demonstration as described by <span>Yip et al. (2010)</span>. A <a href="https://www.youtube.com/watch?v=8WQ2TAEquxM">youtube video</a> of the 2006 demonstration illustrates this better than words.</p>
Map Source: <a href="http://www.openstreetmap.org/#map=10/22.3810/114.1370">Open Street Map</a>
<p>
</p><p>In order to estimate the number of participants a <strong>two on-the-spot counting method</strong> was devised by <span>Yip et al. (2010)</span>: Two points along the march were selected as shown in the above map: Point A denotes the location after which an individual is counted as being part of the march. In order to take into account that people join the march at a later point than A, a second point B is selected to adjust the count at A for such late entries. Three to four persons were stationed at each of the two counting locations. Once the demonstration passed the respective point each of them started to count the number of people passing in a one-minute intervals. They counted for one minute every 5 minutes until the last person of the march had passed the counting point.</p>
<h3>Loading the Data</h3>
<p>We store the resulting counting data displayed in Table 2 and Table 3 of <span>Yip et al. (2010)</span> as two Excel-files. In a data pre-processing step these are then read and combined into one data.frame containing the columns <code>Y1</code>-<code>Y4</code>. Furthermore, we re-format the table's time specification to proper POSIX formatted date-times. The exact data dancing steps can be found in the accompanying <a href="https://github.com/hoehleatsu/hoehleatsu.github.io/blob/master/_source/2017-05-04-crowdsize.Rmd">Rmd code of this post</a>. Altogether, this yields a <code>tbl</code> with the first couple of lines looking as follows:</p>
<pre><code>## # A tibble: 6 × 7
##      Y1    Y2    Y3    Y4     Mean Point          Time_POSIX
##   &lt;dbl> &lt;dbl> &lt;dbl> &lt;dbl>    &lt;dbl> &lt;chr>              &lt;dttm>
## 1   150    NA   160   180 163.3333     A 2006-07-01 15:55:00
## 2   308   360   250   280 299.5000     A 2006-07-01 16:00:00
## 3   430   350   300   270 337.5000     A 2006-07-01 16:05:00
## 4   210   280   240   252 245.5000     A 2006-07-01 16:10:00
## 5   130   216   200   180 181.5000     A 2006-07-01 16:15:00
## 6   210   260   300   280 262.5000     A 2006-07-01 16:20:00</code></pre>
<p>We then compute a number of row-wise statistics for all columns containing the counts - which columns contain the counts is specified by a regular expression <code>ccol_regexp</code>. In our case would be <code>&quot;^Y[0-9]+&quot;</code>.</p>
<h3>Descriptive Statistics</h3>
<p>The counts of the 4 counters at point A and the 3 counters at point B are summarized in the following small table:</p>
<table border="1,"><tr>
Point
n_counters
n_timepoints
sum_of_the_mean_counts
</tr><tr><td>
A
</td>
<td align="right">
4
</td>
<td align="right">
22
</td>
<td align="right">
4849.50
</td>
</tr><tr><td>
B
</td>
<td align="right">
3
</td>
<td align="right">
26
</td>
<td align="right">
4746.67
</td>
</tr></table>
<p>
</p><p>A time series for the individual counts as well as their mean is shown below. One observes that at point B the intensity of the crowd was lower, as the observation had stretched over a larger distance. The later is seen from the time span between the first and last count for the two points: approximately 1:45h for A vs. 2:45h for B.</p>
<p></p>
<h2>Two On-the-Spot Counting Method</h2>
<p>Below we give the mathematical details of the two on-the-spot counting method. Consider the counting point <span>\(X\)</span> of the march, i.e. <span>\(X\in \{A,B\}\)</span>. Let <span>\(m_X\)</span> be the number of counters at this point. Assume that the first people of the march pass <span>\(X\)</span> at time point <span>\(a_X\)</span> and that last people of the march reach <span>\(X\)</span> at time point <span>\(e_X\)</span>. The time unit could for example be minutes. Counting is done such that at regular intervals <span>\(c\)</span> one counts all people passing the point of observation within a time block of 1 unit - say 1 minute. Let <span>\(k_X\)</span> denote the number of time points where observations are available at <span>\(X\)</span>. Hence, the <span>\(k_X\)</span> observations at <span>\(X\)</span> are available for the time points <span>\(a_X,a_X+c,a_X+2c,a_X+(k_X-1)c\)</span>. Denote by <span>\(Y_{X,j}(t)\)</span> the <span>\(j\)</span>'th person's count at time <span>\(t\)</span>. Then</p>
<p><span>\[\overline{Y}_X(t) = \frac{1}{m_X} \sum_{i=1}^{m_X} Y_{X,i}(t)\]</span></p>
<p>is the average of the observer's counts at point <span>\(X\)</span> for time <span>\(t\)</span>. By scaling up each observer's observations to account for the time blocks without a count and averaging over the different observers we get an estimate for the number of participants at point <span>\(X\)</span>:</p>
<p><span>\[ \hat{N}_X = \frac{e_X}{k_X} \sum_{j=1}^{k_X} \overline{Y}_X(a_X +
(j-1)c).\]</span></p>
<p>In most cases one would have that <span>\(e_X/k_X=c\)</span>. If a counter thus counts 200 people for every 1-minute-counting-block during two-hours, i.e. corresponding to 24 observations - one every five minutes, her estimate for <span>\(N_X\)</span> would be 200<span>\(\cdot\)</span> 24<span>\(\cdot\)</span> 5= 24000.</p>
<p>In order to adjust the estimate at point <span>\(A\)</span> for people who joined the march after point <span>\(A\)</span>, we perform an independent counting at point <span>\(B\)</span> and additionally ask <span>\(m\)</span> people at point <span>\(A\)</span>, whether they marched past point <span>\(A\)</span> or not. Denoting <span>\(\hat{\phi}\)</span> the fraction of people answering yes to this question the <strong>two on-the-spot counting estimator</strong> is <span>\[
\hat{N} = \hat{N}_A + (1-\hat{\phi}) \hat{N}_B.
\]</span> Note that this estimator does not take into account that people could potentially leave the march between <span>\(A\)</span> and <span>\(B\)</span> and that its also possible to join the march after <span>\(B\)</span>. However, the proportion of such participants is assumed to be negligible.</p>
<p>A confidence interval (CI) based on an asymptotic normal assumption can be obtained by deriving that <span>\[
\operatorname{se}(\hat{N}) =
\sqrt{\widehat{\operatorname{Var}}(\hat{N}_A) + (1-\hat{\phi})^2
\widehat{\operatorname{Var}}(\hat{N}_B) + \hat{N}_B^2
\frac{\hat{\phi}(1-\hat{\phi})}{m}},
\]</span> where we have used that <span>\[
\widehat{\operatorname{Var}}(\hat{N}_X) =
\frac{e_X^2}{k_X^2} \sum_{j=1}^{k_X}
\widehat{\operatorname{Var}}(\overline{Y}_X(a_X + (j-1)c)) =
\frac{e_X^2}{k_X^2} \sum_{j=1}^{k_X}
\frac{\widehat{\operatorname{Var}}(Y_X(a_X + (j-1)c))}{m_X}
\]</span> and <span>\[
\widehat{\operatorname{Var}}(Y_X(t)) =
\frac{1}{m_X-1}\sum_{i=1}^{m_X} (Y_{X,i}(t) - \overline{Y}_X(t)).
\]</span></p>
<p>A two-sided <span>\((1-\alpha)\cdot 100\%\)</span> CI is then constructed as <span>\(\hat{N} \pm z_{1-\alpha/2} \operatorname{se}(\hat{N})\)</span>. Since <span>\(N\)</span> is expected to be at least of moderate size before one bothers counting this asymptotic CI should have decent coverage.</p>
<h3>Implementation in R</h3>
<p>The above equations have been implemented as function <code>two_on_the_spot_N</code> in R, which given a <code>counts</code> data.frame computes the estimate and an corresponding confidence interval. The github code of this post contains the details.</p>
<div><pre><code><span>args</span>(two_on_the_spot_N)</code></pre></div>
<pre><code>## function (counts, ccol_regexp = &quot;^Y[0-9]+&quot;, phi_estim, c = 5, 
##     conf.level = 0.95) 
## NULL</code></pre>
<p>Among 480 interviewed persons at point B, 437 reported to also have passed point A. In other words <span>\(\hat{\phi}\)</span>=91% and we obtain <span>\(\hat{N}\)</span> as follows with R:</p>
<div><pre><code>##Compute the two on the spot estimate based on the data in counts
N &lt;-<span> </span><span>two_on_the_spot_N</span>(counts, <span>phi_estim=</span><span>c</span>(<span>437</span>,<span>480</span>),<span>conf.level=</span><span>0.95</span>)

##Rounded version
<span>with</span>(N, <span>round</span>(<span>c</span>(<span>estimate=</span>estimate,ci)/<span>100</span>)*<span>100</span>)</code></pre></div>
<pre><code>## estimate ci_lower ci_upper 
##    26400    25600    27200</code></pre>
<p>Our estimate for the number of participants is thus around 26400 with a 95% confidence interval of 25600-27200. For comparison the author's state that the Hong Kong Police estimate was around 28000 whereas the organizers claimed a size of 58000.</p>
<h2>Discussion</h2>
<p>We were able to reproduce the results of <span>Yip et al. (2010)</span> using the article's data (up to some rounding issues). An R function is now available for supporting mobile crowd estimation in the future. It will be interesting to data synthesize such traditional counting approaches with more modern data sources such as mobile phone or twitter data <span>(Botta, Moat, and Preis 2015)</span>.</p>
<p><br><a href="https://en.wikipedia.org/wiki/File:Hong_Kong_1_July_march.jpg">Picture Source</a>: Ding Yuin Shan, Hong Kong, licensed under the Creative Commons Attribution 2.0 Generic license.</p>
<div align="right">
<p>QED.</p>
</div>
<h2>References</h2>
<div>
<div>
<p>Botta, Federico, Helen Susannah Moat, and Tobias Preis. 2015. “Quantifying Crowd Size with Mobile Phone and Twitter Data.” Royal Society Open Science 2 (5). The Royal Society. doi:<a href="https://doi.org/10.1098/rsos.150162">10.1098/rsos.150162</a>.</p>
</div>
<div>
<p>Watson, Ray, and Paul Yip. 2011. “How Many Were There When It Mattered?” Significance 8 (3): 104–7. doi:<a href="https://doi.org/10.1111/j.1740-9713.2011.00502.x">10.1111/j.1740-9713.2011.00502.x</a>.</p>
</div>
<div>
<p>Yip, Paul S. F., Ray Watson, K. S. Chan, Eric H. Y. Lau, Feng Chen, Ying Xu, Liqun Xi, Derek Y. T. Cheung, Brian Y. T. Ip, and Danping Liu. 2010. “Estimation of the Number of People in a Demonstration.” Australian &amp; New Zealand Journal of Statistics 52 (1). Blackwell Publishing Asia: 17–26. doi:<a href="https://doi.org/10.1111/j.1467-842X.2009.00562.x">10.1111/j.1467-842X.2009.00562.x</a>.</p>
</div></div>