Skip to content

Instantly share code, notes, and snippets.

@prabhasp
Last active December 11, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prabhasp/4529702 to your computer and use it in GitHub Desktop.
Save prabhasp/4529702 to your computer and use it in GitHub Desktop.
Coverage analysis for Nigeria -- generated by Rmarkdown.
<p><link href="http://kevinburke.bitbucket.org/markdowncss/markdown.css" rel="stylesheet"></link></p>
<h1>Coverage gap analysis (without facility lists) for Baseline Facility Inventory</h1>
<p>This is an attempt to figure out whether any lessons on baseline facility inventory coverage gaps can be identified without the use of facility lists, which will ultimately needed for a proper analysis of gap coverage.</p>
<p>However, we can do a very simple analysis to identify lgas which have very few facilities collected, or which have very few facilities collected given the population of the LGA. We will do this analysis for 147 LGAs for which the CGS planning/granting process will take place in 2013.</p>
<p>The analysis follows. First we load and prepare our datasets.</p>
<pre><code class="r">library(plyr)
library(stringr)
library(ggplot2)
one47 &lt;- read.csv(&quot;147_final_list.csv&quot;)
one47 &lt;- merge(one47, read.csv(&quot;population_774.csv&quot;), by = &quot;X_lga_id&quot;)
e &lt;- read.csv(&quot;in_process_data/merged/Education_661_Merged.csv&quot;)
h &lt;- read.csv(&quot;in_process_data/merged/Health_661_Merged.csv&quot;)
e &lt;- subset(e, select = c(&quot;mylga&quot;, &quot;mylga_state&quot;, &quot;mylga_zone&quot;, &quot;unique_lga&quot;,
&quot;X_lga_id&quot;, &quot;level_of_education&quot;, &quot;school_managed&quot;, &quot;school_name&quot;))
h &lt;- subset(h, select = c(&quot;mylga&quot;, &quot;mylga_state&quot;, &quot;mylga_zone&quot;, &quot;unique_lga&quot;,
&quot;X_lga_id&quot;, &quot;facility_type&quot;, &quot;facility_owner_manager.private_forprofit&quot;))
e147 &lt;- merge(e, one47, by = &quot;X_lga_id&quot;, all.x = F)
h147 &lt;- merge(h, one47, by = &quot;X_lga_id&quot;, all.x = F)
etots &lt;- merge(ddply(e147, .(X_lga_id), nrow), one47, by = &quot;X_lga_id&quot;,
all.y = T)
names(etots) &lt;- replace(names(etots), names(etots) == &quot;V1&quot;, &quot;Total&quot;)
etots$TotalByPopulation &lt;- etots$Total/etots$Population
htots &lt;- merge(ddply(h147, .(X_lga_id), nrow), one47, by = &quot;X_lga_id&quot;,
all.y = T)
names(htots) &lt;- replace(names(htots), names(htots) == &quot;V1&quot;, &quot;Total&quot;)
htots$TotalByPopulation &lt;- htots$Total/htots$Population
</code></pre>
<h1>Some LGAs missing data entirely</h1>
<p>We find, right away, that 3 facility for health and 4 for education has no data among the 147 LGAs for the initial granting process.</p>
<pre><code class="r">print(str_c(&quot;Education has data for &quot;, length(levels(as.factor(h147$X_lga_id))),
&quot; / 147 lgas&quot;)) #TODO: print exactly what LGAs missing
</code></pre>
<pre><code>## [1] &quot;Education has data for 143 / 147 lgas&quot;
</code></pre>
<pre><code class="r">print(str_c(&quot;Health has data for &quot;, length(levels(as.factor(e147$X_lga_id))),
&quot; / 147 lgas&quot;)) #TODO: print exactly what LGAs missing
</code></pre>
<pre><code>## [1] &quot;Health has data for 144 / 147 lgas&quot;
</code></pre>
<h1>Education &ndash; low facility numbers, and low facility count per population</h1>
<p>Lets start with education, and plot the number of facilities in an LGA, separated by zone:</p>
<pre><code class="r">qplot(data = etots, x = zone, y = Total) + geom_point()
</code></pre>
<pre><code>## Warning message: Removed 3 rows containing missing values (geom_point).
</code></pre>
<pre><code>## Warning message: Removed 3 rows containing missing values (geom_point).
</code></pre>
<p><img src="figure/unnamed-chunk-3.png" alt="plot of chunk unnamed-chunk-3"/> </p>
<p>This allows us to start noting LGAs with a very low number of facilities compared to the rest. By simply eye-balling, we can establish the following cutoffs per zone:</p>
<ul>
<li>north_central: 80</li>
<li>northeast: 55</li>
<li>northwest: 50</li>
<li>south_south: 40</li>
<li>southeast: 50</li>
<li>southwest: 60</li>
</ul>
<p>After that, we need to check the facility count per population. Here, let me present a slightly zoomed in view of the data:</p>
<pre><code class="r">qplot(data = etots, x = zone, y = TotalByPopulation) + geom_point() +
coord_cartesian(ylim = c(0, 0.001))
</code></pre>
<pre><code>## Warning message: Removed 3 rows containing missing values (geom_point).
</code></pre>
<pre><code>## Warning message: Removed 3 rows containing missing values (geom_point).
</code></pre>
<p><img src="figure/unnamed-chunk-4.png" alt="plot of chunk unnamed-chunk-4"/> </p>
<p>Again, eyeballing, we come up with the cutoffs:<br/>
* .0004: north_central<br/>
* .0002: northeast, northwest, south_south, and southeast<br/>
* 0.0003: southeast</p>
<p>Programming the cutoffs in, we see that the following LGAs might need to be re-surveyed</p>
<pre><code class="r">education_to_review &lt;- subset(etots, (zone == &quot;north_central&quot; &amp; (is.na(Total) |
Total &lt;= 80 | TotalByPopulation &lt;= 4e-04)) | (zone == &quot;northeast&quot; &amp; (is.na(Total) |
Total &lt;= 55 | TotalByPopulation &lt;= 2e-04)) | (zone == &quot;northwest&quot; &amp; (is.na(Total) |
Total &lt;= 50 | TotalByPopulation &lt;= 2e-04)) | (zone == &quot;south_south&quot; &amp; (is.na(Total) |
Total &lt;= 40 | TotalByPopulation &lt;= 2e-04)) | (zone == &quot;southeast&quot; &amp; (is.na(Total) |
Total &lt;= 50 | TotalByPopulation &lt;= 2e-04)) | (zone == &quot;southwest&quot; &amp; (is.na(Total) |
Total &lt;= 60 | TotalByPopulation &lt;= 3e-04)))
subset(education_to_review[order(-education_to_review$Total), ],
select = c(&quot;zone&quot;, &quot;state&quot;, &quot;lga&quot;, &quot;Total&quot;, &quot;TotalByPopulation&quot;))
</code></pre>
<pre><code>## zone state lga Total TotalByPopulation
## 96 north_central Nasarawa Nasarawa 173 2.899e-04
## 5 southwest Lagos Ajeromi-Ifelodun 154 2.251e-04
## 3 southwest Ogun Ado Odo/Ota 142 2.697e-04
## 97 north_central Nasarawa Nasarawa Eggon 78 5.230e-04
## 116 north_central Kwara Oke-Ero 70 1.215e-03
## 4 north_central Niger Agwara 64 1.115e-03
## 41 north_central Kwara Ekiti 59 1.076e-03
## 118 southwest Osun Ola-Oluwa 58 7.572e-04
## 131 northeast Gombe Shongom 52 3.432e-04
## 80 northwest Jigawa Kiyawa 49 2.834e-04
## 84 northwest Kaduna Kudan 49 3.525e-04
## 13 southeast Abia Arochukwu 45 2.644e-04
## 103 southeast Enugu Nkanu East 44 2.958e-04
## 39 southwest Ekiti Efon 40 4.601e-04
## 76 northwest Kebbi Kalgo 39 4.567e-04
## 73 southeast Imo Isu 38 2.310e-04
## 22 north_central Kogi Bassa 37 2.643e-04
## 145 northeast Taraba Yorro 37 4.138e-04
## 130 northeast Bauchi Shira 36 1.538e-04
## 134 northeast Yobe Tarmuwa 36 4.663e-04
## 35 northeast Borno Dikwa 31 2.927e-04
## 8 southeast Anambra Anambra East 28 1.826e-04
## 56 northwest Kaduna Giwa 27 9.426e-05
## 58 northwest Sokoto Gudu 26 2.721e-04
## 47 south_south Akwa Ibom Esit Eket 24 3.768e-04
## 54 northeast Yobe Geidam 22 1.399e-04
## 140 southeast Abia Ukwa East 22 3.737e-04
## 57 northeast Borno Gubio 21 1.375e-04
## 53 northeast Taraba Gassol 20 8.172e-05
## 63 southwest Osun Ifedayo 17 4.587e-04
## 92 northeast Borno Mobbar 16 1.372e-04
## 61 south_south Akwa Ibom Ibiono Ibom 14 7.382e-05
## 139 south_south Akwa Ibom Udung Uko 14 2.628e-04
## 110 south_south Rivers Ogu/Bolo 13 1.741e-04
## 146 northeast Yobe Yusufari 13 1.170e-04
## 30 northeast Borno Chibok 2 3.025e-05
## 31 northeast Borno Damboa NA NA
## 121 southeast Edo Ovia South NA NA
## 128 northeast Taraba Sardauna NA NA
</code></pre>
<h1>Health &ndash; low facility numbers, and low facility count per population</h1>
<p>Similarly for health, we start by plotting the facility counts and facility count per population:</p>
<pre><code class="r">qplot(data = etots, x = zone, y = Total) + geom_point()
</code></pre>
<pre><code>## Warning message: Removed 3 rows containing missing values (geom_point).
</code></pre>
<pre><code>## Warning message: Removed 3 rows containing missing values (geom_point).
</code></pre>
<p><img src="figure/unnamed-chunk-61.png" alt="plot of chunk unnamed-chunk-6"/> </p>
<pre><code class="r">qplot(data = htots, x = zone, y = TotalByPopulation) + geom_point() +
coord_cartesian(ylim = c(0, 5e-04))
</code></pre>
<pre><code>## Warning message: Removed 4 rows containing missing values (geom_point).
</code></pre>
<pre><code>## Warning message: Removed 4 rows containing missing values (geom_point).
</code></pre>
<p><img src="figure/unnamed-chunk-62.png" alt="plot of chunk unnamed-chunk-6"/> </p>
<p>And we come up with the cut-offs<br/>
* north_central: Total &lt;= 35 | TotalByPopulation &lt;= 0.00025<br/>
* northeast: Total &lt;= 35 | TotalByPopulation &lt;= 0.00015 <br/>
* northwest: Total &lt;= 20 | TotalByPopulation &lt;= 0.0001<br/>
* south_south: Total &lt;= 10 | TotalByPopulation &lt;= 0.0001 <br/>
* southeast: Total &lt;= 10 | TotalByPopulation &lt;= 0.00011<br/>
* southwest: Total &lt;= 20 | TotalByPopulation &lt;= 0.0001</p>
<p>Programming the cutoffs in, we see that the following LGAs might need to be re-surveyed</p>
<pre><code class="r">health_to_review &lt;- subset(htots, (zone == &quot;north_central&quot; &amp; (is.na(Total) |
Total &lt;= 35 | TotalByPopulation &lt;= 0.00025)) | (zone == &quot;northeast&quot; &amp; (is.na(Total) |
Total &lt;= 35 | TotalByPopulation &lt;= 0.00015)) | (zone == &quot;northwest&quot; &amp; (is.na(Total) |
Total &lt;= 20 | TotalByPopulation &lt;= 1e-04)) | (zone == &quot;south_south&quot; &amp; (is.na(Total) |
Total &lt;= 10 | TotalByPopulation &lt;= 1e-04)) | (zone == &quot;southeast&quot; &amp; (is.na(Total) |
Total &lt;= 10 | TotalByPopulation &lt;= 0.00011)) | (zone == &quot;southwest&quot; &amp; (is.na(Total) |
Total &lt;= 20 | TotalByPopulation &lt;= 1e-04)))
subset(health_to_review[order(-health_to_review$Total), ], select = c(&quot;zone&quot;,
&quot;state&quot;, &quot;lga&quot;, &quot;Total&quot;, &quot;TotalByPopulation&quot;))
</code></pre>
<pre><code>## zone state lga Total TotalByPopulation
## 96 north_central Nasarawa Nasarawa 71 1.190e-04
## 119 north_central Benue Okpokwu 42 2.378e-04
## 5 southwest Lagos Ajeromi-Ifelodun 40 5.847e-05
## 67 north_central Kwara Ilorin East 38 1.860e-04
## 4 north_central Niger Agwara 32 5.574e-04
## 94 northeast Gombe Nafada 25 1.809e-04
## 134 northeast Yobe Tarmuwa 23 2.979e-04
## 22 north_central Kogi Bassa 22 1.572e-04
## 91 northwest Kano Minjibir 21 9.823e-05
## 39 southwest Ekiti Efon 20 2.300e-04
## 41 north_central Kwara Ekiti 20 3.646e-04
## 89 northwest Jigawa Maigatari 20 1.113e-04
## 116 north_central Kwara Oke-Ero 20 3.471e-04
## 28 northwest Kano Bunkure 19 1.112e-04
## 40 south_south Bayelsa Ekeremor 19 7.030e-05
## 60 northeast Taraba Ibi 19 2.260e-04
## 137 northwest Sokoto Tureta 19 2.779e-04
## 143 northwest Kano Warawa 19 1.475e-04
## 54 northeast Yobe Geidam 18 1.144e-04
## 62 southwest Oyo Ido 18 1.743e-04
## 76 northwest Kebbi Kalgo 18 2.108e-04
## 93 northeast Adamawa Mubi North 18 1.191e-04
## 35 northeast Borno Dikwa 17 1.605e-04
## 130 northeast Bauchi Shira 17 7.265e-05
## 145 northeast Taraba Yorro 17 1.901e-04
## 109 south_south Bayelsa Obalga 16 8.893e-05
## 117 south_south Rivers Okrika 16 7.206e-05
## 19 northwest Kano Bagwai 15 9.211e-05
## 103 southeast Enugu Nkanu East 15 1.008e-04
## 14 south_south Rivers Asari-Toru 14 6.361e-05
## 74 southwest Oyo Iwajowa 12 1.165e-04
## 115 north_central Kogi Okehi 12 6.000e-05
## 58 northwest Sokoto Gudu 11 1.151e-04
## 63 southwest Osun Ifedayo 11 2.968e-04
## 80 northwest Jigawa Kiyawa 10 5.783e-05
## 34 south_south Rivers Degema 9 3.603e-05
## 57 northeast Borno Gubio 9 5.891e-05
## 92 northeast Borno Mobbar 9 7.715e-05
## 47 south_south Akwa Ibom Esit Eket 8 1.256e-04
## 8 southeast Anambra Anambra East 7 4.565e-05
## 139 south_south Akwa Ibom Udung Uko 7 1.314e-04
## 61 south_south Akwa Ibom Ibiono Ibom 6 3.164e-05
## 110 south_south Rivers Ogu/Bolo 6 8.034e-05
## 53 northeast Taraba Gassol 5 2.043e-05
## 56 northwest Kaduna Giwa 5 1.746e-05
## 146 northeast Yobe Yusufari 5 4.501e-05
## 30 northeast Borno Chibok NA NA
## 31 northeast Borno Damboa NA NA
## 121 southeast Edo Ovia South NA NA
## 128 northeast Taraba Sardauna NA NA
</code></pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment