Menu ENN Search
Language: English Français

New version of R package 'zscorer' available

This question was posted the Assessment and Surveillance forum area and has 21 replies.

» Post a reply

Mark Myatt

Consultant Epidemiologist

Frequent user

5 Nov 2019, 14:55

Ernest and I have been working on the zscorer package for the R Language for Data Analysis and Graphics. v0.3.1 of the zscorer package calculates and adds nutritional anthropometry z-scores 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 for children aged between zero and 60 months or the WHO Growth References for school-aged children and adolescents.

New in this version is that MUAC-for-age (mfa) z-scores for children aged between 60 and 228 months are calculated using the new MUAC-for-age growth reference developed by Mramba et al. (2017) using data from the USA and Africa:

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

This reference has been validated with African school-age children and adolescents.

The zscorer comes packaged with the WHO Growth References data and the new MUAC-for-age reference data.

The package contains a Shiny app that provides a web interface to the package's functions. You can see an example of this functionality here.

The package can be downloaded and installed in R in the usual manner. The package website is here.

A manual is inlcuded in the package and is available here.

Carlos Grijalva-Eternod

UCL Institute for Global Health

Normal user

5 Nov 2019, 19:54

This R package is very neat and useful.

Thank you Mark and Ernest.

Ernest Guevarra


Frequent user

5 Nov 2019, 20:15

Thanks for sharing this to the forum Mark!

Mark and I are pleased to be able to share this package along with the accompanying web interface with the forum and to everyone who does nutrition studies and surveys. We think this fills a gap that we noted from some of the questions/issues raised in this thread with regard to tools for z-score calculation.

For those who already use R Language for Data Analysis and Graphics, then installation and usage will be straightforward using the links that Mark shared documenting the functions in the zscorer package.

For those that don't use R or are still in the early stages of learning R, the web interface allows for anyone to perform the calculations using familiar and easy to learn point and click user interface.

This package and the web interface is in active development. Mark and I are happy to receive feedback/comments/issue or bug reports/feature requests either via this EN-NET forum or through our GitHub development portal found here. Mark and I also embrace open source development and as such our codebase is available for anyone to review and give feedback to or build on. This is available, again, through our GitHub development portal.

Anonymous 27728


Normal user

5 Nov 2019, 22:13

Excuse me, for it's not an answer but rather a question: please tell me if you know a way to calculate the target weight and height of a child without using the WHO Zscore table. 

I would like to know whether there is another method to find the target weight of a child  without using the WHO z-score table, because after taking the anthopomteric measurements for a child with W/H -3 we use the WHO table to find the target weight.  My question is to find out whether there is another method of calculating this?  

 Thank you for taking my question into consideration, Tidiani Cisse Student

Sharon Cox

Assoc Professor

Normal user

6 Nov 2019, 01:32

Thanks Ernest and Mark. I agree that this fills a gap. I will be sharing with my students. 

Mutegi Kevin

Normal user

6 Nov 2019, 03:02

Thank you Mark & Ernest

Mbaye Diop

Cellule de lutte contre la malnutrition

Normal user

7 Nov 2019, 13:59


There are expected target weights for 1 month periods as part of growth monitoring and promotion (GMP).

Try to get acquainted with these tables, but they are for children from 0-23 months.

Thank you

Mark Myatt

Consultant Epidemiologist

Frequent user

7 Nov 2019, 16:16

Dear Anonymous 27728 / Étudiant / Tidiani Cisse,

I am not sure that I understand your question. I guess that you have a SAM case with WHZ < -3 and you want to work out what weight for the same height would give WHZ >= 2 and this becomes a "target weight". Is that correct?

If so then it should be quite easy to write an short R script which uses the functions and reference data in the zscorer package to do the calculations You could wrap that script up with Shiny so you could do the calculations in your web-browser.

The mechanics of the R script will be something like this:

    ## Load zscorer library

    ## Sex, weight, and height for a SAM case
    sex = 1
    height = 91
    weight = 9.9

    ## Calculate WHZ for this case
    getWGSR(sex = sex, firstPart = weight, secondPart = height, index = "wfh")

