| Type: | Package |
| Title: | An Efficient Workflow for Plausibility Checks and Prevalence Analysis of Wasting in R |
| Version: | 0.2.5 |
| Description: | A simple and streamlined workflow for plausibility checks and prevalence analysis of wasting based on the Standardized Monitoring and Assessment of Relief and Transition (SMART) Methodology https://smartmethodology.org/, with application in R. |
| License: | GPL (≥ 3) |
| Depends: | R (≥ 4.1) |
| Imports: | dplyr, lubridate, nipnTK, rlang, scales, srvyr (≥ 1.3.0), stats, zscorer, tibble, methods, purrr |
| Suggests: | knitr, rmarkdown, quarto, spelling, testthat (≥ 3.0.0), |
| Encoding: | UTF-8 |
| Language: | en-GB |
| LazyData: | true |
| URL: | https://github.com/mphimo/mwana, https://mphimo.github.io/mwana/ |
| BugReports: | https://github.com/mphimo/mwana/issues |
| VignetteBuilder: | quarto |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-08-22 16:39:54 UTC; tomaszaba |
| Author: | Tomás Zaba |
| Maintainer: | Tomás Zaba <tomas.zaba@outlook.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-02 12:20:02 UTC |
mwana: An Efficient Workflow for Plausibility Checks and Prevalence Analysis of Wasting in R
Description
A simple and streamlined workflow for plausibility checks and prevalence analysis of wasting based on the Standardized Monitoring and Assessment of Relief and Transition (SMART) Methodology https://smartmethodology.org/, with application in R.
Author(s)
Maintainer: Tomás Zaba tomas.zaba@outlook.com (ORCID) [copyright holder]
Authors:
Tomás Zaba tomas.zaba@outlook.com (ORCID) [copyright holder]
Ernest Guevarra (ORCID) [copyright holder]
Mark Myatt
See Also
Useful links:
Report bugs at https://github.com/mphimo/mwana/issues
A sample data of district level SMART surveys with location anonymised
Description
anthro.01 is a two-stage cluster-based survey with probability of selection
of clusters proportional to the size of the population. The survey employed
the SMART methodology.
Usage
anthro.01
Format
A tibble of 1,191 rows and 11 columns.
| Variable | Description |
| area | Survey location |
| dos | Survey date |
| cluster | Primary sampling unit |
| team | Enumerator IDs |
| sex | Sex; "m" = boys, "f" = girls |
| dob | Date of birth |
| age | Age in months, typically estimated using local event calendars |
| weight | Weight in kilograms |
| height | Height in centimetres |
| oedema | oedema; "n" = no oedema, "y" = with oedema |
| muac | Mid-upper arm circumference in millimetres |
Source
Anonymous
Examples
anthro.01
A sample of an already wrangled survey data
Description
A household budget survey data conducted in Mozambique in 2019/2020, known as IOF (Inquérito ao Orçamento Familiar in Portuguese). IOF is a two-stage cluster-based survey, representative at province level (second administrative level), with probability of the selection of the clusters proportional to the size of the population. Its data collection spans for a period of 12 months.
Usage
anthro.02
Format
A tibble of 2,267 rows and 14 columns.
| Variable | Description |
| province | The administrative unit level 1 where data was collected |
| strata | Rural or Urban |
| cluster | Primary sampling unit |
| sex | Sex; "m" = boys, "f" = girls |
| age | Calculated age in months with two decimal places |
| weight | Weight in kilograms |
| height | Height in centimetres |
| oedema | oedema; "n" = no oedema, "y" = with oedema |
| muac | Mid-upper arm circumference in millimetres |
| wtfactor | Survey weights |
| wfhz | Weight-for-height z-scores with 3 decimal places |
| flag_wfhz | Flagged WFHZ value. 1 = flagged, 0 = not flagged |
| mfaz | MUAC-for-age z-scores with 3 decimal places |
| flag_mfaz | Flagged MFAZ value. 1 = flagged, 0 = not flagged |
Source
Mozambique National Institute of Statistics. The data is publicly available at https://mozdata.ine.gov.mz/index.php/catalog/88#metadata-data_access. Data was wrangled using this package's wranglers. Details about survey design can be read from: https://mozdata.ine.gov.mz/index.php/catalog/88#metadata-sampling
Examples
anthro.02
A sample data of district level SMART surveys conducted in Mozambique
Description
anthro.03 contains survey data of four districts. Each district dataset
presents distinct data quality scenarios that require a specific prevalence
analysis approach. Data from two districts have a problematic WFHZ standard
deviation. The data from the remaining two districts are all within range.
This sample data is useful to demonstrate the use of the prevalence functions on a multiple-domain survey data where there can be variations in the rating of acceptability of the standard deviation, hence requiring different analytical approach for each survey domain to ensure accurate estimation.
Usage
anthro.03
Format
A tibble of 943 x 9.
| Variable | Description |
| district | Survey location |
| cluster | Primary sampling unit |
| team | Survey teams |
| sex | Sex; "m" = boys, "f" = girls |
| age | Calculated age in months with two decimal places |
| weight | Weight in kilograms |
| height | Height in centimetres |
| oedema | oedema; "n" = no oedema, "y" = with oedema |
| muac | Mid-upper arm circumference in millimetres |
Source
Anonymous
Examples
anthro.03
A sample data from a community-based sentinel site with location anonymised
Description
Data herein was derived from population-based assessments in three locations (analysis unit). Each unit presents distinct scenarios that requires also-distinct handling during the prevalence analysis:
-
Unit A has flawless data.
-
Unit B has age-ratio-test results rated as problematic, with an observed proportion of children aged 24-59 months < 0.66.
-
Unit C has age-ratio-test results rated as problematic, with an observed proportion of children aged 24-59 months >= 0.66.
This sample data is useful to demonstrate designed behaviours of MUAC-prevalence functions to dealing with certain-and-expected flaws in the data.
Usage
anthro.04
Format
A tibble of 2,192 × 6.
| Variable | Description |
| analysis_unit | Location wherein the assessment was conducted |
| cluster | Primary sampling unit |
| sex | Sex; "1" = boys, "2" = girls |
| age | Calculated age in months |
| muac | Mid-upper arm circumference in millimetres |
| oedema | oedema; "n" = no oedema, "y" = yes oedema |
Source
Anonymous
Examples
anthro.04
Define wasting
Description
Determine if a given observation in the dataset is wasted or not, and its respective form of wasting (global, severe or moderate) on the basis of z-scores of weight-for-height (WFHZ), muac-for-age (MFAZ), raw MUAC values and combined case-definition.
Usage
define_wasting(
df,
zscores = NULL,
muac = NULL,
oedema = NULL,
.by = c("zscores", "muac", "combined")
)
Arguments
df |
A |
zscores |
A vector of class |
muac |
An |
oedema |
A |
.by |
A choice of the criterion by which a case is to be defined. Choose "zscores" for WFHZ or MFAZ, "muac" for raw MUAC and "combined" for combined. Default value is "zscores". |
Value
The tibble object df with additional columns named named gam,
sam and mam, each of class numeric containing coded values of either
1 (case) and 0 (not a case). If .by = "combined", additional columns are
named cgam, csam and cmam.
Examples
## Case-definition by z-scores ----
z <- anthro.02 |>
define_wasting(
zscores = wfhz,
muac = NULL,
oedema = oedema,
.by = "zscores"
)
head(z)
## Case-definition by MUAC ----
m <- anthro.02 |>
define_wasting(
zscores = NULL,
muac = muac,
oedema = oedema,
.by = "muac"
)
head(m)
## Case-definition by combined ----
c <- anthro.02 |>
define_wasting(
zscores = wfhz,
muac = muac,
oedema = oedema,
.by = "combined"
)
head(c)
Identify, flag, and remove outliers
Description
Identify outlier z-scores for weight-for-height (WFHZ) and MUAC-for-age (MFAZ) following the SMART methodology. The function can also be used to detect outliers for height-for-age (HFAZ) and weight-for-age (WFAZ) z-scores following the same approach.
For flagging z-scores, z-scores that deviate substantially from the sample's z-score mean are considered outliers and are unlikely to reflect accurate measurements. For raw MUAC, values that are less than 100 millimetres or greater than 200 millimetres are considered outliers as recommended by Bilukha & Kianian (2023). Including these values in the analysis could compromise the accuracy of the resulting estimates.
To remove outliers, their values are set to NA rather than removing the
record from the dataset. This process is also called censoring. By
assigning NA values to these outliers, they can be effectively removed
during statistical operations with functions that allow for removal of NA
values such as mean() for getting the mean value or sd() for getting the
standard deviation.
Usage
flag_outliers(x, .from = c("zscores", "raw_muac"))
remove_flags(x, .from = c("zscores", "raw_muac"))
Arguments
x |
A |
.from |
Either "zscores" or "raw_muac" for type of data to flag outliers from. |
Value
An vector of the same length as x of flagged records coded as
1 for a flagged record and 0 for a non-flagged record.
References
Bilukha, O., & Kianian, B. (2023). Considerations for assessment of measurement quality of mid‐upper arm circumference data in anthropometric surveys and mass nutritional screenings conducted in humanitarian and refugee settings. Maternal & Child Nutrition, 19, e13478. Available at https://onlinelibrary.wiley.com/doi/10.1111/mcn.13478
SMART Initiative (2017). Standardized Monitoring and Assessment for Relief and Transition. Manual 2.0. Available at: https://smartmethodology.org.
Examples
## Sample data of raw MUAC values ----
x <- anthro.01$muac
## Apply the function with `.from` set to "raw_muac" ----
m <- flag_outliers(x, .from = "raw_muac")
head(m)
## Sample data of z-scores (be it WFHZ, MFAZ, HFAZ or WFAZ) ----
x <- anthro.02$mfaz
# Apply the function with `.from` set to "zscores" ----
z <- flag_outliers(x, .from = "zscores")
tail(z)
## With `.from` set to "zscores" ----
z <- remove_flags(
x = wfhz.01$wfhz,
.from = "zscores"
)
head(z)
## With `.from` set to "raw_muac" ----
m <- remove_flags(
x = mfaz.01$muac,
.from = "raw_muac"
)
tail(m)
Calculate child's age in months
Description
Calculate child's age in months based on the date of birth and the date of data collection.
Usage
get_age_months(dos, dob)
Arguments
dos |
A |
dob |
A |
Value
A numeric vector of child's age in months. Any value less
than 6.0 and greater than or equal to 60.0 months are set to NA.
Examples
## Take two vectors of class "Date" ----
surv_date <- as.Date(
c(
"2024-01-05", "2024-01-05", "2024-01-05", "2024-01-08", "2024-01-08",
"2024-01-08", "2024-01-10", "2024-01-10", "2024-01-10", "2024-01-11"
)
)
bir_date <- as.Date(
c(
"2022-04-04", "2021-05-01", "2023-05-24", "2017-12-12", NA,
"2020-12-12", "2022-04-04", "2021-05-01", "2023-05-24", "2020-12-12"
)
)
## Apply the function ----
get_age_months(
dos = surv_date,
dob = bir_date
)
A sample mid-upper arm circumference (MUAC) screening data
Description
A sample mid-upper arm circumference (MUAC) screening data
Usage
mfaz.01
Format
A tibble with 661 rows and 4 columns.
| Variable | Description |
| sex | Sex; "m" = boys, "f" = girls |
| months | Calculated age in months with two decimal places |
| oedema | oedema, "n" = no oedema, "y" = with oedema |
| muac | Mid-upper arm circumference in millimetres |
Source
Anonymous
Examples
mfaz.01
A sample SMART survey data with mid-upper arm circumference measurements
Description
A sample SMART survey data with mid-upper arm circumference measurements
Usage
mfaz.02
Format
A tibble with 303 rows and 7 columns.
| Variable | Description |
| cluster | Primary sampling unit |
| sex | Sex; "m" = boys, "f" = girls |
| age | Calculated age in months with two decimal places |
| oedema | oedema, "n" = no oedema, "y" = with oedema |
| mfaz | MUAC-for-age z-scores with 3 decimal places |
| flag_mfaz | Flagged MUAC-for-age z-score value. 1 = flagged, 0 = not flagged |
Source
Anonymous
Examples
mfaz.02
Check whether sample size requirements for IPC Acute Malnutrition (IPC AMN) analysis are met
Description
Data for estimating the prevalence of acute malnutrition used in the IPC AMN can come from different sources: surveys, screenings or community-based surveillance systems. The IPC has set minimum sample size requirements for each source. This function verifies whether these requirements are met.
Usage
mw_check_ipcamn_ssreq(
df,
cluster,
.source = c("survey", "screening", "ssite"),
...
)
Arguments
df |
A |
cluster |
A vector of class |
.source |
The source of evidence. A choice between "survey" for representative survey data at the area of analysis; "screening" for screening data; "ssite" for community-based sentinel site data. Default value is "survey". |
... |
A vector of class |
Value
A summary tibble containing check results for:
-
n_clusters- the total number of unique clusters or screening or site identifiers; -
n_obs- the corresponding total number of children in the dataset; and, -
meet_ipc- whether the IPC AMN requirements were met.
References
IPC Global Partners. 2021. Integrated Food Security Phase Classification Technical Manual Version 3.1.Evidence and Standards for Better Food Security and Nutrition Decisions. Rome. Available at: https://www.ipcinfo.org/ipcinfo-website/resources/ipc-manual/en/.
Examples
mw_check_ipcamn_ssreq(
df = anthro.01,
cluster = cluster,
.source = "survey",
area
)
Estimate age-weighted prevalence of wasting by MUAC
Description
Estimates age‑weighted prevalence of wasting using MUAC. Accepts age in months or in categories ('6–23', '24–59'). The default is age in months.
The prevalence is weighted as:
( prevalence_{6-23} + (2 \times prevalence_{24-59} )) / 3
Whilst the function is exported to users as a standalone, it is embedded into
the following major MUAC prevalence functions of this package:
mw_estimate_prevalence_muac(), mw_estimate_prevalence_screening(), and
mw_estimate_prevalence_screening2().
Usage
mw_estimate_age_weighted_prev_muac(
df,
muac,
has_age = TRUE,
age = NULL,
age_cat = NULL,
oedema = NULL,
raw_muac = FALSE,
...
)
Arguments
df |
A |
muac |
A |
has_age |
Logical. Specifies whether the input dataset provides age in
months or in categories ('6–23', '24–59'). Defaults to |
age |
A vector of class |
age_cat |
A |
oedema |
A |
raw_muac |
Logical. Whether outliers should be excluded based on the raw
MUAC values or MFAZ. For the former, set it to |
... |
A vector of class |
Details
As a standalone function, the user must check data quality before calling the function.
Value
A summary tibble with wasting prevalence estimates, as given by the
SMART updated MUAC tool (see references below).
References
SMART Initiative (no date). Updated MUAC data collection tool. Available at: https://smartmethodology.org/survey-planning-tools/updated-muac-tool/
Examples
## Example application when age is given in months ----
anthro.04 |>
mw_wrangle_age(age = age) |>
mw_wrangle_muac(
muac = muac,
.recode_muac = TRUE,
.to = "cm",
age = age,
sex = sex,
.recode_sex = FALSE
) |>
transform(muac = recode_muac(muac, "mm")) |>
mw_estimate_age_weighted_prev_muac(
muac = muac,
has_age = TRUE,
age = age,
age_cat = FALSE,
oedema = oedema,
raw_muac = FALSE,
analysis_unit
)
## Example application when age is given in categories ----
anthro.04 |>
transform(age_cat = ifelse(age < 24, "6-23", "24-59")) |>
mw_wrangle_muac(
muac = muac,
.recode_muac = FALSE,
.to = "none",
sex = sex,
.recode_sex = FALSE
) |>
mw_estimate_age_weighted_prev_muac(
has_age = FALSE,
age = NULL,
age_cat = age_cat,
oedema = oedema,
raw_muac = TRUE
)
Estimate the prevalence of combined wasting
Description
Estimate the prevalence of wasting based on the combined case-definition of weight-for-height z-scores (WFHZ), MUAC and/or oedema. The function allows users to estimate prevalence in accordance with complex-sample design properties such as accounting for survey sample weights when needed or applicable.
The data quality is first assessed by calculating and rating the standard deviation (SD) of WFHZ. Then it calculates the observed proportion of children aged 24–59 months out of all children in the dataset. Next, it estimates the p-value for the difference between this observed proportion and the expected (0.66), and rates the result.
Prevalence is estimated only when the WFHZ SD is not problematic and the age ratio test is not problematic, or — if the age ratio test is problematic — the proportion of children aged 24–59 months is greater than or equal to 0.66.
Usage
mw_estimate_prevalence_combined(df, wt = NULL, oedema = NULL, ...)
Arguments
df |
A |
wt |
A vector of class |
oedema |
A |
... |
A vector of class |
Details
A concept of combined flags is introduced in this function. Any observation
that is flagged for either flag_wfhz or flag_mfaz is flagged under a new
variable named cflags added to df. This ensures that all flagged
observations from both WFHZ and MFAZ data are excluded from the prevalence
analysis.
| flag_wfhz | flag_mfaz | cflags |
| 1 | 0 | 1 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
Value
A summary tibble for the descriptive statistics about combined
wasting.
Examples
## When wt are set to NULL ----
mw_estimate_prevalence_combined(
df = anthro.02,
wt = NULL,
oedema = oedema
)
## When `wt` is not set to NULL ----
mw_estimate_prevalence_combined(
df = anthro.02,
wt = wtfactor,
oedema = oedema
)
Estimate the prevalence of wasting based on z-scores of muac-for-age (MFAZ)
Description
Calculate the prevalence estimates of wasting based on z-scores of MUAC-for-age and/or bilateral oedema. The function allows users to estimate prevalence in accordance with complex sample design properties such as accounting for survey sample weights when needed or applicable. The quality of the data is first evaluated by calculating and rating the standard deviation of MFAZ. Standard approach to prevalence estimation is calculated only when the standard deviation of MFAZ is rated as not problematic. If the standard deviation is problematic, prevalence is estimated using the PROBIT estimator. Outliers are detected based on SMART flagging criteria. Identified outliers are then excluded before prevalence estimation is performed.
Usage
mw_estimate_prevalence_mfaz(df, wt = NULL, oedema = NULL, ...)
Arguments
df |
A |
wt |
A vector of class |
oedema |
A |
... |
A vector of class |
Value
A summary tibble for the descriptive statistics about wasting.
Examples
## Without grouping variables ----
anthro.04 |>
mw_wrangle_age(age = age) |>
mw_wrangle_muac(
muac = muac,
.recode_muac = TRUE,
.to = "cm",
age = age,
sex = sex,
.recode_sex = FALSE
) |>
transform(muac = recode_muac(muac, "mm")) |>
mw_estimate_prevalence_mfaz(
wt = NULL,
oedema = oedema,
analysis_unit
)
Estimate the prevalence of wasting based on MUAC for survey data
Description
Estimate the prevalence of wasting based on MUAC and/or nutritional oedema. The function allows users to estimate prevalence in accordance with complex sample design properties, such as accounting for survey sample weights when needed or applicable.
It first evaluates the quality of the data to determine the appropriate prevalence-analysis flow to be employed. Quality is evaluated by estimating the observed proportion of children aged 24-59 months of the total children in the dataset, then it estimates the p-value for the difference between the above-mentioned category against the expected (0.66) and rates it.
If age ratio test is "problematic" and the proportion of children aged 24-59 months is < 0.66, age-weighting approach is applied to prevalence estimation, to account for the over-representation of younger children in the sample; otherwise, a non-age-weighted prevalence is estimated.
Usage
mw_estimate_prevalence_muac(df, age, muac, wt = NULL, oedema = NULL, ...)
Arguments
df |
A |
age |
A vector of class |
muac |
A |
wt |
A vector of class |
oedema |
A |
... |
A vector of class |
Details
A typical user analysis workflow is expected to begin with data quality checks, followed by a thorough review, and only thereafter proceed to prevalence estimation. This sequence places the user in the strongest position to assess whether the resulting prevalence estimates are reliable.
Outliers are identified using SMART flagging criteria applied to MFAZ, and are excluded from the prevalence estimation.
Value
A summary tibble for the descriptive statistics about wasting based
on MUAC, with confidence intervals.
References
SMART Initiative (no date). Updated MUAC data collection tool. Available at: https://smartmethodology.org/survey-planning-tools/updated-muac-tool/
See Also
mw_estimate_age_weighted_prev_muac() mw_estimate_prevalence_mfaz()
mw_estimate_prevalence_screening()
Examples
## Ungrouped analysis ----
anthro.04 |>
mw_wrangle_age(age = age) |>
mw_wrangle_muac(
muac = muac,
.recode_muac = TRUE,
.to = "cm",
age = age,
sex = sex,
.recode_sex = FALSE
) |>
transform(muac = recode_muac(muac, "mm")) |>
mw_estimate_prevalence_muac(
muac = muac,
age = age,
wt = NULL,
oedema = oedema,
analysis_unit
)
Estimate the prevalence of wasting based on MUAC for non-survey data
Description
It is common to estimate prevalence of wasting from non-survey data, such as screenings or any other data derived from community-based surveillance systems. In such situations, the analysis usually consists only in estimating the point prevalence and the counts of positive cases, without necessarily estimating the uncertainty. This function serves this purpose.
It first evaluates the quality of the data to determine the appropriate prevalence-analysis flow to be employed. Quality is evaluated by estimating the observed proportion of children aged 24-59 months of the total children in the dataset, then it estimates the p-value for the difference between the above-mentioned category against the expected (0.66) and rates it.
If age ratio test is "problematic" and the proportion of children aged 24-59 months is < 0.66, age-weighting approach is applied to prevalence estimation, to account for the over-representation of younger children in the sample; otherwise, a non-age-weighted prevalence is estimated.
Usage
mw_estimate_prevalence_screening(df, muac, age, oedema = NULL, ...)
mw_estimate_prevalence_screening2(df, age_cat, muac, oedema = NULL, ...)
Arguments
df |
A |
muac |
A |
age |
A vector of class |
oedema |
A |
... |
A vector of class |
age_cat |
A |
Details
A typical user analysis workflow is expected to begin with data quality checks, followed by a thorough review, and only thereafter proceed to prevalence estimation. This sequence places the user in the strongest position to assess whether the resulting prevalence estimates are reliable.
In mw_estimate_prevalence_screening(), outliers are identified using SMART
flagging criteria applied to MFAZ, whereas in mw_estimate_prevalence_screening2()
are based on the raw MUAC values. In either functions, outliers are excluded
from the prevalence estimation.
Value
A summary tibble for the descriptive statistics about wasting based
on MUAC, with no confidence intervals.
References
SMART Initiative (no date). Updated MUAC data collection tool. Available at: https://smartmethodology.org/survey-planning-tools/updated-muac-tool/
See Also
mw_estimate_prevalence_muac(), mw_estimate_age_weighted_prev_muac(),
flag_outliers() and remove_flags().
Examples
mw_estimate_prevalence_screening(
df = anthro.02,
muac = muac,
age = age,
oedema = oedema,
province
)
## With `oedema` set to `NULL` ----
mw_estimate_prevalence_screening(
df = anthro.02,
muac = muac,
age = age,
oedema = NULL,
province
)
## Specifying the grouping variables ----
mw_estimate_prevalence_screening(
df = anthro.02,
muac = muac,
age = age,
oedema = NULL,
province
)
anthro.01 |>
mw_wrangle_muac(
sex = sex,
.recode_sex = TRUE,
muac = muac
) |>
transform(
age_cat = ifelse(age < 24, "6-23", "24-59")
) |>
mw_estimate_prevalence_screening2(
age_cat = age_cat,
muac = muac,
oedema = oedema,
area
)
Estimate the prevalence of wasting based on weight-for-height z-scores (WFHZ)
Description
Calculate the prevalence estimates of wasting based on z-scores of weight-for-height and/or nutritional oedema. The function allows users to estimate prevalence in accordance with complex sample design properties such as accounting for survey sample weights when needed or applicable. The quality of the data is first evaluated by calculating and rating the standard deviation of WFHZ. Standard approach to prevalence estimation is calculated only when the standard deviation of MFAZ is rated as not problematic. If the standard deviation is problematic, prevalence is estimated using the PROBIT estimator. Outliers are detected based on SMART flagging criteria. Identified outliers are then excluded before prevalence estimation is performed.
Usage
mw_estimate_prevalence_wfhz(df, wt = NULL, oedema = NULL, ...)
Arguments
df |
A |
wt |
A vector of class |
oedema |
A |
... |
A vector of class |
Value
A summary tibble for the descriptive statistics about wasting.
Examples
## When .by = NULL ----
### Start off by wrangling the data ----
data <- mw_wrangle_wfhz(
df = anthro.03,
sex = sex,
weight = weight,
height = height,
.recode_sex = TRUE
)
### Now run the prevalence function ----
mw_estimate_prevalence_wfhz(
df = data,
wt = NULL,
oedema = oedema
)
## Now when .by is not set to NULL ----
mw_estimate_prevalence_wfhz(
df = data,
wt = NULL,
oedema = oedema,
district
)
## When a weighted analysis is needed ----
mw_estimate_prevalence_wfhz(
df = anthro.02,
wt = wtfactor,
oedema = oedema,
province
)
Clean and format the output tibble returned from the MUAC-for-age z-score plausibility check
Description
Converts scientific notations to standard notations, rounds off values, and renames columns to meaningful names.
Usage
mw_neat_output_mfaz(df)
Arguments
df |
An |
Value
A data.frame object of the same length and width as df, with column
names and values formatted as appropriate.
Examples
## First wrangle age data ----
data <- mw_wrangle_age(
df = anthro.01,
dos = dos,
dob = dob,
age = age,
.decimals = 2
)
## Then wrangle MUAC data ----
data_mfaz <- mw_wrangle_muac(
df = data,
sex = sex,
age = age,
muac = muac,
.recode_sex = TRUE,
.recode_muac = TRUE,
.to = "cm"
)
## Then run plausibility check ----
pl <- mw_plausibility_check_mfaz(
df = data_mfaz,
flags = flag_mfaz,
sex = sex,
muac = muac,
age = age,
area
)
## Now neat the output table ----
mw_neat_output_mfaz(df = pl)
Clean and format the output tibble returned from the MUAC plausibility check
Description
Converts scientific notations to standard notations, rounds off values, and renames columns to meaningful names.
Usage
mw_neat_output_muac(df)
Arguments
df |
A |
Value
A data.frame object of the same length and width as df, with column names
and values formatted for clarity and readability.
Examples
## First wrangle MUAC data ----
df_muac <- mw_wrangle_muac(
df = anthro.01,
sex = sex,
muac = muac,
age = NULL,
.recode_sex = TRUE,
.recode_muac = FALSE,
.to = "none"
)
## Then run the plausibility check ----
pl_muac <- mw_plausibility_check_muac(
df = df_muac,
flags = flag_muac,
sex = sex,
muac = muac
)
## Neat the output table ----
mw_neat_output_muac(df = pl_muac)
Clean and format the output tibble returned from the WFHZ plausibility check
Description
Converts scientific notations to standard notations, rounds off values, and renames columns to meaningful names.
Usage
mw_neat_output_wfhz(df)
Arguments
df |
An |
Value
A tibble object of the same length and width as df, with column names and
values formatted for clarity and readability.
Examples
## First wrangle age data ----
data <- mw_wrangle_age(
df = anthro.01,
dos = dos,
dob = dob,
age = age,
.decimals = 2
)
## Then wrangle WFHZ data ----
data_wfhz <- mw_wrangle_wfhz(
df = data,
sex = sex,
weight = weight,
height = height,
.recode_sex = TRUE
)
## Now run the plausibility check ----
pl <- mw_plausibility_check_wfhz(
df = data_wfhz,
sex = sex,
age = age,
weight = weight,
height = height,
flags = flag_wfhz,
area
)
## Now neat the output table ----
mw_neat_output_wfhz(df = pl)
Check the plausibility and acceptability of MUAC-for-age z-score (MFAZ) data
Description
Check the overall plausibility and acceptability of MFAZ data through a structured test suite encompassing checks for sampling and measurement-related biases in the dataset. This test suite follows the recommendation made by Bilukha & Kianian (2023) on the plausibility of constructing a comprehensive plausibility check for MUAC data similar to weight-for-height z-score to evaluate its acceptability when age values are available in the dataset.
The function works on a data.frame returned from wrangling functions for
age and for MUAC-for-age z-score data available from this package.
Usage
mw_plausibility_check_mfaz(df, sex, muac, age, flags, ...)
Arguments
df |
A |
sex |
A |
muac |
A |
age |
A vector of class |
flags |
A |
... |
A vector of class |
Details
Whilst the function uses the same checks and criteria as those for weight-for-height z-scores in the SMART plausibility check, the percent of flagged records is evaluated using different cut-off points, with a maximum acceptability of 2.0% as shown below:
| Excellent | Good | Acceptable | Problematic |
| 0.0 - 1.0 | >1.0 - 1.5 | >1.5 - 2.0 | >2.0 |
Value
A single-row summary tibble with columns containing the plausibility
check results. If ungrouped analysis, the output will consist of 17 columns
and one row; otherwise, the number of columns will vary according to the number
vectors specified, and the number of rows to the categories within the grouping
variables.
References
Bilukha, O., & Kianian, B. (2023). Considerations for assessment of measurement quality of mid‐upper arm circumference data in anthropometric surveys and mass nutritional screenings conducted in humanitarian and refugee settings. Maternal & Child Nutrition, 19, e13478. https://onlinelibrary.wiley.com/doi/10.1111/mcn.13478
SMART Initiative (2017). Standardized Monitoring and Assessment for Relief and Transition. Manual 2.0. Available at: https://smartmethodology.org.
See Also
mw_wrangle_age() mw_wrangle_muac() mw_stattest_ageratio()
flag_outliers()
Examples
## First wrangle age data ----
data <- mw_wrangle_age(
df = anthro.01,
dos = dos,
dob = dob,
age = age,
.decimals = 2
)
## Then wrangle MUAC data ----
data_muac <- mw_wrangle_muac(
df = data,
sex = sex,
age = age,
muac = muac,
.recode_sex = TRUE,
.recode_muac = TRUE,
.to = "cm"
)
## And finally run plausibility check ----
mw_plausibility_check_mfaz(
df = data_muac,
flags = flag_mfaz,
sex = sex,
muac = muac,
age = age,
area, team
)
Check the plausibility and acceptability of raw MUAC data
Description
Check the overall plausibility and acceptability of raw MUAC data through a structured test suite encompassing checks for sampling and measurement-related biases in the dataset. The test suite in this function follows the recommendation made by Bilukha & Kianian (2023).
Usage
mw_plausibility_check_muac(df, sex, muac, flags, ...)
Arguments
df |
A |
sex |
A |
muac |
A vector of class |
flags |
A |
... |
A vector of class |
Details
Cut-off points used for the percent of flagged records:
| Excellent | Good | Acceptable | Problematic |
| 0.0 - 1.0 | >1.0 - 1.5 | >1.5 - 2.0 | >2.0 |
Value
A single-row summary tibble with columns containing the plausibility
check results. If ungrouped analysis, the output will consist of nine columns
and one row; otherwise, the number of columns will vary according to the number
vectors specified, and the number of rows to the categories within the grouping
variables.
References
Bilukha, O., & Kianian, B. (2023). Considerations for assessment of measurement quality of mid‐upper arm circumference data in anthropometric surveys and mass nutritional screenings conducted in humanitarian and refugee settings. Maternal & Child Nutrition, 19, e13478. https://onlinelibrary.wiley.com/doi/10.1111/mcn.13478
SMART Initiative (2017). Standardized Monitoring and Assessment for Relief and Transition. Manual 2.0. Available at: https://smartmethodology.org.
See Also
mw_wrangle_muac() flag_outliers()
Examples
## First wrangle MUAC data ----
df_muac <- mw_wrangle_muac(
df = anthro.01,
sex = sex,
muac = muac,
age = NULL,
.recode_sex = TRUE,
.recode_muac = FALSE,
.to = "none"
)
## Then run the plausibility check ----
mw_plausibility_check_muac(
df = df_muac,
flags = flag_muac,
sex = sex,
muac = muac,
area, team # group analysis by survey area and by survey team
)
Check the plausibility and acceptability of weight-for-height z-score (WFHZ) data
Description
Check the overall plausibility and acceptability of WFHZ data through a structured test suite encompassing checks for sampling and measurement-related biases in the dataset. The test suite, including the criteria and corresponding rating of acceptability, follows the standards in the SMART plausibility check.
The function works on a data frame returned by this package's wrangling functions for age and for WFHZ data.
Usage
mw_plausibility_check_wfhz(df, sex, age, weight, height, flags, ...)
Arguments
df |
A |
sex |
A |
age |
A vector of class |
weight |
A vector of class |
height |
A vector of class |
flags |
A |
... |
A vector of class |
Value
A single-row summary tibble with columns containing the plausibility
check results. If ungrouped analysis, the output will consist of 19 columns
and one row; otherwise, the number of columns will vary according to the number
vectors specified, and the number of rows to the categories within the grouping
variables.
References
SMART Initiative (2017). Standardized Monitoring and Assessment for Relief and Transition. Manual 2.0. Available at: https://smartmethodology.org.
See Also
mw_plausibility_check_mfaz() mw_plausibility_check_muac()
mw_wrangle_age()
Examples
## First wrangle age data ----
data <- mw_wrangle_age(
df = anthro.01,
dos = dos,
dob = dob,
age = age,
.decimals = 2
)
## Then wrangle WFHZ data ----
data_wfhz <- mw_wrangle_wfhz(
df = data,
sex = sex,
weight = weight,
height = height,
.recode_sex = TRUE
)
## Now run the plausibility check ----
mw_plausibility_check_wfhz(
df = data_wfhz,
sex = sex,
age = age,
weight = weight,
height = height,
flags = flag_wfhz,
area, team
)
Test for statistical difference between the proportion of children aged 24 to 59 months old over those aged 6 to 23 months old
Description
Calculate the observed age ratio of children aged 24 to 59 months old over those aged 6 to 23 months old and test if there is a statistically significant difference between the observed and the expected.
Usage
mw_stattest_ageratio(age, .expectedP = 0.66)
mw_stattest_ageratio2(age_cat, .expectedP = 0.66)
Arguments
age |
A |
.expectedP |
The expected proportion of children aged 24 to 59 months old over those aged 6 to 23 months old. By default, this is expected to be 0.66. |
age_cat |
A |
Details
This function should be used specifically when assessing the quality of MUAC
data. For age ratio test of children aged 6 to 29 months old over 30 to 59
months old, as performed in the SMART plausibility check, use
nipnTK::ageRatioTest() instead.
Value
A list object with three elements: p for p-value of the
difference between the observed and the expected proportion of children aged
24 to 59 months old over those aged 6 to 23 months old, observedR for the
observed ratio, and observedP for the observed proportion.
References
SMART Initiative. Updated MUAC data collection tool. Available at: https://smartmethodology.org/survey-planning-tools/updated-muac-tool/
Examples
mw_stattest_ageratio(
age = anthro.02$age,
.expectedP = 0.66
)
age <- ifelse(anthro.02$age < 24, "6-23", "24-59")
mw_stattest_ageratio2(
age = age,
.expectedP = 0.66
)
Wrangle child's age
Description
Wrangle child's age for downstream analysis. This includes calculating age in months based on the date of data collection and the child's date of birth, and setting to NA the age values that are less than 6.0 and greater than or equal to 60.0 months old.
Usage
mw_wrangle_age(df, dos = NULL, dob = NULL, age, .decimals = 2)
Arguments
df |
A |
dos |
A |
dob |
A |
age |
A |
.decimals |
The number of decimal places to round off age to. Default is 2. |
Value
A tibble based on df. The variable age will be automatically
filled in each row where age value was missing and both the child's
date of birth and the date of data collection are available. Rows where age
is less than 6.0 and greater than or equal to 60.0 months old will be set to
NA. Additionally, a new variable named age_days of class double for
calculated age of child in days is added to df.
Examples
## A sample data ----
df <- data.frame(
surv_date = as.Date(c(
"2023-01-01", "2023-01-01", "2023-01-01", "2023-01-01", "2023-01-01"
)),
birth_date = as.Date(c(
"2019-01-01", NA, "2018-03-20", "2019-11-05", "2021-04-25"
)),
age = c(NA, 36, NA, NA, NA)
)
## Apply the function ----
mw_wrangle_age(
df = df,
dos = surv_date,
dob = birth_date,
age = age,
.decimals = 3
)
Wrangle MUAC data
Description
Calculate z-scores for MUAC-for-age (MFAZ) and identify outliers based on
the SMART methodology. When age is not supplied, only outliers are detected
from the raw MUAC values. The function only works after age has gone through
mw_wrangle_age().
Usage
mw_wrangle_muac(
df,
sex,
muac,
age = NULL,
.recode_sex = TRUE,
.recode_muac = TRUE,
.to = c("cm", "mm", "none"),
.decimals = 3
)
Arguments
df |
A |
sex |
A |
muac |
A |
age |
A |
.recode_sex |
Logical. Set to TRUE if the values for |
.recode_muac |
Logical. Set to TRUE if the values for raw MUAC should be converted to either centimetres or millimetres. Otherwise, set to FALSE (default) |
.to |
A choice of the measuring unit to convert MUAC values into. Can be "cm" for centimetres, "mm" for millimetres, or "none" to leave as it is. |
.decimals |
The number of decimal places to use for z-score outputs. Default is 3. |
Value
A tibble based on df. If age = NULL, flag_muac variable for
detected MUAC outliers based on raw MUAC is added to df. Otherwise,
variables named mfaz for child's MFAZ and flag_mfaz for detected outliers
based on SMART guidelines are added to df.
References
Bilukha, O., & Kianian, B. (2023). Considerations for assessment of measurement quality of mid‐upper arm circumference data in anthropometric surveys and mass nutritional screenings conducted in humanitarian and refugee settings. Maternal & Child Nutrition, 19, e13478. https://onlinelibrary.wiley.com/doi/10.1111/mcn.13478
SMART Initiative (2017). Standardized Monitoring and Assessment for Relief and Transition. Manual 2.0. Available at: https://smartmethodology.org.
See Also
flag_outliers() remove_flags() mw_wrangle_age()
Examples
## When age is available, wrangle it first before calling the function ----
w <- mw_wrangle_age(
df = anthro.02,
dos = NULL,
dob = NULL,
age = age,
.decimals = 2
)
### Then apply the function to wrangle MUAC data ----
mw_wrangle_muac(
df = w,
sex = sex,
age = age,
muac = muac,
.recode_sex = TRUE,
.recode_muac = TRUE,
.to = "cm",
.decimals = 3
)
## When age is not available ----
mw_wrangle_muac(
df = anthro.02,
sex = sex,
age = NULL,
muac = muac,
.recode_sex = TRUE,
.recode_muac = TRUE,
.to = "cm",
.decimals = 3
)
Wrangle weight-for-height data
Description
Calculate z-scores for weight-for-height (WFHZ) and identify outliers based on the SMART methodology.
Usage
mw_wrangle_wfhz(df, sex, weight, height, .recode_sex = TRUE, .decimals = 3)
Arguments
df |
A |
sex |
A |
weight |
A vector of class |
height |
A vector of class |
.recode_sex |
Logical. Set to TRUE if the values for |
.decimals |
The number of decimal places to use for z-score outputs. Default is 3. |
Value
A data frame based on df with new variables named wfhz for
child's WFHZ and flag_wfhz for detected outliers added.
References
SMART Initiative (2017). Standardized Monitoring and Assessment for Relief and Transition. Manual 2.0. Available at: https://smartmethodology.org.
See Also
flag_outliers() remove_flags()
Examples
mw_wrangle_wfhz(
df = anthro.01,
sex = sex,
weight = weight,
height = height,
.recode_sex = TRUE,
.decimals = 2
)
Rate the acceptability of the age and sex ratio test p-values
Description
Rate the acceptability of the age and sex ratio test p-values
Usage
rate_agesex_ratio(p)
Arguments
p |
A vector of class |
Value
A character vector with the same length as p for the
acceptability rate.
Rate the overall acceptability of the data
Description
Rate the overall data acceptability score into "Excellent", "Good", "Acceptable" or "Problematic".
Usage
rate_overall_quality(q)
Arguments
q |
A |
Value
A vector of class factor with the same length as q of overall
rate of acceptability of the data.
Rate the acceptability of the proportion of flagged records
Description
Rate the acceptability of the proportion of flagged records in WFHZ, MFAZ, and raw MUAC data following the SMART methodology criteria.
Usage
rate_propof_flagged(p, .in = c("mfaz", "wfhz", "raw_muac"))
Arguments
p |
A vector of class |
.in |
Specifies the dataset where the rating should be done. Can be "wfhz", "mfaz", or "raw_muac". Default to "wfhz". |
Value
A vector of class factor with the same length as p for the
acceptability rate.
Rate the acceptability of the skewness and kurtosis test results
Description
Rate the acceptability of the skewness and kurtosis test results
Usage
rate_skewkurt(sk)
Arguments
sk |
A vector of class |
Value
A vector of class factor with the same length as sk for the
acceptability rate.
Rate the acceptability of the standard deviation
Description
Rate the acceptability of the standard deviation of WFHZ, MFAZ, and raw MUAC data. Rating follows the SMART methodology criteria.
Usage
rate_std(sd, .of = c("zscores", "raw_muac"))
Arguments
sd |
A vector of class |
.of |
Specifies the dataset to which the rating should be done. Can be "wfhz", "mfaz", or "raw_muac". |
Value
A vector of class factor of the same length as sd for the
acceptability rate.
Convert MUAC values to either centimetres or millimetres
Description
Convert MUAC values to either centimetres or millimetres
Usage
recode_muac(x, .to = c("cm", "mm"))
Arguments
x |
A vector of raw MUAC values. The class can either be |
.to |
Either "cm" (centimetres) or "mm" (millimetres) for the unit of measurement to convert MUAC values to. |
Value
A numeric vector of the same length as x with values set to
specified unit of measurement.
Examples
## Recode from millimetres to centimetres ----
muac_cm <- recode_muac(
x = anthro.01$muac,
.to = "cm"
)
head(muac_cm)
## Using the `muac_cm` object to recode it back to "mm" ----
muac_mm <- recode_muac(
x = muac_cm,
.to = "mm"
)
tail(muac_mm)
Get the overall acceptability score from the acceptability rate scores
Description
Get the overall acceptability score from the acceptability rate scores
Usage
score_overall_quality(
cl_flags,
cl_sex,
cl_age,
cl_dps_m = NULL,
cl_dps_w = NULL,
cl_dps_h = NULL,
cl_std,
cl_skw,
cl_kurt,
.for = c("wfhz", "mfaz")
)
Arguments
.for |
A choice between "wfhz" and "mfaz" for the type of scorer to apply. Default is "wfhz". |
Value
A numeric value for the overall data quality (acceptability)
score.
Score the acceptability rating of the check results that constitutes the plausibility check suite
Description
Attribute a score, also known as penalty point, for a given rate of acceptability of the standard deviation, proportion of flagged records, age and sex ratio, skewness, kurtosis and digit preference score check results. The scoring criteria and thresholds follows the standards in the SMART plausibility check.
Usage
score_std_flags(x)
score_agesexr_dps(x)
score_skewkurt(x)
Arguments
x |
A |
Value
An integer vector with the same length as x of the acceptability
score.
References
SMART Initiative (2017). Standardized Monitoring and Assessment for Relief and Transition. Manual 2.0. Available at: https://smartmethodology.org.
A sample SMART survey data with weight-for-height z-score standard deviation rated as problematic
Description
A sample SMART survey data with weight-for-height z-score standard deviation rated as problematic
Usage
wfhz.01
Format
A tibble with 303 rows and 6 columns.
| Variable | Description |
| cluster | Primary sampling unit |
| sex | Sex; "m" = boys, "f" = girls |
| age | Calculated age in months with two decimal places |
| oedema | oedema, "n" = no oedema, "y" = with oedema |
| wfhz | MUAC-for-age z-scores with 3 decimal places |
| flag_wfhz | Flagged weight-for-height z-score value; 1 = flagged, 0 = not flagged |
Source
Anonymous
Examples
wfhz.01