brittanyblouin / ANCRTAdjust

An R package to adjust routine HIV testing data from antenatal care to reduce bias in estimating HIV prevalence trends
MIT License
2 stars 3 forks source link

Inconsistency in quality indicators by region #8

Open ellessenne opened 4 years ago

ellessenne commented 4 years ago

There is an inconsistence between the region and the suffix added to the quality indicators:

> quality_indicators(ancrt_cleaned, byregion = TRUE, bytime = FALSE)
                                Raw.Count Raw.Percent Clean.Count Clean.Percent region
Missing >=1 quarter                     0        (0%)          NA            NA    All
Missing n_clients                       0        (0%)           0          (0%)    All
Missing n_status                        0        (0%)           0          (0%)    All
Missing testpos                         0        (0%)           0          (0%)    All
Missing testneg                         0        (0%)           0          (0%)    All
Missing knownpos                        0        (0%)           0          (0%)    All
Missing >=1 variables                   0        (0%)           0          (0%)    All
Invalid coverage                      654     (3.27%)         650       (3.25%)    All
Invalid prevalence                      0        (0%)           0          (0%)    All
Inconsistent n_status                 475     (2.38%)           0          (0%)    All
Negative n_clients                      0        (0%)           0          (0%)    All
Negative n_status                       0        (0%)           0          (0%)    All
Negative testpos                        1        (0%)           0          (0%)    All
Negative testneg                        0        (0%)           0          (0%)    All
Negative knownpos                       0        (0%)           0          (0%)    All
One or more invalid variables         886     (4.43%)         650       (3.25%)    All
Missing >=1 quarter.1                   0        (0%)          NA            NA      1
Missing n_clients.1                     0        (0%)           0          (0%)      1
Missing n_status.1                      0        (0%)           0          (0%)      1
Missing testpos.1                       0        (0%)           0          (0%)      1
Missing testneg.1                       0        (0%)           0          (0%)      1
Missing knownpos.1                      0        (0%)           0          (0%)      1
Missing >=1 variables.1                 0        (0%)           0          (0%)      1
Invalid coverage.1                    229     (3.58%)         213       (3.33%)      1
Invalid prevalence.1                    0        (0%)           0          (0%)      1
Inconsistent n_status.1               142     (2.22%)           0          (0%)      1
Negative n_clients.1                    0        (0%)           0          (0%)      1
Negative n_status.1                     0        (0%)           0          (0%)      1
Negative testpos.1                      0        (0%)           0          (0%)      1
Negative testneg.1                      0        (0%)           0          (0%)      1
Negative knownpos.1                     0        (0%)           0          (0%)      1
One or more invalid variables.1       290     (4.53%)         213       (3.33%)      1
Missing >=1 quarter.2                   1     (0.46%)          NA            NA      3
Missing n_clients.2                     0        (0%)           0          (0%)      3
Missing n_status.2                      0        (0%)           0          (0%)      3
Missing testpos.2                       0        (0%)           0          (0%)      3
Missing testneg.2                       0        (0%)           0          (0%)      3
Missing knownpos.2                      0        (0%)           0          (0%)      3
Missing >=1 variables.2                 0        (0%)           0          (0%)      3
Invalid coverage.2                    142      (3.3%)         138       (3.21%)      3
Invalid prevalence.2                    0        (0%)           0          (0%)      3
Inconsistent n_status.2               108     (2.51%)           0          (0%)      3
Negative n_clients.2                    0        (0%)           0          (0%)      3
Negative n_status.2                     0        (0%)           0          (0%)      3
Negative testpos.2                      0        (0%)           0          (0%)      3
Negative testneg.2                      0        (0%)           0          (0%)      3
Negative knownpos.2                     0        (0%)           0          (0%)      3
One or more invalid variables.2       188     (4.37%)         138       (3.21%)      3
Missing >=1 quarter.3                   1     (0.22%)          NA            NA      2
Missing n_clients.3                     0        (0%)           0          (0%)      2
Missing n_status.3                      0        (0%)           0          (0%)      2
Missing testpos.3                       0        (0%)           0          (0%)      2
Missing testneg.3                       0        (0%)           0          (0%)      2
Missing knownpos.3                      0        (0%)           0          (0%)      2
Missing >=1 variables.3                 0        (0%)           0          (0%)      2
Invalid coverage.3                    283     (3.04%)         299       (3.22%)      2
Invalid prevalence.3                    0        (0%)           0          (0%)      2
Inconsistent n_status.3               225     (2.42%)           0          (0%)      2
Negative n_clients.3                    0        (0%)           0          (0%)      2
Negative n_status.3                     0        (0%)           0          (0%)      2
Negative testpos.3                      1     (0.01%)           0          (0%)      2
Negative testneg.3                      0        (0%)           0          (0%)      2
Negative knownpos.3                     0        (0%)           0          (0%)      2
One or more invalid variables.3       408     (4.39%)         299       (3.22%)      2

Here, for instance, region 3 has quality indicators with suffix .2. Could it be just a matter of ordering 'region' before printing the results? If so, I would suggest making sure they're ordered appropriately. It may not be wrong per se strictly speaking, but it looks like it could lead to some confusion to me.

m-maheu-giroux commented 4 years ago