This gives:

     [1] -3.633671

This is the WHZ for the specified case (i.e. sex = 1 (for male), height = 91, and weight = 9.9).

We now need to calculate what weight for the current height gives WHZ = 2

    ## Specify the objective function
    objFun <- function(weight)
      result <- getWGSR(sex = sex, firstPart = weight,
                        secondPart = height, index = "wfh") + 1.99

    ## Find the weight that gives an answer closest to zero
    uniroot(objFun, interval = c(weight, 25))$root

This gives:

    [1] 11.23279

This is the target weight

We can check the result with the original height and the target weight:

    getWGSR(sex = 1, firstPart = 11.23279, secondPart = 91, index = "wfh")

This gives:

    [1] -1.990001

which, as we wanted it just above WHZ = -2.

This process assumes that no height is gained during treatment. This may not always be the case as children tend to grow quickly when their nutritional needs are met.

A simple alternative ... UNICEF guidelines have a 15% weight gain as a target. For the example child this would be:

    9.9 * 1.15 = 11.385

We can check what that gives:

     getWGSR(sex = 1, firstPart = 11.385, secondPart = 91, index = "wfh")
This gives:

    [1] -1.813269

which is also a bit above WHZ < -2 giving some room for a little gain in height.

The 15% proportional weight gain apporach is simple to apply with a table or using a cheap and simple pocket calculator.

BTW ... The GMP target weight tables are for normal growth in weight and we expect / want accelerated growth in therapeutic feeding.

I hope this is useful.

Martin Njoroge


Normal user

13 Nov 2019, 08:57

Thanks Mark & Ernest. Quite informative and helpful.

Severine Frison

Normal user

15 Apr 2020, 11:57

Hello Mark,

I've been using the package, really great work. Thanks a lot.

I have one question though, it seems like zscores are rounded to 2 digits only. Is there a way to change that option?

Many thanks in advance


Mark Myatt

Consultant Epidemiologist

Frequent user

15 Apr 2020, 12:26

Yes. Using addWGSR() to add z-scores to an R data.frame you can specify the number of digits you want using the digits parameter. For example, with surevy data in the svy data.frame object you might add WHZ with four digits using:

    svy <- addWGSR(data = svy, sex = "sex", firstPart = "weight",

                                  secondPart = "height", index = "wfh", digits = 4)

this should add WHZ as wfhz with four decimal places ... I am not sure why you would need this level of precision. If you need a different name than use the name parameter.

I hope this is of some use.

Thanks you for your kind comments about the software,

Severine Frison

Normal user

15 Apr 2020, 13:37

Thanks a lot Mark!

Cazes Cécile

Normal user

22 May 2020, 23:24


The weight-for-height calculation table used in the DRC corresponds to the WHO unisex boy table but does not take into account the child's age. So when I compare the classification of children according to the W / H ratio according to the DRC table and according to a variable calculated with the package zscorer or other package R such as anthro or igrowup, I observe differences in classifications.

For example, a 29 month old child with a weight of 7.2 kg and a height of 73.5 cm has a W / H ratio = -3 according to the DRC table but a W / H ratio = - 3.27 according to the WHO table for boys. So when I check the classification by the nurses of this child in two categories, SAM or Non-SAM, my calculated variable indicates a SAM classification while the child is non-SAM according to the DRC table, so there is no error according to the table used in the DRC. I found 1.5% of discrepancy of this type due to the fact that the calculation of the weight / height index according to the WHO 2006 standards is based on the age or the taking of the standing or lying height of the child.

The ideal would be that I can integrate the DRC weight / height table into an R program to avoid these discrepancies. What do you think? Do you think this is doable? How? Or maybe there are other alternatives?

Thank you in advance for your help.

Mark Myatt

Consultant Epidemiologist

Frequent user

25 May 2020, 11:00

I am not sure I fully understand the question. WHZ for a boy with height = 73.5cm and weight = 7.2 kg is -3. This is from the WHO table:

Using zscorer:

    >getWGSR(sex = 1, firstPart = 7.2, secondPart = 73.5, index = "wfh")


     [1] -3.078397

