Skip to content

Commit 1db68ce

Browse files
authored
Merge pull request #17 from lshtm-gigs/dev
gigs 0.3.0
2 parents 42a1435 + 7bc75e1 commit 1db68ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+730
-592
lines changed

README.md

+47-30
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<!-- badges: end -->
55

66
## About
7-
Produced as part of the Guidance for International Growth Standards (GIGS) project,
8-
`gigs` provides a single, simple interface for working with the WHO Child Growth
9-
Standards and outputs from the INTERGROWTH-21<sup>st</sup> project. You will
10-
find functions for converting between anthropometric measures (e.g. weight or
11-
length) to z-scores and percentiles, and the inverse. Also included are
7+
Produced as part of the Guidance for International Growth Standards (GIGS)
8+
project, `gigs` provides a single, simple interface for working with the WHO
9+
Child Growth Standards and outputs from the INTERGROWTH-21<sup>st</sup> project.
10+
You will find functions for converting between anthropometric measures (e.g.
11+
weight or length) to z-scores and centiles, and the inverse. Also included are
1212
functions for classifying newborn and infant growth according to
1313
literature-based cut-offs.
1414

@@ -40,15 +40,15 @@ files.
4040
Component standards
4141
</summary>
4242

43-
| Acronym | Description | Unit | `gest_age()` range |
44-
|----------|--------------------------------------------|-------|--------------------|
45-
| `wfga` | Weight-or-gestational age | kg | 168 to 300 days |
46-
| `lfga` | Length-for-gestational age | cm | 168 to 300 days |
47-
| `hcfga` | Head circumference-for-gestational age | cm | 168 to 300 days |
48-
| `wlrfga` | Weight-to-length ratio-for-gestational age | kg/cm | 168 to 300 days |
49-
| `ffmfga` | Fat-free mass-for-gestational age | kg | 266 to 294 days |
50-
| `bfpfga` | Body fat percentage-for-gestational age | % | 266 to 294 days |
51-
| `fmfga` | Fat mass-for-gestational age | kg | 266 to 294 days |
43+
| Acronym | Description | Unit | `gest_days()` range |
44+
|----------|--------------------------------------------|-------|---------------------|
45+
| `wfga` | Weight-or-gestational age | kg | 168 to 300 days |
46+
| `lfga` | Length-for-gestational age | cm | 168 to 300 days |
47+
| `hcfga` | Head circumference-for-gestational age | cm | 168 to 300 days |
48+
| `wlrfga` | Weight-to-length ratio-for-gestational age | kg/cm | 168 to 300 days |
49+
| `ffmfga` | Fat-free mass-for-gestational age | kg | 266 to 294 days |
50+
| `bfpfga` | Body fat percentage-for-gestational age | % | 266 to 294 days |
51+
| `fmfga` | Fat mass-for-gestational age | kg | 266 to 294 days |
5252

5353
</details>
5454
- `ig_png` - INTERGROWTH-21<sup>st</sup> standards for postnatal growth in
@@ -78,8 +78,8 @@ files.
7878
| `bfa` | BMI-for-age | kg/m<sup>2</sup> | 0 to 1856 days |
7979
| `lhfa` | length/height-for-age | cm | 0 to 1856 days |
8080
| `hcfa` | head circumference-for-age | cm | 0 to 1856 days |
81-
| `wfl` | weight-for-height | kg | 45 to 110 cm |
82-
| `wfh` | weight-for-length | kg | 65 to 120 cm |
81+
| `wfl` | weight-for-length | kg | 45 to 110 cm |
82+
| `wfh` | weight-for-height | kg | 65 to 120 cm |
8383
| `acfa` | arm circumference-for-age | cm | 91 to 1856 days |
8484
| `ssfa` | subscapular skinfold-for-age | mm | 91 to 1856 days |
8585
| `tsfa` | triceps skinfold-for-age | mm | 91 to 1856 days |
@@ -90,27 +90,29 @@ files.
9090
Each conversion function has similar syntax. The main function call determines
9191
the set of standards in use, the `acronym` parameter specifies which component
9292
standard is being used, and the `conversion` parameter specifies the type of
93-
conversion you wish to perform. The `sex()` and `sexcode()` options are used to
94-
give the function sex data - as the growth standards are sex-specific, the
95-
standards cannot be applied correctly without this information.
93+
conversion you wish to perform. This `conversion` parameter can take one of four
94+
values: `"v2z"` (value-to-z-score), `"v2c"` (value-to-centile), `"z2v"`
95+
(z-score-to-value), `"c2v"` (centile-to-value). The `sex()` and `sexcode()`
96+
options are used to give the function sex data - as the growth standards are
97+
sex-specific, the standards cannot be applied correctly without this information.
9698

