Skip to content

Commit 709e8f6

Browse files
authored
Merge pull request #24 from lshtm-gigs/dev
gigs 0.4.1
2 parents 4a036b4 + 30b6ade commit 709e8f6

26 files changed

+254
-213
lines changed

README.md

+104-107
Large diffs are not rendered by default.

_gclassify_sga.ado _gclassify_sfga.ado

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
capture program drop _gclassify_sga
1+
capture program drop _gclassify_sfga
22
capture program drop SGA_Badsyntax
3-
*! version 0.3.2 (SJxx-x: dmxxxx)
4-
program define _gclassify_sga
3+
*! version 0.4.0 (SJxx-x: dmxxxx)
4+
program define _gclassify_sfga
55
version 16
66
preserve
77

@@ -22,7 +22,7 @@ program define _gclassify_sga
2222
*/ [SEVere by(string)]
2323

2424
if `"`by'"' != "" {
25-
_egennoby classify_sga() `"`by'"'
25+
_egennoby classify_sfga() `"`by'"'
2626
/* NOTREACHED */
2727
}
2828

@@ -62,19 +62,19 @@ program define _gclassify_sga
6262
replace `return' = 1 if float(`p_temp') > 0.9
6363
replace `return' = . if missing(`p_temp') | `touse' == 0
6464
}
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"
65+
cap la de sfga_labels -1 "SGA" 0 "AGA" 1 "LGA"
66+
cap la de sev_sfga_labels -2 "severely SGA" -1 "SGA" 0 "AGA" 1 "LGA"
6767
if "`severe'"=="" {
68-
la val `return' sga_labels
68+
la val `return' sfga_labels
6969
}
7070
else {
7171
replace `return' = -2 if float(`p_temp') < 0.03
72-
la val `return' sev_sga_labels
72+
la val `return' sev_sfga_labels
7373
}
7474
restore, not
7575
end
7676

7777
program SGA_Badsyntax
78-
di as err "sexcode() option invalid: see {help classify_sga}"
78+
di as err "sexcode() option invalid: see {help classify_sfga}"
7979
exit 198
8080
end

_gclassify_stunting.ado

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
capture program drop _gclassify_stunting
2-
*! version 0.3.2 (SJxx-x: dmxxxx)
2+
*! version 0.4.0 (SJxx-x: dmxxxx)
33
program define _gclassify_stunting
44
version 16
55
preserve
@@ -74,9 +74,9 @@ program define _gclassify_stunting
7474
replace `return' = 0 if float(`z') > -2
7575
replace `return' = . if missing(`z') | `touse' == 0
7676
}
77-
cap la de stunting_labs -2 "severe stunting" -1 "stunting" 0 "normal"
78-
cap la de stunting_labs_out -2 "severe stunting" -1 "stunting" 0 "normal" /*
79-
*/ 999 "outlier"
77+
cap la de stunting_labs -2 "severe stunting" -1 "stunting" 0 "not stunting"
78+
cap la de stunting_labs_out -2 "severe stunting" -1 "stunting" 0 /*
79+
*/ "not stunting" 999 "outlier"
8080
if "`outliers'"=="" {
8181
la val `return' stunting_labs
8282
}

_gclassify_svn.ado

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
capture program drop _gclassify_svn
22
capture program drop SVN_Badsyntax
3-
*! version 0.3.2 (SJxx-x: dmxxxx)
3+
*! version 0.4.0 (SJxx-x: dmxxxx)
44
program define _gclassify_svn
55
version 16
66
preserve
@@ -53,18 +53,18 @@ program define _gclassify_svn
5353

5454
marksample touse
5555

56-
tempvar sga is_term is_sga
56+
tempvar sfga is_term is_sfga
5757
qui {
58-
egen double `sga' = classify_sga(`input'), ///
58+
egen double `sfga' = classify_sfga(`input'), ///
5959
gest_days(`gest_days') sex(`sex') sexcode(m="`male'", f="`female'")
6060
gen `is_term' = `gest_days' >= 259 // 259 days = 37 weeks
6161
gen `type' `return' = .
62-
replace `return' = -4 if `is_term' == 0 & `sga' == -1
63-
replace `return' = -3 if `is_term' == 0 & `sga' == 0
64-
replace `return' = -2 if `is_term' == 0 & `sga' == 1
65-
replace `return' = -1 if `is_term' == 1 & `sga' == -1
66-
replace `return' = 0 if `is_term' == 1 & `sga' == 0
67-
replace `return' = 1 if `is_term' == 1 & `sga' == 1
62+
replace `return' = -4 if `is_term' == 0 & `sfga' == -1
63+
replace `return' = -3 if `is_term' == 0 & `sfga' == 0
64+
replace `return' = -2 if `is_term' == 0 & `sfga' == 1
65+
replace `return' = -1 if `is_term' == 1 & `sfga' == -1
66+
replace `return' = 0 if `is_term' == 1 & `sfga' == 0
67+
replace `return' = 1 if `is_term' == 1 & `sfga' == 1
6868
replace `return' = . if missing(`sga') | `touse' == 0
6969
}
7070
cap la de svn_labels -4 "Preterm SGA" -3 "Preterm AGA" -2 "Preterm LGA" ///

