zscorer facilitates the calculation of a range of anthropometric z-scores (i.e. the number of standard deviations from the mean) and adds them to survey data:

  • Weight-for-length (wfl) z-scores for children with lengths between 45 and 110 cm

  • Weight-for-height (wfh) z-scores for children with heights between 65 and 120 cm

  • Length-for-age (lfa) z-scores for children aged less than 24 months

  • Height-for-age (hfa) z-scores for children aged between 24 and 228 months

  • Weight-for-age (wfa) z-scores for children aged between zero and 120 months

  • Body mass index-for-age (bfa) z-scores for children aged between zero and 228 months

  • MUAC-for-age (mfa) z-scores for children aged between 3 and 228 months

  • Triceps skinfold-for-age (tsa) z-scores for children aged between 3 and 60 months

  • Sub-scapular skinfold-for-age (ssa) z-scores for children aged between 3 and 60 months

  • Head circumference-for-age (hca) z-scores for children aged between zero and 60 months

The z-scores are calculated using the WHO Child Growth Standards [1],[2] for children aged between zero and 60 months or the WHO Growth References [3] for school-aged children and adolescents. MUAC-for-age (mfa) z-scores for children aged between 60 and 228 months are calculated using the MUAC-for-age growth reference developed by Mramba et al. (2017) [4] using data from the USA and Africa. This reference has been validated with African school-age children and adolescents. The zscorer comes packaged with the WHO Growth References data and the MUAC-for-age reference data.

Installation

You can install zscorer from CRAN:

install.packages("zscorer")

or you can install the development version of zscorer from GitHub with:

if(!require(remotes)) install.packages("remotes")
remotes::install_github("nutriverse/zscorer")

then load zscorer

Usage

Calculating anthropometric z-scores using the addWGSR() function

The main function in the zscorer package is addWGSR().

To demonstrate its usage, we will use the accompanying dataset in zscorer called anthro3. We inspect the dataset as follows:

head(anthro3)

which returns:

anthro3 contains anthropometric data from a Rapid Assessment Method (RAM) survey from Burundi.

Anthropometric indices (e.g. weight-for-height z-scores) have not been calculated and added to the data.

We will use the addWGSR() function to add weight-for-height (wfh) z-scores to the example data:

A new column named wfhz has been added to the dataset:

The wfhz column contains the weight-for-height (wfh) z-scores calculated from the sex, weight, and height columns in the anthro3 dataset. The calculated z-scores are rounded to two decimals places unless the digits option is used to specify a different precision (run ?addWGSR to see description of various parameters that can be specified in the addWGSR() function).

The addWGSR() function takes up to nine parameters to calculate each index separately, depending on the index required. These are described in the Help files of the zscorer package which can be accessed as follows:

The standing parameter specifies how “stature” (i.e. length or height) was measured. If this is not specified, and in some special circumstances, height and age rules will be applied when calculating z-scores. These rules are described in the table below.

 

index standing age height Action
hfa or lfa standing < 731 days index = lfa height = height + 0.7 cm
hfa or lfa supine < 731 days index = lfa
hfa or lfa unknown < 731 days index = lfa
hfa or lfa standing ≥ 731 days index = hfa
hfa or lfa supine ≥ 731 days index = hfa height = height - 0.7 cm
hfa or lfa unknown ≥ 731 days index = hfa
wfh or wfl standing < 65 cm index = wfl height = height + 0.7 cm
wfh or wfl standing ≥ 65 cm index = wfh
wfh or wfl supine ≤ 110 cm index = wfl
wfh or wfl supine more than 110 cm index = wfh height = height - 0.7 cm
wfh or wfl unknown < 87 cm index = wfl
wfh or wfl unknown ≥ 87 cm index = wfh
bfa standing < 731 days height = height + 0.7 cm
bfa standing ≥ 731 days height = height - 0.7 cm

 

The addWGSR() function will not produce error messages unless there is something very wrong with the data or the specified parameters. If an error is encountered in a record then the value NA is returned. Error conditions are listed in the table below.

 

Error condition Action
Missing or nonsense value in standing parameter Set standing to 3 (unknown) and apply appropriate height or age rules.
Unknown index specified Return NA for z-score.
Missing sex Return NA for z-score.
Missing firstPart Return NA for z-score.
Missing secondPart Return NA for z-score.
sex is not male (1) or female (2) Return NA for z-score.
firstPart is not numeric Return NA for z-score.
secondPart is not numeric Return NA for z-score.
Missing thirdPart when index = "bfa" Return NA for z-score.
thirdPart is not numeric when index = "bfa" Return NA for z-score.
secondPart is out of range for specified index Return NA for z-score.

 

We can see this error behaviour using the example data:

We can display the problem record:

The problem is due to the value 9 in the sex column, which should be coded 1 (for male) and 2 (for female). Z-scores are only calculated for records with sex specified as either 1 (male) or 2 (female). All other values, including NA, will return NA.

The addWGSR() function requires that data are recorded using the required units or required codes (see ?addWGSR to check units required by the different function parameters).

The addWGSR() function will return incorrect values if the data are not recorded using the required units. For example, this attempt to add weight-for-age z-scores to the example data:

will give incorrect results:

The odd range of values is due to age being recorded in months rather than days.

It is simple to convert all ages from months to days:

before calculating and adding weight-for-age z-scores:

The muac column in the example dataset is recorded in millimetres (mm). We need to convert this to centimetres (cm):

before using the addWGS() function to calculate MUAC-for-age z-scores:

As a last example we will use the addWGSR() function to add body mass index-for-age (bfa) z-scores to the data to create a new variable called bmiAgeZ with a precision of 4 decimal places as:

Usage - legacy functions