9799
### INTERGROWTH-21<sup>st</sup> Newborn Size standards, including very preterm
98100
This function can be used to convert between measurements and
99-
z-scores/percentiles in each of the INTERGROWTH-21<sup>st</sup> Newborn Size
101+
z-scores/centiles in each of the INTERGROWTH-21<sup>st</sup> Newborn Size
100102
Standards.
101103

102104
![](./readme/readme_ignbs.png)
103105

104106
### INTERGROWTH-21<sup>st</sup> Postnatal Growth standards
105107
This function can be used to convert between measurements and
106-
z-scores/percentiles in each of the INTERGROWTH-21<sup>st</sup> Postnatal
108+
z-scores/centiles in each of the INTERGROWTH-21<sup>st</sup> Postnatal
107109
Growth of Preterm Infants Standards.
108110

109111
![](./readme/readme_igpng.png)
110112

111113
### WHO Child Growth Standards
112114
This function can be used to convert between measurements and
113-
z-scores/percentiles in each of the WHO Child Growth Standards.
115+
z-scores/centiles in each of the WHO Child Growth Standards.
114116

115117
![](./readme/readme_whogs.png)
116118

@@ -121,7 +123,8 @@ cut-offs. These publications are discussed in the attached [paper]().
121123
#### Size for gestational age
122124
![](./readme/readme_csga.png)
123125

124-
This function outputs a variable with the following values and labels:
126+
This function outputs a variable with the following values and labels. Severely
127+
SGA infants are only labelled if the `severe` option is specified:
125128

126129
| Value | Meaning | Centile range |
127130
|-------|---------------------------------------|------------------------------------|
@@ -130,10 +133,26 @@ This function outputs a variable with the following values and labels:
130133
| 0 | Appropriate for gestational age (AGA) | 10<sup>th</sup> to 90<sup>th</sup> |
131134
| 1 | Large for gestational age (LGA) | \>90<sup>th</sup> |
132135

136+
#### Small vulnerable newborns
137+
![](./readme/readme_csvn.png)
138+
139+
This function outputs a variable with the following values and labels:
140+
141+
| Value | Meaning | Term Status | Centile range |
142+
|-------|-------------|-------------|------------------------------------|
143+
| -4 | Preterm SGA | Preterm | <10<sup>th</sup> |
144+
| -3 | Preterm AGA | Preterm | 10<sup>th</sup> to 90<sup>th</sup> |
145+
| -2 | Preterm LGA | Preterm | \>90<sup>th</sup> |
146+
| -1 | Term SGA | Term | <10<sup>th</sup> |
147+
| 0 | Term AGA | Term | 10<sup>th</sup> to 90<sup>th</sup> |
148+
| 1 | Term LGA | Term | \>90<sup>th</sup> |
149+
150+
133151
#### Stunting
134152
![](./readme/readme_cstunting.png)
135153

136-
The function outputs a variable with the following values and labels:
154+
The function outputs a variable with the following values and labels. Outlier
155+
observations are only labelled if the `outliers` option is specified:
137156

138157
| Value | Meaning | Z-score range |
139158
|-------|-----------------|---------------|
@@ -145,7 +164,8 @@ The function outputs a variable with the following values and labels:
145164
#### Wasting
146165
![](./readme/readme_cwasting.png)
147166

148-
The function outputs a variable with the following values and labels:
167+
The function outputs a variable with the following values and labels. Outlier
168+
observations are only labelled if the `outliers` option is specified:
149169

150170
| Value | Meaning | Z-score range |
151171
|-------|----------------|---------------|
@@ -158,7 +178,8 @@ The function outputs a variable with the following values and labels:
158178
#### Weight-for-age
159179
![](./readme/readme_cwfa.png)
160180

161-
The function outputs a variable with the following values and labels:
181+
The function outputs a variable with the following values and labels. Outlier
182+
observations are only labelled if the `outliers` option is specified:
162183