You are right... this could have been made nicer. I implemented your suggested changes.

ellessenne commented 4 years ago

I think it prints better, but I still see some inconsistencies:

> ancrt_quality <- quality_indicators(ancrt_cleaned, by_region = TRUE, by_time = FALSE)
> ancrt_quality
                                         Raw.Count Raw.Percent Clean.Count Clean.Percent region
Missing >=1 quarter                              0        (0%)          NA            NA    all
Missing n_clients                                0        (0%)           0          (0%)    all
Missing n_status                                 0        (0%)           0          (0%)    all
Missing testpos                                  0        (0%)           0          (0%)    all
Missing testneg                                  0        (0%)           0          (0%)    all
Missing knownpos                                 0        (0%)           0          (0%)    all
Missing >=1 variables                            0        (0%)           0          (0%)    all
Invalid coverage                               654     (3.27%)         650       (3.25%)    all
Invalid prevalence                               0        (0%)           0          (0%)    all
Inconsistent n_status                          475     (2.38%)           0          (0%)    all
Negative n_clients                               0        (0%)           0          (0%)    all
Negative n_status                                0        (0%)           0          (0%)    all
Negative testpos                                 1        (0%)           0          (0%)    all
Negative testneg                                 0        (0%)           0          (0%)    all
Negative knownpos                                0        (0%)           0          (0%)    all
One or more invalid variables                  886     (4.43%)         650       (3.25%)    all
Missing >=1 quarter (region 1)                   0        (0%)          NA            NA      1
Missing n_clients (region 1)                     0        (0%)           0          (0%)      1
Missing n_status (region 1)                      0        (0%)           0          (0%)      1
Missing testpos (region 1)                       0        (0%)           0          (0%)      1
Missing testneg (region 1)                       0        (0%)           0          (0%)      1
Missing knownpos (region 1)                      0        (0%)           0          (0%)      1
Missing >=1 variables (region 1)                 0        (0%)           0          (0%)      1
Invalid coverage (region 1)                    229     (3.58%)         213       (3.33%)      1
Invalid prevalence (region 1)                    0        (0%)           0          (0%)      1
Inconsistent n_status (region 1)               142     (2.22%)           0          (0%)      1
Negative n_clients (region 1)                    0        (0%)           0          (0%)      1
Negative n_status (region 1)                     0        (0%)           0          (0%)      1
Negative testpos (region 1)                      0        (0%)           0          (0%)      1
Negative testneg (region 1)                      0        (0%)           0          (0%)      1
Negative knownpos (region 1)                     0        (0%)           0          (0%)      1
One or more invalid variables (region 1)       290     (4.53%)         213       (3.33%)      1
Missing >=1 quarter (region 3)                   1     (0.46%)          NA            NA      2
Missing n_clients (region 3)                     0        (0%)           0          (0%)      2
Missing n_status (region 3)                      0        (0%)           0          (0%)      2
Missing testpos (region 3)                       0        (0%)           0          (0%)      2
Missing testneg (region 3)                       0        (0%)           0          (0%)      2
Missing knownpos (region 3)                      0        (0%)           0          (0%)      2
Missing >=1 variables (region 3)                 0        (0%)           0          (0%)      2
Invalid coverage (region 3)                    142      (3.3%)         138       (3.21%)      2
Invalid prevalence (region 3)                    0        (0%)           0          (0%)      2
Inconsistent n_status (region 3)               108     (2.51%)           0          (0%)      2
Negative n_clients (region 3)                    0        (0%)           0          (0%)      2
Negative n_status (region 3)                     0        (0%)           0          (0%)      2
Negative testpos (region 3)                      0        (0%)           0          (0%)      2
Negative testneg (region 3)                      0        (0%)           0          (0%)      2
Negative knownpos (region 3)                     0        (0%)           0          (0%)      2
One or more invalid variables (region 3)       188     (4.37%)         138       (3.21%)      2
Missing >=1 quarter (region 2)                   1     (0.22%)          NA            NA      3
Missing n_clients (region 2)                     0        (0%)           0          (0%)      3
Missing n_status (region 2)                      0        (0%)           0          (0%)      3
Missing testpos (region 2)                       0        (0%)           0          (0%)      3
Missing testneg (region 2)                       0        (0%)           0          (0%)      3
Missing knownpos (region 2)                      0        (0%)           0          (0%)      3
Missing >=1 variables (region 2)                 0        (0%)           0          (0%)      3
Invalid coverage (region 2)                    283     (3.04%)         299       (3.22%)      3
Invalid prevalence (region 2)                    0        (0%)           0          (0%)      3
Inconsistent n_status (region 2)               225     (2.42%)           0          (0%)      3
Negative n_clients (region 2)                    0        (0%)           0          (0%)      3
Negative n_status (region 2)                     0        (0%)           0          (0%)      3
Negative testpos (region 2)                      1     (0.01%)           0          (0%)      3
Negative testneg (region 2)                      0        (0%)           0          (0%)      3
Negative knownpos (region 2)                     0        (0%)           0          (0%)      3
One or more invalid variables (region 2)       408     (4.39%)         299       (3.22%)      3

Note that region 2 and 3 are mixed up between the first and last column.