Define if a given observation in the data set 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,
edema = NULL,
.by = c("zscores", "muac", "combined")
)
Arguments
- df
A data set object of class
data.frame
to use. It must have been wrangled using this package's wrangling functions for WFHZ or MUAC, or both (for combined) as appropriate.- zscores
A vector of class
double
of WFHZ or MFAZ values. If the class does not match the expected type, the function will stop execution and return an error message indicating the type of mismatch.- muac
A vector of class
integer
ornumeric
of raw MUAC values in millimeters. If the class does not match the expected type, the function will stop execution and return an error message indicating the type of mismatch.- edema
A vector of class
character
of edema. Default isNULL
. If the class does not match the expected type, the function will stop execution and return an error message indicating the type of mismatch. Code values should be "y" for presence and "n" for absence of bilateral edema. If different, the function will stop execution and return an error indicating the issue.- .by
A choice of the criterion by which the case-definition should done. Choose
zscores
for WFHZ or MFAZ,muac
for raw MUAC andcombined
for combined.
Value
Three vectors named gam
, sam
and mam
, of class numeric
, same
length as inputs, containing dummy values: 1 for case and 0 for not case.
This is added to df
. When combined
is selected, vector's names become
cgam
, csam
and cmam
.
Examples
## Case-definition by z-scores ----
z <- anthro.02 |>
define_wasting(
zscores = wfhz,
muac = NULL,
edema = edema,
.by = "zscores"
)
head(z)
#> # A tibble: 6 × 17
#> province strata cluster sex age weight height edema muac wtfactor wfhz
#> <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> <dbl>
#> 1 Zambezia Rural 391 1 6.01 8.2 68 n 152 825. 0.349
#> 2 Zambezia Rural 404 2 6.01 7.1 65.1 n 139 287. -0.006
#> 3 Zambezia Rural 399 1 6.11 7.6 64.1 n 155 130. 0.9
#> 4 Zambezia Urban 430 2 6.14 7.9 65.9 n 148 1277. 0.876
#> 5 Zambezia Urban 468 2 6.28 6.6 59.7 n 132 792. 1.38
#> 6 Zambezia Urban 517 2 6.34 6 61.8 n 129 480. -0.583
#> # ℹ 6 more variables: flag_wfhz <dbl>, mfaz <dbl>, flag_mfaz <dbl>, gam <dbl>,
#> # sam <dbl>, mam <dbl>
## Case-definition by MUAC ----
m <- anthro.02 |>
define_wasting(
zscores = NULL,
muac = muac,
edema = edema,
.by = "muac"
)
head(m)
#> # A tibble: 6 × 17
#> province strata cluster sex age weight height edema muac wtfactor wfhz
#> <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> <dbl>
#> 1 Zambezia Rural 391 1 6.01 8.2 68 n 152 825. 0.349
#> 2 Zambezia Rural 404 2 6.01 7.1 65.1 n 139 287. -0.006
#> 3 Zambezia Rural 399 1 6.11 7.6 64.1 n 155 130. 0.9
#> 4 Zambezia Urban 430 2 6.14 7.9 65.9 n 148 1277. 0.876
#> 5 Zambezia Urban 468 2 6.28 6.6 59.7 n 132 792. 1.38
#> 6 Zambezia Urban 517 2 6.34 6 61.8 n 129 480. -0.583
#> # ℹ 6 more variables: flag_wfhz <dbl>, mfaz <dbl>, flag_mfaz <dbl>, gam <dbl>,
#> # sam <dbl>, mam <dbl>
## Case-definition by combined ----
c <- anthro.02 |>
define_wasting(
zscores = wfhz,
muac = muac,
edema = edema,
.by = "combined"
)
head(c)
#> # A tibble: 6 × 17
#> province strata cluster sex age weight height edema muac wtfactor wfhz
#> <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> <dbl>
#> 1 Zambezia Rural 391 1 6.01 8.2 68 n 152 825. 0.349
#> 2 Zambezia Rural 404 2 6.01 7.1 65.1 n 139 287. -0.006
#> 3 Zambezia Rural 399 1 6.11 7.6 64.1 n 155 130. 0.9
#> 4 Zambezia Urban 430 2 6.14 7.9 65.9 n 148 1277. 0.876
#> 5 Zambezia Urban 468 2 6.28 6.6 59.7 n 132 792. 1.38
#> 6 Zambezia Urban 517 2 6.34 6 61.8 n 129 480. -0.583
#> # ℹ 6 more variables: flag_wfhz <dbl>, mfaz <dbl>, flag_mfaz <dbl>, cgam <dbl>,
#> # csam <dbl>, cmam <dbl>