163184
| Value | Meaning | Z-score range |
164185
|-------|----------------------|---------------|
@@ -283,10 +304,6 @@ remove any observations which were not made at birth. We then use the
283304
```
284305

285306
## Known issues and bug reporting
286-
For coefficient-based standards (i.e. the `who_gs()` standards and some of the `ig_nbs()`
287-
standards), providing floats/doubles to the `xvar()` or `gest_age()` options may result
288-
in massive slowdowns. This is going to be addressed in a coming update.
289-
290307
We kindly request that users note any bugs, issues, or feature requests on the GitHub
291308
[issues page](https://github.com/lshtm-gigs/gigs-stata/issues).
292309

_gclassify_sga.ado

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
capture program drop _gclassify_sga
22
capture program drop SGA_Badsyntax
3-
*! version 0.2.4 (SJxx-x: dmxxxx)
3+
*! version 0.3.0 (SJxx-x: dmxxxx)
44
program define _gclassify_sga
55
version 16
66
preserve
@@ -18,13 +18,14 @@ program define _gclassify_sga
1818
error 198
1919
}
2020

21+
syntax [if] [in], GEST_days(varname numeric) sex(varname) SEXCode(string) /*
22+
*/ [SEVere by(string)]
23+
2124
if `"`by'"' != "" {
2225
_egennoby classify_sga() `"`by'"'
2326
/* NOTREACHED */
2427
}
2528