_gclassify_wasting.ado

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
capture program drop _gclassify_wasting
2-
*! version 0.3.2 (SJxx-x: dmxxxx)
2+
*! version 0.4.0 (SJxx-x: dmxxxx)
33
program define _gclassify_wasting
44
version 16
55
preserve
@@ -80,9 +80,9 @@ program define _gclassify_wasting
8080
*/ missing(`gest_days')
8181
}
8282
cap la def wasting_labs -2 "severe wasting" -1 "wasting" ///
83-
0 "normal" 1 "overweight"
83+
0 "not wasting" 1 "overweight"
8484
cap la def wasting_labs_out -2 "severe wasting" -1 "wasting" ///
85-
0 "normal" 1 "overweight" 999 "outlier"
85+
0 "not wasting" 1 "overweight" 999 "outlier"
8686

8787
if "`outliers'"=="" {
8888
la val `return' wasting_labs

_gclassify_wfa.ado

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
capture program drop _gclassify_wfa
2-
*! version 0.3.2 (SJxx-x: dmxxxx)
2+
*! version 0.4.0 (SJxx-x: dmxxxx)
33
program define _gclassify_wfa
44
version 16
55
preserve
@@ -77,9 +77,9 @@ program define _gclassify_wfa
7777
replace `return' = . if missing(`z') | `touse' == 0
7878
}
7979
cap la def wfa_labs -2 "severely underweight" -1 "underweight" ///
80-
0 "normal" 1 "overweight"
80+
0 "normal weight" 1 "overweight"
8181
cap la def wfa_labs_out -2 "severely underweight" -1 "underweight" ///
82-
0 "normal" 1 "overweight" 999 "outlier"
82+
0 "normal weight" 1 "overweight" 999 "outlier"
8383

8484
if "`outliers'"=="" {
8585
la val `return' wfa_labs

classify_sga.sthlp classify_sfga.sthlp

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{smcl}
2-
{* *! version 0.3.2 23 Nov 2023}{...}
2+
{* *! version 0.4.0 23 Jan 2023}{...}
33
{vieweralsosee "" "--"}{...}
4-
{vieweralsosee "gigs: Classification functions" "help classify_sga"}{...}
5-
{viewerjumpto "Syntax" "classify_sga##syntax"}{...}
6-
{viewerjumpto "Description" "classify_sga##description"}{...}
7-
{viewerjumpto "Functions" "classify_sga##functions"}{...}
8-
{viewerjumpto "Options" "classify_sga##options"}{...}
9-
{viewerjumpto "Remarks" "classify_sga##remarks"}{...}
10-
{viewerjumpto "Examples" "classify_sga##examples"}{...}
11-
12-
{hi:help classify_sga, help classify_svn, help classify_stunting, help classify_wasting, help classify_wfa}{right: ({browse "https://www.overleaf.com/project/641db63564edd62fb54c963b":SJXX-X: st0001})}
4+
{vieweralsosee "gigs: Classification functions" "help classify_sfga"}{...}
5+
{viewerjumpto "Syntax" "classify_sfga##syntax"}{...}
6+
{viewerjumpto "Description" "classify_sfga##description"}{...}
7+
{viewerjumpto "Functions" "classify_sfga##functions"}{...}
8+
{viewerjumpto "Options" "classify_sfga##options"}{...}
9+
{viewerjumpto "Remarks" "classify_sfga##remarks"}{...}
10+
{viewerjumpto "Examples" "classify_sfga##examples"}{...}
11+
12+
{hi:help classify_sfga, help classify_svn, help classify_stunting, help classify_wasting, help classify_wfa}{right: ({browse "https://www.overleaf.com/project/641db63564edd62fb54c963b":SJXX-X: st0001})}
1313
{hline}
1414

1515
{title:Title}
@@ -21,7 +21,7 @@
2121
{title:Syntax}
2222

2323
{p 8 17 2}{cmd:egen} [{it:{help datatype:type}}] {newvar} {cmd:=}
24-
{cmd:classify_sga}{cmd:(}{varname}{cmd:)}
24+
{cmd:classify_sfga}{cmd:(}{varname}{cmd:)}
2525
{ifin}{cmd:,}
2626
{cmdab:gest:_days}{cmd:(}{varname}{cmd:)} {cmdab:sex}{cmd:(}{varname}{cmd:)}
2727
{cmdab:sexc:ode}{cmd:(}{cmdab:m:ale=}{it:code}{cmd:,} {cmdab:f:emale=}{it:code}{cmd:)}
@@ -79,7 +79,7 @@
7979
{marker functions}{...}
8080
{title:Functions for egen}
8181

82-
{p 4 4 2}{hi:classify_sga(}{varname}{cmd:)} is used to classify size for
82+
{p 4 4 2}{hi:classify_sfga(}{varname}{cmd:)} is used to classify size for
8383
gestational age in newborns according to INTERGROWTH-21st
8484
weight-for-gestational age standards. It produces a variable with the
8585
following values and labels:
@@ -126,7 +126,7 @@
126126
{col 20}{hline 38}
127127
{col 21}{cmd: -2}{col 27}Severe stunting{col 45}-5 to -3
128128
{col 21}{cmd: -1}{col 27}Stunting {col 45}-3 to -2
129-
{col 21}{cmd: 0}{col 27}Normal {col 45}-2 to 5
129+
{col 21}{cmd: 0}{col 27}Not stunting {col 45}-2 to 5
130130
{col 21}{cmd:999}{col 27}Outlier {col 45}<-5 or >5
131131

132132
{pmore}This function takes one argument:
@@ -146,7 +146,7 @@
146146
{col 20}{hline 38}
147147
{col 21}{cmd: -2}{col 27}Severe wasting{col 45}-5 to -3
148148
{col 21}{cmd: -1}{col 27}Wasting {col 45}-3 to -2
149-
{col 21}{cmd: 0}{col 27}Normal {col 45}-2 to 2
149+
{col 21}{cmd: 0}{col 27}Not wasting {col 45}-2 to 2
150150
{col 21}{cmd: 1}{col 27}Overweight {col 45}2 to 5
151151
{col 21}{cmd:999}{col 27}Outlier {col 45}<-5 or >5
152152

@@ -180,7 +180,7 @@
180180
{dlgtab:Non-specific}
181181

182182
{phang}{opt gest:_days(varname numeric)} specifies gestational age in days for
183-
newborns. In {cmd:classify_sga()} and {cmd:classify_sga()},any value outside
183+
newborns. In {cmd:classify_sfga()} and {cmd:classify_svn()},any value outside
184184
the range of valid gestational ages as specified in the
185185
{help ig_nbs##tab1:ig_nbs() documentation} will return a missing value. In the
186186
other classification functions, this variable is used to compute post-menstrual
@@ -229,11 +229,11 @@
229229
{marker examples}{...}
230230
{title:Examples}
231231

232-
{pstd}Classifying SGA, where {cmd:sex} contains the codes {cmd:1} and {cmd:2}:{p_end}
233-
{phang2}{cmd:. egen sga = classify_sga(weight_kg), gest_days(ga_days) sex(sex) sexcode(male=1, female=2)}
232+
{pstd}Classifying size-for-GA, where {cmd:sex} contains the codes {cmd:1} and {cmd:2}:{p_end}
233+
{phang2}{cmd:. egen sfga = classify_sfga(weight_kg), gest_days(ga_days) sex(sex) sexcode(male=1, female=2)}
234234

235-
{pstd}Include severe SGA classifications with the {opt:severe} option:{p_end}
236-
{phang2}{cmd:. egen sga = classify_sga(weight_kg), gest_days(ga_days) sex(sex) sexcode(male=1, female=2) severe}
235+
{pstd}Include severe size-for-GA classifications with the {opt:severe} option:{p_end}
236+
{phang2}{cmd:. egen sfga = classify_sfga(weight_kg), gest_days(ga_days) sex(sex) sexcode(male=1, female=2) severe}
237237

238238
{pstd}Classifying stunting, where {cmd:sex} contains the codes {cmd:M} and {cmd:F}:{p_end}
239239
{phang2}{cmd:. egen stunting = classify_stunting(weight_kg), gest_days(ga_days) age_days(age) sex(sex) sexcode(male=M, female=F)}
@@ -244,7 +244,7 @@
244244
{pstd}You can use just the first letters of the {cmd:lenht_cm()}, {cmd:gest_days()}, and {cmd:sexcode()} arguments instead:{p_end}
245245
{phang2}{cmd:. egen wasting = classify_wasting(weight_kg), lenht(lenht_cm) gest(ga_days) age_days(age) sex(sex) sexc(m=Male, f=Female)}
246246

247-
{pstd}Request that gigs classifies outlier/implasuible values with the {opt:outliers} option:{p_end}
247+
{pstd}Request that gigs classifies outlier/implasuible values with the {cmd:outliers} option:{p_end}
248248
{phang2}{cmd:. egen wasting = classify_wasting(weight_kg), lenht(lenht_cm) gest(ga_days) age_days(age) sex(sex) sexc(m=Male, f=Female) outliers}
249249

250250
{marker authors}{...}

classify_stunting.sthlp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.h classify_sga
1+
.h classify_sfga

classify_svn.sthlp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.h classify_sga
1+
.h classify_sfga

classify_wasting.sthlp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.h classify_sga
1+
.h classify_sfga

classify_wfa.sthlp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.h classify_sga
1+
.h classify_sfga

gigs.pkg

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
v 0.4.0
2-
d 'GIGS': Newborn and infant growth assessment using international growth standards
1+
v 0.4.1
2+
d 'GIGS': Fetal, neonatal, and infant growth assessment using international growth standards
33
d
44
d gigs provides a single, simple interface for working with outputs from the INTERGROWTH-21st project and the WHO Child Growth standards. You will find functions for converting between anthropometric measures (e.g. weight or length) to z-scores and centiles, and the inverse. Also included are functions for classifying newborn and infant growth according to DHS guidelines.
55
d
66
d Distribution-Date: 20240116
77
d License: GNU General Public License v3.0
88
d
9-
F _gclassify_sga.ado
9+
F _gclassify_sfga.ado
1010
F _gclassify_stunting.ado
1111
F _gclassify_svn.ado
1212
F _gclassify_wasting.ado
@@ -16,7 +16,7 @@ F _gig_nbs.ado
1616
F _gig_png.ado
1717
F _gwho_gs.ado
1818
F gigs_ipolate_coeffs.mo
19-
F classify_sga.sthlp
19+
F classify_sfga.sthlp
2020
F classify_stunting.sthlp
2121
F classify_svn.sthlp
2222
F classify_wasting.sthlp
@@ -40,3 +40,4 @@ F whoLMS_wfl.dta
4040
F who_gs.sthlp
4141
f gigs_examples.do
4242
f life6mo.dta
43+
f life6mo.sthlp

gigs.sthlp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
{* *! version 0.4.0 07 Dec 2023}{...}
33
{vieweralsosee "" "--"}{...}
44
{vieweralsosee "gigs: Conversion functions" "help ig_nbs"}{...}
5-
{vieweralsosee "gigs: Classification functions" "help classify_sga"}{...}
5+
{vieweralsosee "gigs: Classification functions" "help classify_sfga"}{...}
66

7-
{hi: help ig_nbs, help classify_sga}{right: ({browse "https://www.overleaf.com/project/641db63564edd62fb54c963b":SJXX-X: st0001})}
7+
{hi: help ig_nbs, help classify_sfga}{right: ({browse "https://www.overleaf.com/project/641db63564edd62fb54c963b":SJXX-X: st0001})}
88
{hline}
99

1010
{title:Title}
@@ -52,7 +52,7 @@
5252

5353
{p 4 14 2}Conversion functions: {help ig_nbs:documentation}
5454

55-
{p 4 14 2}Classification functions: {help classify_sga:documentation}
55+
{p 4 14 2}Classification functions: {help classify_sfga:documentation}
5656

5757
{p 4 14 2}Article: {it:Stata Journal}, volume XX, number X: {browse "https://www.overleaf.com/project/641db63564edd62fb54c963b":st0001}
5858

gigs.stpr

62 Bytes
Binary file not shown.

gigs_examples.do

+31-24
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
use life6mo
2-
gen agedays = pma - gestage
1+
use life6mo, clear
2+
keep id gestage sex visitweek pma age_days weight_g
33
local 37weeks 7 * 37
4-
list in f/10, noobs abbreviate(10) sep(10)
4+
list in f/9, noobs abbreviate(10) sep(9)
55

6-
egen double waz_nbs = ig_nbs(meaninfwgt/1000, "wfga", "v2z") ///
7-
if agedays == 0, ///
6+
egen double waz_nbs = ig_nbs(weight_g/1000, "wfga", "v2z") ///
7+
if age_days == 0, ///
88
gest_days(gestage) sex(sex) sexcode(m=1, f=2)
99

10-
egen double waz_who = who_gs(meaninfwgt/1000, "wfa", "v2z") ///
11-
if agedays > 0 & gestage >= `37weeks', ///
12-
xvar(agedays) sex(sex) sexcode(m=1, f=2)
10+
egen double waz_who = who_gs(weight_g/1000, "wfa", "v2z") ///
11+
if age_days > 0 & gestage >= `37weeks', ///
12+
xvar(age_days) sex(sex) sexcode(m=1, f=2)
1313

1414
gen pma_weeks = pma / 7
15-
gen pma_weeks_floored = floor(pma / 7)
16-
egen double waz_png = ig_png(meaninfwgt/1000, "wfa", "v2z") ///
17-
if gestage < `37weeks' & agedays > 0, ///
18-
xvar(pma_weeks_floored) sex(sex) sexcode(m=1, f=2)
19-
drop pma_weeks pma_weeks_floored
15+
egen double waz_png = ig_png(weight_g/1000, "wfa", "v2z") ///
16+
if age_days > 0 & gestage < `37weeks', ///
17+
xvar(pma_weeks) sex(sex) sexcode(m=1, f=2)
18+
drop pma_weeks
2019

2120
gen double waz = waz_who if gestage > `37weeks'
2221
replace waz = waz_png if gestage < `37weeks'
23-
replace waz = waz_nbs if agedays == 0
22+
replace waz = waz_nbs if age_days == 0
2423

25-
list visitweek gestage pma waz_* waz in f/10, noobs sep(10)
24+
list visitweek gestage pma waz_* waz in f/9, noobs sep(9)
2625
drop waz_*
2726

2827
gen preterm = gestage < `37weeks'
2928
collapse waz, by(visitweek preterm)
3029
line waz visitweek if preterm == 0 || line waz visitweek if preterm == 1 ||, ///
31-
title("WAZ in term/preterm infants in the LIFE study") ///
30+
title("WAZ in 300 infants from the LIFE data extract") ///
3231
xtitle("Visit week") ///
3332
ytitle("Weight-for-age z-score (WAZ)") ///
3433
xlabel(0 1 2 4 6 10 14 18 26) ///
@@ -37,14 +36,22 @@ line waz visitweek if preterm == 0 || line waz visitweek if preterm == 1 ||, ///
3736
graph export "gigs_fig1.pdf"
3837