which is close enough (it is -3 exactly if weight is about 7.245 but we almost never mesure weight with that degree of precision).

WHZ does not include an age term. It is considered a strength of W/H that age is not used (since it is often not accurate). We do account for age indirectly by using length rather than height in children aged less than two years or with height less than 87 cm (a proxy for two years of age). This may be the origin of the discrepancy you report.

If I specify standing = 1 (i.e. measured standing) as in:

    >getWGSR(sex = 1, firstPart = 7.2, secondPart = 73.5, index = "wfh",              standing = 1)

which gives:

     [1] -3.26919

I think this is your "-3.27". 

If you use zscorer and do not specify a 'standing' value then height (and age) rules apply. You can see these rules if you type '(getWSGR)' to print the function defintion.

The "0.7" is a correction that accounts for compression of the spine when standing. You can do this before using getWGSR() or addWGRS() to match the DRC table or use the 'standing' parameter.

You could rewrite the getWGSR() function to make it match results given in the DRC table. That would not be hard to do.

I hope this helps.

Cazes Cécile

Normal user

25 May 2020, 11:33

Thank you very much for your answer.

I would like to understand how the DRC table is designed.

According to my research, this is the WHO table for boys, but I noticed that the values correspond to either children under 24 months of age (lying down measurement) or children of + 24 months of age (standing measurement).

If I understand your answer correctly, you mean that the DRC table corresponds to the WHO boys table with a systematic correction made on the height: + 0.7 cm compared to the actual height? is it this?

so I should apply the argument: index = wfh height = height + 0.7 cm systematically to get the values from the DRC table?

Thanks for your help

Mark Myatt

Consultant Epidemiologist

Frequent user

25 May 2020, 12:21

The WHO table for younger(i.e. < 2 years) children is usually for weight-for-length (i.e. children measured lying down). There are weight-for-height tables for children of all ages (capable of standing upright). When you measure a child lying down the length is greater than the height. Before the WGS we used to assume the difference was 0.5 cm and adjusted the length by -0.5 cm to estimate height in order to work with weight-for-height tables. Since WGS we have used 0.7 cm. This is the difference in reference median height for two year olds in L/A (M = 87.8 cm; F = 86.4 cm) and H/A tables (M = 87.1 cm; F = 85.7 cm).

I do not know how the DRC tables were made. I doubt they used a separate reference population from locally collected data. I guess they just joined the W/L table (kids < 2 years) an the W/H table (kids >= 2 years) together was done with the old NCHS reference. You could ask your local nutrition cluster for guidance. SMART project people might know. Someone on EN-NET might know.

You need to take care of the sign of the adjustment. If the child was measured lying down then subtract 0.7 cm to use the W/H table to get WHZ and do nothing to use the W/L table to get WLZ. If the child was measured upright then add 0.7 cm to use the W/L table to get WLZ and do nothing to use the W/H table to get WHZ. Does that make sense? This sort of behaviour is encoded in the height / age rules in the gettWGSR() function in zscorer.

I hope this helps.

Cazes Cécile

Normal user

25 May 2020, 14:34

again, Thank you for your suggestions, I will apply your instructions.

One last question, do you have a bibliographic reference regarding the 0.7 cm correction?

Thank you again.

Mark Myatt

Consultant Epidemiologist

Frequent user

25 May 2020, 15:02

The WHO / UNICEF handbook:


which is available from here has:

Always record carefully whether recumbent length or standing height was measured. If a child is 2 years old or older and cannot stand, measure the child’s recumbent length and note this in the questionnaire (in the question about measurement position); equally, if a child is less than 2 years old and is measured standing, this should also be noted in the questionnaire. In both cases, explain why this child was not measured in the appropriate position for his or her age. In such cases, an adjustment will be required in the data analysis phase prior to calculating the z-scores based on the WHO Child Growth Standards (0.7 cm should be added to the standing height to convert it to recumbent length for children below 2 years old old, and 0.7 cm subtracted from the recumbent length to convert it to standing height for children 2 years or older). This adjustment is made automatically by the software program in the standard analysis approach (see Chapter 3 on Data Analysis).