26-
syntax [if] [in], gest_age(varname numeric) sex(varname) SEXCode(string)
27-
2829
local 1 `sexcode'
2930
*zap commas to spaces (i.e. commas indulged)
3031
local 1 : subinstr local 1 "," " ", all
@@ -53,17 +54,23 @@ program define _gclassify_sga
5354
marksample touse
5455

5556
tempvar p_temp
56-
egen double `p_temp' = ig_nbs(`input', "wfga", "v2p"), ///
57-
gest_age(`gest_age') sex(`sex') sexcode(m="`male'", f="`female'")
57+
egen double `p_temp' = ig_nbs(`input', "wfga", "v2c"), ///
58+
gest_days(`gest_days') sex(`sex') sexcode(m="`male'", f="`female'")
5859
qui {
5960
generate `type' `return' = 0
6061
replace `return' = -1 if float(`p_temp') < 0.1
6162
replace `return' = 1 if float(`p_temp') > 0.9
62-
replace `return' = -2 if float(`p_temp') < 0.03
6363
replace `return' = . if `p_temp' == . | `touse' == 0
64-
}
65-
capture label define sga_labels -2 "severely SGA" -1 "SGA" 0 "AGA" 1 "LGA"
66-
label values `return' sga_labels
64+
}
65+
cap la de sga_labels -1 "SGA" 0 "AGA" 1 "LGA"
66+
cap la de sev_sga_labels -2 "severely SGA" -1 "SGA" 0 "AGA" 1 "LGA"
67+
if "`severe'"=="" {
68+
la val `return' sga_labels
69+
}
70+
else {
71+
replace `return' = -2 if float(`p_temp') < 0.03
72+
la val `return' sev_sga_labels
73+
}
6774
restore, not
6875
end
6976

_gclassify_stunting.ado

+23-59
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
capture program drop _gclassify_stunting
2-
*! version 0.2.4 (SJxx-x: dmxxxx)
2+
*! version 0.3.0 (SJxx-x: dmxxxx)
33
program define _gclassify_stunting
44
version 16
55
preserve
@@ -16,15 +16,15 @@ program define _gclassify_stunting
1616
if `"`paren'"' != ")" {
1717
error 198
1818
}
19-
19+
20+
syntax [if] [in], GEST_days(varname numeric) age_days(varname numeric) /*
21+
*/ sex(varname) SEXCode(string) [OUTliers BY(string)]
22+
2023
if `"`by'"' != "" {
2124
_egennoby classify_stunting() `"`by'"'
2225
/* NOTREACHED */
2326
}
24-
25-
syntax [if] [in], GA_at_birth(varname numeric) age_days(varname numeric) /*
26-
*/ lenht_method(varname) LENHTCode(string) sex(varname) SEXCode(string)
27-
27+
2828
local 1 `sexcode'
2929
local 1 : subinstr local 1 "," " ", all
3030
tokenize `"`1'"', parse("= ")
@@ -48,79 +48,43 @@ program define _gclassify_stunting
4848
local female "`3'"
4949
}
5050
else StuntingSex_Badsyntax
51-
52-
local 2 `lenhtcode'
53-
local 2 : subinstr local 2 "," " ", all
54-
tokenize `"`2'"', parse("= ")
55-
56-
if "`1'" == substr("length", 1, length("`1'")) {
57-
if "`2'" ~= "=" | "`5'" ~= "=" | /*
58-
*/ "`4'" ~= substr("height", 1, length("`4'")) | /*
59-
*/ "`7'" ~= "" {
60-
StuntingLenht_Badsyntax
61-
}
62-
local length "`3'"
63-
local height "`6'"
64-
}
65-
else if "`1'" == substr("height", 1, length("`1'")) {
66-
if "`2'" ~= "=" | "`5'" ~= "=" | /*
67-
*/ "`4'" ~= substr("length", 1, length("`4'") | /*
68-
*/ "`7'" ~= "" {
69-
StuntingLenht_Badsyntax
70-
}
71-
local length "`6'"
72-
local height "`3'"
73-
}
74-
else StuntingLenht_Badsyntax
7551

7652
marksample touse
77-
78-
tempvar lenht_cm
79-
qui {
80-
generate double `lenht_cm' = `input'
81-
replace `lenht_cm' = `lenht_cm' - 0.7 ///
82-
if `age_days' >= 731 & `lenht_method' == "`length'"
83-
replace `lenht_cm' = `lenht_cm' + 0.7 ///
84-
if `age_days' < 731 & `lenht_method' == "`height'"
85-
}
86-
8753
tempvar pma_weeks z_PNG z_WHO z
8854
qui {
89-
gen double `pma_weeks' = round((`age_days' + `ga_at_birth') / 7)
90-
egen double `z_PNG' = ig_png(`lenht_cm', "lfa", "v2z"), ///
55+
gen double `pma_weeks' = floor((`age_days' + `gest_days') / 7)
56+
egen double `z_PNG' = ig_png(`input', "lfa", "v2z"), ///
9157
xvar(`pma_weeks') sex(`sex') sexcode(m="`male'", f="`female'")
92-
egen double `z_WHO' = who_gs(`lenht_cm', "lhfa", "v2z"), ///
58+
egen double `z_WHO' = who_gs(`input', "lhfa", "v2z"), ///
9359
xvar(`age_days') sex(`sex') sexcode(m="`male'", f="`female'")
9460

9561
gen double `z' = `z_PNG' if ///
96-
`ga_at_birth' >= 182 & `ga_at_birth' < 259 & ///
97-
`pma_weeks' >= 27 & `pma_weeks' < 64
98-
replace `z' = `z_WHO' if ///
99-
`ga_at_birth' < 182 | `ga_at_birth' >= 259 | `pma_weeks' < 27 | ///
100-
`pma_weeks' >= 64
62+
`gest_days' >= 182 & `gest_days' < 259 & ///
63+
`pma_weeks' >= 27 & `pma_weeks' <= 64
64+
replace `z' = `z_WHO' if `gest_days' >= 259 | ///
65+
(`gest_days' < 259 & `pma_weeks' > 64)
10166

10267
generate `type' `return' = .
10368
replace `return' = -1 if float(`z') <= -2
10469
replace `return' = -2 if float(`z') <= -3
105-
replace `return' = -10 if float(`z') < -6
10670
replace `return' = 0 if float(`z') > -2
107-
replace `return' = -10 if float(`z') > 6
10871
replace `return' = . if `z' == . | `touse' == 0
10972
}
110-
capture label define stunting_labels -10 "implausible" ///
111-
-2 "severe stunting" -1 "stunting" 0 "normal"
112-
label values `return' stunting_labels
73+
cap la de stunting_labs -2 "severe stunting" -1 "stunting" 0 "normal"
74+
cap la de stunting_labs_out -2 "severe stunting" -1 "stunting" 0 "normal" /*
75+
*/ 999 "outlier"
76+
if "`outliers'"=="" {
77+
la val `return' stunting_labs
78+
}
79+
else {
80+
qui replace `return' = 999 if abs(float(`z')) > 6 & `return' != .
81+
la val `return' stunting_labs_out
82+
}
11383
restore, not
11484
end
11585

11686
capture prog drop StuntingSex_Badsyntax
11787
program StuntingSex_Badsyntax
11888
di as err "sexcode() option invalid: see {help ig_nbs}"
11989
exit 198
120-
end
121-
122-
capture prog drop StuntingLenht_Badsyntax
123-
program StuntingLenht_Badsyntax
124-
di as err "lenhtcode() option invalid: see {help classify_stunting}"
125-
exit 198
12690
end

0 commit comments

Comments
 (0)