3938
use life6mo, clear
40-
keep if (gestage - pma) == 0
41-
egen sga = classify_sga(meaninfwgt/1000), ///
39+
keep if (age_days) == 0
40+
egen sfga = classify_sfga(weight_g/1000), ///
41+
gest_days(gestage) sex(sex) sexcode(m=1, f=2)
42+
graph bar, over(sfga) ///
43+
title("Size-for-GA categorisations in the LIFE data extract") ///
44+
note("") ///
45+
ytitle("Percentage") ///
46+
scheme(sj)
47+
graph export "gigs_fig2.pdf"
48+
49+
50+
egen svn = classify_svn(weight_g/1000), ///
4251
gest_days(gestage) sex(sex) sexcode(m=1, f=2)
43-
gen term_status = "Preterm" if gestage < `37weeks'
44-
replace term_status = "Term" if gestage >= `37weeks'
45-
graph bar, over(sga) by(term_status, ///
46-
title("Percentage of each size-for-GA category by term status") ///
47-
note("")) ///
52+
graph bar, over(svn) ///
53+
title("SVN categorisations in the LIFE data extract") ///
54+
note("") ///
4855
ytitle("Percentage") ///
4956
scheme(sj)
50-
graph export "gigs_fig2.pdf"
57+
graph export "gigs_fig3.pdf"

ig_nbs.sthlp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{smcl}
22
{* *! version 0.4.0 07 Dec 2023}{...}
33
{vieweralsosee "" "--"}{...}
4-
{vieweralsosee "gigs: Classification functions" "help classify_sga"}{...}
4+
{vieweralsosee "gigs: Classification functions" "help classify_sfga"}{...}
55
{viewerjumpto "Syntax" "ig_nbs##syntax"}{...}
66
{viewerjumpto "Description" "ig_nbs##description"}{...}
77
{viewerjumpto "Functions" "ig_nbs##functions"}{...}
@@ -310,7 +310,7 @@ also {it:fcn} dependent.
310310

311311
{title:Also see}
312312

313-
{p 4 14 2}Classification functions: {help classify_sga:documentation}
313+
{p 4 14 2}Classification functions: {help classify_sfga:documentation}
314314

315315
{p 4 14 2}Article: {it:Stata Journal}, volume XX, number X: {browse "https://www.overleaf.com/project/641db63564edd62fb54c963b":st0001}
316316

life6mo.dta

-158 KB
Binary file not shown.

0 commit comments

Comments
 (0)