The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Legacy functions

Ernest Guevarra

2019-10-19

Legacy functions

Earlier versions (pre-release and v0.1.0) of zscorer used different functions that calculated only three anthropometric indices: weight-for-age, height-for-age and weight-for-height. Also, these functions used a simplified construct of the WHO Growth Reference in which children’s ages were recorded in months compared to days in the standard WHO Growth Reference.

With the developers’ recent work on anthropometric data quality processes implemented in R (see nipnTK), a more consistent and standard set of functions were deemed necessary to calculate not just three but all anthropometric indices used in the WHO Growth Standards and to make the children’s age in the reference data consistent with the standard using days. This work has now culminated in the current zscorer function.

For the purposes of backwards compatibility and to keep a record of past codebase for previous versions of the functions, the legacy functions have been kept in zscorer. This vignette describes those functions and shows examples of how to use them.

For new users of zscorer, developers recommend to start learning and using the new functions instead of using these legacy functions. For previous zscorer users, developers recommend to review past code that use the legacy functions and if feasible adapt code to the new functions available.

Calculating z-scores using the legacy functions

The zscorer package comes with the original legacy functions included in its version 0.1.0. These functions allow for the calculation of weight-for-age, height-for-age and weight-for-height z-scores for individual children and for a cohort of children.

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.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.