on page 41 (also see Table 9). This correction procedure is present in the WHO scripts for R and STATA and in the xscorer getWGSR() function.

I hope this helps.

Cazes Cécile

Normal user

26 May 2020, 11:50

Hello again,

After checking, I still have the same problem of discordant values between the WHO table for the WFL boy table (0-2years old, 45 to 110 cm) and the WFL value calculated by the package.

All of the children below are under 24 months of age with a length measurement while lying down. The WHO boy WFL table indicates a wfl z-score strictly equal to -3; these children are classified as not severe.

On the other hand, the variable calculated with zscorer indicates a wfl z-score <-3; these children are in the severe class. I found the same result using the R anthro and igrowup packages.

With zscorer:

getWGSR (sex = 1, firstPart = 7.2, secondPart = 73.5, index = "wfl", standing = "2")
[1] -3.078397

getWGSR (sex = 1, firstPart = 6.8, secondPart = 71.1, index = "wfl", standing = "2")
[1] -3.073756

getWGSR (sex = 1, firstPart = 5.7, secondPart = 65.0, index = "wfl", standing = "2")
[1] -3.078341

getWGSR (sex = 1, firstPart = 5.3, secondPart = 63.2, index = "wfl", standing = "2")
[1] -3.199316

getWGSR (sex = 1, firstPart = 5.4, secondPart = 63.5, index = "wfl", standing = "2")
[1] -3.10421

Mark Myatt

Consultant Epidemiologist

Frequent user

26 May 2020, 12:48

I assume you mean "length" not "waist" measurement.

I think you are saying that your example weights and heights should be giving a WHZ = -3 but actually give WHZ a litte below -3.

Looking at your first example (male, weight = 7.2, length = 73.5) using the WHO table at:

shows 7.2 in the -3 SD column for height = 73.5. If we use the LMS values we get:

 z = (((7.2/9.1927)^-0.3521) - 1)/(-0.3521 * 0.08276) = -3.082965

this should be adjusted. See page 203 of:

WHO Multicentre Growth Reference Study Group. 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. Geneva: World Health Organization, 2006

This is the procedure used in anthro, igrowup, zscorer, and other software as well as for the production of the WHO lookup tables.

After adjustment we get WHZ = -3.078397.

It seems to me that rounding error may have crept into the WHO and DRC tables. Playing with values (altering weight, keeping height the same, and recalculating WHZ) i get:

getWGSR (sex = 1, firstPart = 7.2455, secondPart = 73.5, index = "wfl", standing = "2")
[1] -3.000095

This 7.2455 kg gives very close to WHZ = -3 but we never measure to that degree of precision ... 100 g precision is about the best we can do with Salter type sprung hanging scales. If we round 7.2455 kg to 100 g precision we get 7.2 kg.

I have long opined in this forum that WHZ is overly complicated and prone to error. I think this is a large part of what we are seeing here. I think we can live with a small error that we cannot avoid and favours sensitivity. A difference is z-scores of c. 0.08 seems little to worry about. It seems a very thin line to have between treating and not treating very thin children.

Cazes Cécile

Normal user

26 May 2020, 14:42

I apologize for the confusion on the term "size" which comes from the translation from French / English I think (only one word in French).

Your explanations are of great help, thank you very much.

I had this assumption on rounding of size or weight but I would not have been able to confirm them as you did. thank you so much.

some children are classified in the -3 SD column when they are severe and miss out on treatment with RUTF it is a shame. In the specific case of these 5 children, the MUAC was between 115 and 122, therefore children at high risk of mortality who escape treatment with RUTF according to the national protocol.

Thanks for your help.

Mark Myatt

Consultant Epidemiologist

Frequent user

27 May 2020, 11:45

I am glad that I was able to help.

I am interested in "combined" protocols which treat SAM and MAM cases in CMAM type programs with MAM cases receiving a shorter and less intensive RUTF-based treatment protocol.These programs tend to use MUAC (PB) to decide admission and children with MUAC (PB) between 115 mm and 122 mm would be admitted.

If you have any problem posting a response, please contact the moderator at

Back to top

» Post a reply