-
Notifications
You must be signed in to change notification settings - Fork 0
/
notesAnalysisPNG.Rmd
1742 lines (1430 loc) · 65.2 KB
/
notesAnalysisPNG.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Notes on data processing and analysis of available Papua New Guinea datasets"
author: "Ernest Guevarra"
date: "16/08/2018"
output: pdf_document
geometry: margin=2cm
classoption: a4paper
fontsize: 12pt
highlight: tango
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
#
# Require maptools, rgeos, rgdal, raster
#
if(!require(maptools, quietly = TRUE)) install.packages("maptools") # If maptools required but not installed, install
if(!require(rgeos, quietly = TRUE)) install.packages("rgeos") # If rgeos required but not installed, install
if(!require(rgdal, quietly = TRUE)) install.packages("rgdal") # If rgdal required but not installed, install
if(!require(raster, quietly = TRUE)) install.packages("raster") # If raster required but not installed, install
if(!require(readxl)) install.packages("readxl") # to read Excel files
if(!require(stringr)) install.packages("stringr") # to manipulate strings
if(!require(ggplot2)) install.packages("ggplot2") # for plotting
if(!require(zoo)) install.packages("zoo") # for dates
if(!require(dplyr)) install.packages("dplyr") # for data manipulation
if(!require(tidyr)) install.packages("tidyr") # for data manipulation
if(!require(classInt)) install.packages("classInt") # for classifying for mapping
#
# install papuanewguinea R package from OMNeoHealth Github; devtools
#
if(!require(devtools, quietly = TRUE)) install.packages("devtools") # If devtools required but not installed, install
install_github("OMNeoHealth/papuanewguinea") # Install OMNeoHealth/papuanewguinea from GitHub
library(papuanewguinea) # Load papuanewguinea package
```
# 1. Processing and preparing data for analysis and mapping
Given Microsoft Excel files containing data from the Papua New Guinea NHIS per month for 2015 and 2016, we would like to read each of these files and then concatenate them into a single dataset. This can be done in R as follows:
```{r, echo = TRUE, eval = TRUE}
#
# Get the filenames of all .XLSX files in folder named "data"
#
fileNames <- list.files(path = "data/")
#
# Create a concatenating object
#
png_maternal <- NULL
#
# Loop through each of the XLSX files in data and read them
#
for(i in fileNames) {
#
# Use read_xlsx() to read current filename
#
temp <- read_xlsx(path = paste("data/", i, sep = ""),
col_names = FALSE,
skip = 3)
#
# extract month of current data
#
month <- str_split(string = i, pattern = " ")[[1]][1]
#
# extract year of current data
#
year <- str_split(string = str_split(string = i, pattern = " ")[[1]][2],
pattern = ".xlsx")[[1]][1]
#
# Add month variable to temp dataset
#
temp$month <- month
#
# Add year variable to temp dataset
#
temp$year <- year
#
# concatenate current dataset with png_maternal
#
png_maternal <- data.frame(rbind(png_maternal, temp))
}
```
This results in a data frame object called `png_maternal` with `r ncol(png_maternal)` columns and `r nrow(png_maternal)` rows. The resulting data frame is as follows (first 60 rows):
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = png_maternal[1:60, ],
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped", "scale_down"),
position = "center") %>%
kableExtra::landscape()
```
The object `png_maternal` lacks meaningful column names. Also, it would be good to create codes corresponding to the province code and district codes from the code specified in the first column of `png_maternal`. These can be processed in R as follows:
```{r, echo = TRUE, eval = TRUE}
################################################################################
#
# Get province, district and facility codes
#
################################################################################
#
# Extract first two digits from code
#
png_maternal$pcode <- floor(png_maternal$X__1 / 10000)
#
# pad the pcode with a 0 at the start
#
png_maternal$pcode <- str_pad(string = png_maternal$pcode,
width = 2, side = "left", pad = "0")
#
# Extract first 4 digits from code
#
png_maternal$dcode <- floor(png_maternal$X__1 / 100)
#
# pad the dcode with a 0 at the start
#
png_maternal$dcode <- str_pad(string = png_maternal$dcode,
width = 4, side = "left", pad = "0")
#
# pad the code with a 0 at the start
#
png_maternal$X__1 <- str_pad(string = png_maternal$X__1,
width = 6, side = "left", pad = "0")
################################################################################
#
# Created codebook for PNG maternal mortality data
#
################################################################################
longName <- c("Five to six-digit facility code",
"Name of facility",
"Report recieved? 1 = YES; 2 = NO",
"New attendance breastfeeding pills",
"New attendance combined pills",
"New attendance injection",
"Unkown Number 1",
"Permanent vasectomy",
"New attendance IUD",
"New attendance ovulation",
"New attendance condom",
"Re-attendance breastfeeding pills",
"Re-attendance combined pills",
"Re-attendance injection",
"Re-attendance IUD",
"Re-attendance ovulation",
"Re-attendance condom",
"Antenatal first visit",
"Antenatal fourth visit",
"Antenatal other",
"Antenatal TT1",
"Antenatal TT2",
"Antenatal booster",
"Unknown Number 2",
"Deliveries in health facility",
"Maternal deaths in facility",
"Birthweight less than 2500 grams",
"Stillbirths",
"Village births supervised",
"Village births complications",
"Born before arrival",
"Delivery complications",
"Maternal deaths not in facility",
"Transferred to hospital",
"Month",
"Year",
"Province code",
"District code")
shortName <- c("code", "facility", "report",
"bfpills1", "combpills1", "inj1", "uno1", "vasectomy", "iud1",
"ovulation1", "condom1", "bfpills2", "combpills2", "inj2",
"iud2", "ovulation2", "condom2", "anc1", "anc4", "ancother",
"tt1", "tt2", "ttbooster", "uno2", "delhf", "deadhf", "lbw",
"still", "vbsup", "vbcomp", "bba", "delcomp", "deadnothf",
"transhop", "month", "year", "pcode", "dcode")
names(png_maternal) <- shortName
```
Checking `png_maternal` object again, we see that the columns have been labelled with more meaningful names and corresponding province and district codes have been added.
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = png_maternal[1:60, ],
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped", "scale_down"),
position = "center") %>%
kableExtra::landscape()
```
## a. Processing `png_maternal` to create datasets that can be mapped
Further processing of `png_maternal` can be done to allow for mapping of the data at province and district level.
Province level data can be produced from `png_maternal` as follows:
```{r, echo = TRUE, eval = TRUE}
#
# Aggregate data by province and per year
#
provincedata <- aggregate(
cbind(bfpills1, combpills1, inj1, uno1, vasectomy, iud1, ovulation1,
condom1, bfpills2, combpills2, inj2, iud2, ovulation2, condom2,
anc1, anc4, ancother, tt1, tt2, ttbooster, uno2,
delhf, deadhf, lbw, still, vbsup, vbcomp, bba,
delcomp, deadnothf, transhop) ~ pcode + year,
data = png_maternal, FUN = sum)
```
This produces a data frame object named `provincedata`.
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = provincedata[1:60, ],
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped", "scale_down"),
position = "center") %>%
kableExtra::landscape()
```
District level data can be produced from `png_maternal` as follows:
```{r, echo = TRUE, eval = TRUE}
#
# Aggregate data by district and per year
#
districtdata <- aggregate(
cbind(bfpills1, combpills1, inj1, uno1, vasectomy, iud1, ovulation1,
condom1, bfpills2, combpills2, inj2, iud2, ovulation2, condom2,
anc1, anc4, ancother, tt1, tt2, ttbooster, uno2,
delhf, deadhf, lbw, still, vbsup, vbcomp, bba,
delcomp, deadnothf, transhop) ~ dcode + year,
data = png_maternal, FUN = sum)
```
This produces a data frame object named `districtdata`.
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = districtdata[1:60, ],
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped", "scale_down"),
position = "center") %>%
kableExtra::landscape()
```
To be able to use `provincedata` and `districtdata`, we will need to standardise the raw counts. The usual way to standardise is by calculating rates usually expressed per 10,000 or per 100,000 of a particular population. However, data on specific populations required for the indicators of interest are not available.
As an alternative, we can use available population data per province and per district as a standardising factor to be able to compare the raw counts with each other. It should be made clear that these are not the same as the standard rates hence are not comparable to those. However, standardised values will allow comparison of values across provinces and districts to show general trends rather than on specific absolute values.
Population data at province and district level of Papua New Guinea is available via the `papuanewguinea` R package. Province population data can be accessed in R via a call to `pop_adm1`. District population data can be accessed in R via a call to `pop_adm2`.
The data frame `pop_adm1` is as follows:
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = pop_adm1,
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped", "scale_down"),
position = "center")
```
\newpage
The data frame `pop_adm2` is as follows:
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = pop_adm2,
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped", "scale_down"),
position = "center")
```
We will need to extract the appropriate information from these population datasets to use for standardising the raw counts. For the type of indicators we will be looking at, the data on population of women of reproductive age would be the most appropriate. This is the data identified as `WRA` in the population datasets.
The most efficient way to work with this population data and the province and district data we produced awhile ago will be to extract the population of women of reproductive age and then attaching it to the province and district data accordingly.
To do this, we will first need to organise the population data in such a way that it can be merged with the province data.
First, we need to extract the data columns that we need from the population data. These will be the province name, the province code and the women of reproductive age population.
For the province population, this can be done as follows:
```{r, echo = TRUE, eval = TRUE}
wra_adm1 <- pop_adm1[ , c("ADM1_PCODE", "ADM1_EN", "WRA")]
```
This produces the following data frame object:
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = wra_adm1,
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped"),
position = "center")
```
For the district population, this can be done as follows:
```{r, echo = TRUE, eval = TRUE}
wra_adm2 <- pop_adm2[ , c("ADM2_PCODE", "ADM2_EN", "ADM1_PCODE", "ADM1_EN", "WRA")]
```
This produces the following data frame object:
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = wra_adm2[1:40, ],
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped", "scale_down"),
position = "center")
```
Then, we need to organise the population datasets such that the rows of data are in the same sequence as that of the province and district data. This means, the population datasets will have to be ordered in such a way that the province code and district code are sequential. We see that the population datasets are not sequential and as such will need to be re-ordered. This can be done in R as follows:
```{r, echo = TRUE, eval = TRUE}
wra_adm1 <- wra_adm1[order(wra_adm1$ADM1_PCODE), ]
wra_adm2 <- wra_adm2[order(wra_adm2$ADM2_PCODE), ]
```
We now need to adjust the admin codes to match the admin codes in the province and district data. We notice that the population admin codes start with `PG` whilst the province and district data don't have this. So, we should adjust the population codes by removing the appended `PG`. This can be done as follows:
```{r, echo = TRUE, eval = TRUE}
wra_adm1$ADM1_PCODE <- as.numeric(str_replace(wra_adm1$ADM1_PCODE, "PG", ""))
wra_adm2$ADM2_PCODE <- as.numeric(str_replace(wra_adm2$ADM2_PCODE, "PG", ""))
wra_adm2$ADM1_PCODE <- as.numeric(str_replace(wra_adm2$ADM1_PCODE, "PG", ""))
```
Once the admin codes have been adjusted, we should now calculate a standardising factor which we will call `sf`. Using the population size for women of reproductive age (WRA), we divide this by 100,000 to get a standardising factor that will give an indicator value that is per 100,000 WRA population. This can be done as follows:
```{r, echo = TRUE, eval = TRUE}
wra_adm1$sf <- wra_adm1$WRA / 100000
wra_adm2$sf <- wra_adm2$WRA / 100000
```
Once the standardising factor (`sf`) is calculated, the population data can now be merged with the province and district data respectively.
For the province data, this can be done in R as follows:
```{r, echo = TRUE, eval = TRUE}
provincedata <- merge(wra_adm1,
provincedata,
by.x = "ADM1_PCODE",
by.y = "pcode")
```
For the district data, we will need to do some processing of the district data because there are two additional districts for the National Capital District whilst in the population data and the map data, there is only one. This can be adjusted in such a way that we can collapse the district data for the National Capital District into a single district. This can be done as follows:
```{r, echo = TRUE, eval = TRUE}
x <- colSums(districtdata[districtdata$dcode %in% c(401, 402, 403) &
districtdata$year == 2015, ])
y <- colSums(districtdata[districtdata$dcode %in% c(401, 402, 403) &
districtdata$year == 2016, ])
xy <- rbind(x, y)
xy[1,1] <- 401
xy[2,1] <- 401
xy[1,2] <- 2015
xy[2,2] <- 2016
districtdata <- data.frame(rbind(
districtdata[!districtdata$dcode %in% c(401, 402, 403), ], xy))
```
Once the district data has been adjusted, we can now merge the district data with the district population data. This can be done in R as follows:
```{r, echo = TRUE, eval = TRUE}
districtdata <- merge(wra_adm2,
districtdata,
by.x = "ADM2_PCODE",
by.y = "dcode")
```
We now have processed datasets for province and district data that has all the information needed to produce various analysis outputs.
## b. Processing `png_maternal` to create datasets that can be used for time series analysis
Further processing of `png_maternal` can be done to allow for time series analysis of the data at monthly intervals for year 2015 and 2016.
Monthly province level data can be produced from `png_maternal` as follows:
```{r, echo = TRUE, eval = TRUE}
#
# Aggregate data by month and per year
#
mProvince <- aggregate(
cbind(bfpills1, combpills1, inj1, uno1, vasectomy, iud1, ovulation1,
condom1, bfpills2, combpills2, inj2, iud2, ovulation2, condom2,
anc1, anc4, ancother, tt1, tt2, ttbooster, uno2,
delhf, deadhf, lbw, still, vbsup, vbcomp, bba,
delcomp, deadnothf, transhop) ~ month + pcode + year,
data = png_maternal, FUN = sum)
```
This produces a data frame object named `mProvince`.
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = mProvince[1:60, ],
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped", "scale_down"),
position = "center") %>%
kableExtra::landscape()
```
Monthly district level data can be produced from `png_maternal` as follows:
```{r, echo = TRUE, eval = TRUE}
#
# Aggregate data by district and per year
#
mDistrict <- aggregate(
cbind(bfpills1, combpills1, inj1, uno1, vasectomy, iud1, ovulation1,
condom1, bfpills2, combpills2, inj2, iud2, ovulation2, condom2,
anc1, anc4, ancother, tt1, tt2, ttbooster, uno2,
delhf, deadhf, lbw, still, vbsup, vbcomp, bba,
delcomp, deadnothf, transhop) ~ month + dcode + year,
data = png_maternal, FUN = sum)
```
This produces a data frame object named `mDistrict`.
```{r, echo = FALSE, eval = TRUE}
knitr::kable(x = mDistrict[1:60, ],
booktabs = TRUE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("HOLD_position", "striped", "scale_down"),
position = "center") %>%
kableExtra::landscape()
```
We can then merge these datasets with the population data that contains the standardising factor. This can be done as follows:
```{r, echo = FALSE, eval = TRUE}
mProvince$pcode <- as.numeric(mProvince$pcode)
```
```{r, echo = TRUE, eval = TRUE}
mProvince <- merge(wra_adm1, mProvince, by.x = "ADM1_PCODE", by.y = "pcode")
```
For the district data, we will need to make the same adjustments we did to the district data. This can be done as follows:
```{r, echo = FALSE, eval = TRUE}
mDistrict$dcode <- as.numeric(mDistrict$dcode)
mDistrict$year <- as.numeric(mDistrict$year)
```
```{r, echo = TRUE, eval = TRUE}
x <- aggregate(
cbind(dcode, year, bfpills1, combpills1, inj1, uno1, vasectomy, iud1,
ovulation1, condom1, bfpills2, combpills2, inj2, iud2, ovulation2,
condom2, anc1, anc4, ancother, tt1, tt2, ttbooster, uno2,
delhf, deadhf, lbw, still, vbsup, vbcomp, bba, delcomp, deadnothf,
transhop) ~ month,
data = mDistrict[mDistrict$dcode %in% c(401, 402, 403) &
mDistrict$year == 2015, ],
FUN = sum)
y <- aggregate(
cbind(dcode, year, bfpills1, combpills1, inj1, uno1, vasectomy, iud1,
ovulation1, condom1, bfpills2, combpills2, inj2, iud2, ovulation2,
condom2, anc1, anc4, ancother, tt1, tt2, ttbooster, uno2,
delhf, deadhf, lbw, still, vbsup, vbcomp, bba, delcomp, deadnothf,
transhop) ~ month,
data = mDistrict[mDistrict$dcode %in% c(401, 402, 403) &
mDistrict$year == 2016, ],
FUN = sum)
xy <- rbind(x, y)
xy$dcode <- 401
xy[ 1:12, 3] <- 2015
xy[13:24, 3] <- 2016
mDistrict <- data.frame(rbind(
mDistrict[!mDistrict$dcode %in% c(401, 402, 403), ], xy))
```
The resulting `mDistrict` data can now be merged with the district population data as follows:
```{r, echo = TRUE, eval = TRUE}
mDistrict <- merge(wra_adm2, mDistrict, by.x = "ADM2_PCODE", by.y = "dcode")
```
We now have processed datasets for time series province and district data that has all the information needed to produce various analysis outputs.
# 3. Indicators
Given the Papua New Guinea NHIS data, the following indicators can be possibly calculated:
* Number of pregnant women who has had at least one antenatal care visit (ANC) with a trained health worker per 100,000 women of reproductive age
$$\begin{aligned}
n_{anc1} & ~ \div ~ \frac{n_{WRA}}{100000}\\
\\
where: & \\
\\
n_{anc1} ~ = ~ & \text{Number of pregnant women who has had at least 1 ANC visit} \\
& \text{with a trained health worker} \\
n_{WRA} ~ = ~ & \text{Number of women of reproductive age}
\end{aligned}$$
* Number of pregnant women who has had at least four antenatal care visits (ANC) with any service provider per 100,000 women of reproductive age
$$\begin{aligned}
n_{anc4} & ~ \div ~ \frac{n_{WRA}}{100000}\\
\\
where: & \\
\\
n_{anc4} ~ = ~ & \text{Number of pregnant women who has had at least 4 ANC visits} \\
& \text{with any service provider} \\
n_{WRA} ~ = ~ & \text{Number of women of reproductive age}
\end{aligned}$$
* Number of pregnant women who received first tetanus toxoid vaccination per 100,000 women of reproductive age
$$\begin{aligned}
n_{tt1} & ~ \div ~ \frac{n_{WRA}}{100000}\\
\\
where: & \\
\\
n_{tt1} ~ = ~ & \text{Number of pregnant women who received} \\
& \text{first tetanus toxoid vaccination} \\
n_{WRA} ~ = ~ & \text{Number of women of reproductive age}
\end{aligned}$$
* Number of pregnant women who received second tetanus toxoid vaccination per 100,000 women of reproductive age
$$\begin{aligned}
n_{tt2} & ~ \div ~ \frac{n_{WRA}}{100000}\\
\\
where: & \\
\\
n_{tt2} ~ = ~ & \text{Number of pregnant women who received} \\
& \text{second tetanus toxoid vaccination} \\
n_{WRA} ~ = ~ & \text{Number of women of reproductive age}
\end{aligned}$$
* Number of pregnant women who received tetanus toxoid booster vaccination per 100,000 women of reproductive age
$$\begin{aligned}
n_{ttbooster} & ~ \div ~ \frac{n_{WRA}}{100000}\\
\\
where: & \\
\\
n_{ttbooster} ~ = ~ & \text{Number of pregnant women who received} \\
& \text{tetanus toxoid booster vaccination} \\
n_{WRA} ~ = ~ & \text{Number of women of reproductive age}
\end{aligned}$$
* Number of pregnant women who delivered in a health facility per 100,000 women of reproductive age
$$\begin{aligned}
n_{delhf} & ~ \div ~ \frac{n_{WRA}}{100000}\\
\\
where: & \\
\\
n_{delhf} ~ = ~ & \text{Number of pregnant women who delivered} \\
& \text{in a health facility} \\
n_{WRA} ~ = ~ & \text{Number of women of reproductive age}
\end{aligned}$$
* Number of pregnant women who delivered a low birth weight child per 100,000 women of reproductive age
$$\begin{aligned}
n_{lbw} & ~ \div ~ \frac{n_{WRA}}{100000}\\
\\
where: & \\
\\
n_{lbw} ~ = ~ & \text{Number of pregnant women who delivered} \\
& \text{a low birth weight child} \\
n_{WRA} ~ = ~ & \text{Number of women of reproductive age}
\end{aligned}$$
* Number of pregnant women who delivered a stillbirth per 100,000 women of reproductive age
$$\begin{aligned}
n_{still} & ~ \div ~ \frac{n_{WRA}}{100000}\\
\\
where: & \\
\\
n_{still} ~ = ~ & \text{Number of pregnant women who delivered} \\
& \text{a stillbirth} \\
n_{WRA} ~ = ~ & \text{Number of women of reproductive age}
\end{aligned}$$
* Number of pregnant women who died during childbirth per 100,000 women of reproductive age
$$\begin{aligned}
n_{deadhf} ~ + ~ n_{deadnothf} & ~ \div ~ \frac{n_{WRA}}{100000}\\
\\
where: & \\
\\
n_{deadhf} ~ = ~ & \text{Number of pregnant women who died} \\
& \text{during childbirth at health facility} \\
n_{deadnothf} ~ = ~ & \text{Number of pregnant women who died} \\
& \text{during childbirth outside of health facility} \\
n_{WRA} ~ = ~ & \text{Number of women of reproductive age}
\end{aligned}$$
# 2. Time-series analysis of monthly NHIS data
Using the data frame objects `mProvince` and `mDistricts`, we can now produce time-series analysis of specific indicators specified above.
## At least one antenatal care visit with a trained health worker
We first work with the province data.
We will work with the data columns labelled `anc1` and `sf`
```{r, echo = TRUE, eval = TRUE}
temp1 <- aggregate(anc1 ~ ADM1_PCODE + ADM1_EN + month + year,
data = mProvince,
FUN = sum)
temp2 <- aggregate(sf ~ ADM1_PCODE + ADM1_EN + month + year,
data = mProvince,
FUN = unique)
temp1$anc1Std <- temp1$anc1 / temp2$sf
temp1$month <- as.character(temp1$month)
temp1$month[temp1$month == "jan"] <- 1
temp1$month[temp1$month == "feb"] <- 2
temp1$month[temp1$month == "mar"] <- 3
temp1$month[temp1$month == "apr"] <- 4
temp1$month[temp1$month == "may"] <- 5
temp1$month[temp1$month == "jun"] <- 6
temp1$month[temp1$month == "jul"] <- 7
temp1$month[temp1$month == "aug"] <- 8
temp1$month[temp1$month == "sep"] <- 9
temp1$month[temp1$month == "oct"] <- 10
temp1$month[temp1$month == "nov"] <- 11
temp1$month[temp1$month == "dec"] <- 12
temp1$date <- paste(temp1$year, temp1$month, sep = "-")
temp1$date <- zoo::as.yearmon(temp1$date)
temp1 <- temp1[order(temp1$date), ]
temp1 <- temp1 %>%
group_by(ADM1_EN) %>%
mutate(anc1Sm = rollmean(x = anc1Std, k = 3, na.pad = TRUE))
temp1long <- gather(data = temp1,
key = "anc1",
value = "value",
anc1Std, anc1Sm,
factor_key = TRUE)
```
```{r, echo = TRUE, eval = TRUE}
themeSettings <- theme_bw() +
theme(panel.grid.major = element_line(linetype = 1,
size = 0.2,
colour = "gray80"),
panel.grid.minor = element_line(linetype = 0),
axis.text.x = element_text(size = 6, angle = 90),
legend.key = element_rect(linetype = 0),
legend.key.size = unit(1, "cm"),
legend.position = "top")
```
\newpage
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 12, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(temp1, aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month",
date_breaks = "1 month",
date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(temp1$anc1Std),
by = 500)) +
facet_wrap(vars(ADM1_EN)) +
themeSettings
```
\newpage
We now work with the district data.
```{r, echo = TRUE, eval = TRUE}
dist1 <- aggregate(anc1 ~ ADM2_PCODE + ADM2_EN + ADM1_PCODE + ADM1_EN + month + year,
data = mDistrict,
FUN = sum)
dist2 <- aggregate(sf ~ ADM2_PCODE + ADM2_EN + ADM1_PCODE + ADM1_EN + month + year,
data = mDistrict,
FUN = unique)
dist1$anc1Std <- dist1$anc1 / dist2$sf
dist1$month <- as.character(dist1$month)
dist1$month[dist1$month == "jan"] <- 1
dist1$month[dist1$month == "feb"] <- 2
dist1$month[dist1$month == "mar"] <- 3
dist1$month[dist1$month == "apr"] <- 4
dist1$month[dist1$month == "may"] <- 5
dist1$month[dist1$month == "jun"] <- 6
dist1$month[dist1$month == "jul"] <- 7
dist1$month[dist1$month == "aug"] <- 8
dist1$month[dist1$month == "sep"] <- 9
dist1$month[dist1$month == "oct"] <- 10
dist1$month[dist1$month == "nov"] <- 11
dist1$month[dist1$month == "dec"] <- 12
dist1$date <- paste(dist1$year, dist1$month, sep = "-")
dist1$date <- zoo::as.yearmon(dist1$date)
```
\newpage
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 1, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 500)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 2, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 3, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 4, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 5, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 6, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 7, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 8, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 9, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 10, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 11, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 12, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 13, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```
```{r, echo = TRUE, eval = TRUE, fig.width = 12, fig.height = 4, fig.align = "center", fig.pos = "H", fig.retina = 1}
ggplot(dist1[dist1$ADM1_PCODE == 14, ], aes(as.Date(date), anc1Std)) +
geom_line(colour = "#08519c", size = 1) +
scale_x_date(name = "Month", date_breaks = "1 month", date_labels = "%b %y") +
scale_y_continuous(name = "ANC1",
breaks = seq(from = 0,
to = max(dist1$anc1Std),
by = 100)) +
facet_grid(ADM1_EN ~ ADM2_EN) +
themeSettings
```