To maintain support for earlier versions of the package, the earlier functions used to calculate anthropometric z-scores for weight-for-age, height-for-age and weight-for-height have been kept for now until future deprecation. For current users, it is recommended to use addWGSR() and getWGSR() functions.

Calculating z-score for each of the three anthropometric indices for a single child

For this example, we will use the getWGS() function and apply it to dummy data of a 52 month old male child with a weight of 14.6 kg and a height of 98.0 cm.

Applying the getWGS() function results in a calculated z-score for one child.

Calculating z-score for each of the three anthropometric indices for a cohort or sample of children

For this example, we will use the getCohortWGS() function and apply it to sample data anthro1 that came with zscorer.

As you will see, this dataset has the 4 variables you will need to use with getCohortWGS() to calculate the z-score for the corresponding anthropometric index. These are age, sex, weight and height.

To calculate the three anthropometric indices for all the children in the sample, we execute the following commands in R:

# weight-for-age z-score
waz <- getCohortWGS(data = anthro1,
                    sexObserved = "sex",
                    firstPart = "weight",
                    secondPart = "age",
                    index = "wfa")
head(waz, 50)
#>  [1] -0.75605549 -1.39021503 -1.05597853  1.41575096 -2.67757242
#>  [6]  1.49238050 -0.12987704 -0.02348159 -1.50647344 -1.54381630
#> [11] -2.87495712 -0.43497240 -1.03899540 -1.69281855 -1.31245898
#> [16] -2.21003260 -0.01189226 -0.90917762 -0.67839855 -0.94746695
#> [21] -2.49960425 -0.95659644 -1.65442686 -1.25052760  0.67335751
#> [26]  0.30156301  0.24261346 -2.78670709 -1.15820651 -1.15477183
#> [31] -1.35540820 -0.59134959 -4.14967218 -0.45748752 -0.74331669
#> [36] -1.69725836 -1.05745067 -0.18869508 -0.42095770 -2.21030414
#> [41] -1.30536715 -3.63778143 -0.60662526 -0.54360470 -1.59171780
#> [46] -1.74745738 -0.34803338  0.69896149 -0.74467130  0.18924572

# height-for-age z-score
haz <- getCohortWGS(data = anthro1,
                    sexObserved = "sex",
                    firstPart = "height",
                    secondPart = "age",
                    index = "hfa")
head(haz, 50)
#>  [1] -1.2258169 -2.3475886 -2.9518041 -0.2812852 -4.2056663 -0.5387678
#>  [7] -2.4020719 -1.0317699 -2.7410884 -4.7037571 -2.5670550 -2.1144960
#> [13] -2.2323505 -2.3155458 -2.7516165 -2.7930694  0.1121349 -1.9001797
#> [19] -2.9543730 -1.9671042 -3.8716522  0.8667206 -2.8252069 -2.1412285
#> [25] -2.7994643  0.5496459 -1.4372002 -3.7979410 -2.5661752 -1.8301183
#> [31] -1.6548589 -2.7110333 -3.6399642 -1.7955069 -1.6775100 -1.0317699
#> [37] -0.4356881 -1.2660152  0.4990326 -4.6085660 -3.1662351 -1.0695930
#> [43] -1.8477936 -2.5502314 -1.8301183 -2.2755493 -3.2816532  0.4876774
#> [49] -2.4396410 -0.4794744

# weight-for-height z-score
whz <- getCohortWGS(data = anthro1,
                    sexObserved = "sex",
                    firstPart = "weight",
                    secondPart = "height",
                    index = "wfh")
head(whz, 50)
#>  [1]  0.05572347 -0.01974903  0.57469112  2.06231749 -0.14080044
#>  [6]  2.49047246  1.83315197  0.93614891  0.18541943  2.11599287
#> [11] -1.96943887  1.06351047  0.35315830 -0.61151003 -0.01049441
#> [16] -0.75038993 -0.08000322  0.31277573  1.56456175  0.22152087
#> [21] -0.08798757 -2.14197877 -0.30804823  0.00778227  3.21041413
#> [26]  0.07434468  1.40966986 -0.81485050  0.63816647 -0.33540392
#> [31] -0.61955533  1.35716952 -2.77364671  1.00831095  0.32842063
#> [36] -1.66705281 -1.21157702  0.89024472 -0.89865037  0.82166393
#> [41]  0.64442137 -4.39847850  0.38411140  1.48299847 -0.93068495
#> [46] -0.88558228  1.69551410  0.65143649  0.61269397  0.59813891

Applying the getCohortWGS() function results in a vector of calculated z-scores for all children in the cohort or sample.

Shiny app

To use the included Shiny app, run the following command in R:

This will initiate the Shiny app using the installed web browser in your current device as shown below:

References

  1. World Health Organization. (2006). WHO child growth standards : length/height-for-age, weight-for-age, weight-for-length, weight -for-height and body mass index-for-age : methods and development. World Health Organization. https://apps.who.int/iris/handle/10665/43413

  2. World Health Organization. (2007). WHO child growth standards : head circumference-for-age, arm circumference-for-age, triceps skinfold-for-age and subscapular skinfold-for-age : methods and development. World Health Organization. https://apps.who.int/iris/handle/10665/43706

  3. de Onis M. Development of a WHO growth reference for school-aged children and adolescents. Bull World Health Org. 2007;85: 660–667. doi:10.2471/BLT.07.043497

  4. Mramba L, Ngari M, Mwangome M, Muchai L, Bauni E, Walker AS, et al. A growth reference for mid upper arm circumference for age among school age children and adolescents, and validation for mortality: growth curve construction and longitudinal cohort study. BMJ. 2017;: j3423–8. doi:10.1136/bmj.j3423