Skip to content

Commit

Permalink
Merge pull request #24 from lshtm-gigs/dev
Browse files Browse the repository at this point in the history
gigs 0.4.1
  • Loading branch information
simpar1471 authored Jan 24, 2024
2 parents 4a036b4 + 30b6ade commit 709e8f6
Show file tree
Hide file tree
Showing 26 changed files with 254 additions and 213 deletions.
211 changes: 104 additions & 107 deletions README.md

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions _gclassify_sga.ado → _gclassify_sfga.ado
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
capture program drop _gclassify_sga
capture program drop _gclassify_sfga
capture program drop SGA_Badsyntax
*! version 0.3.2 (SJxx-x: dmxxxx)
program define _gclassify_sga
*! version 0.4.0 (SJxx-x: dmxxxx)
program define _gclassify_sfga
version 16
preserve

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

if `"`by'"' != "" {
_egennoby classify_sga() `"`by'"'
_egennoby classify_sfga() `"`by'"'
/* NOTREACHED */
}

Expand Down Expand Up @@ -62,19 +62,19 @@ program define _gclassify_sga
replace `return' = 1 if float(`p_temp') > 0.9
replace `return' = . if missing(`p_temp') | `touse' == 0
}
cap la de sga_labels -1 "SGA" 0 "AGA" 1 "LGA"
cap la de sev_sga_labels -2 "severely SGA" -1 "SGA" 0 "AGA" 1 "LGA"
cap la de sfga_labels -1 "SGA" 0 "AGA" 1 "LGA"
cap la de sev_sfga_labels -2 "severely SGA" -1 "SGA" 0 "AGA" 1 "LGA"
if "`severe'"=="" {
la val `return' sga_labels
la val `return' sfga_labels
}
else {
replace `return' = -2 if float(`p_temp') < 0.03
la val `return' sev_sga_labels
la val `return' sev_sfga_labels
}
restore, not
end

program SGA_Badsyntax
di as err "sexcode() option invalid: see {help classify_sga}"
di as err "sexcode() option invalid: see {help classify_sfga}"
exit 198
end
8 changes: 4 additions & 4 deletions _gclassify_stunting.ado
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
capture program drop _gclassify_stunting
*! version 0.3.2 (SJxx-x: dmxxxx)
*! version 0.4.0 (SJxx-x: dmxxxx)
program define _gclassify_stunting
version 16
preserve
Expand Down Expand Up @@ -74,9 +74,9 @@ program define _gclassify_stunting
replace `return' = 0 if float(`z') > -2
replace `return' = . if missing(`z') | `touse' == 0
}
cap la de stunting_labs -2 "severe stunting" -1 "stunting" 0 "normal"
cap la de stunting_labs_out -2 "severe stunting" -1 "stunting" 0 "normal" /*
*/ 999 "outlier"
cap la de stunting_labs -2 "severe stunting" -1 "stunting" 0 "not stunting"
cap la de stunting_labs_out -2 "severe stunting" -1 "stunting" 0 /*
*/ "not stunting" 999 "outlier"
if "`outliers'"=="" {
la val `return' stunting_labs
}
Expand Down
18 changes: 9 additions & 9 deletions _gclassify_svn.ado
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
capture program drop _gclassify_svn
capture program drop SVN_Badsyntax
*! version 0.3.2 (SJxx-x: dmxxxx)
*! version 0.4.0 (SJxx-x: dmxxxx)
program define _gclassify_svn
version 16
preserve
Expand Down Expand Up @@ -53,18 +53,18 @@ program define _gclassify_svn

marksample touse

tempvar sga is_term is_sga
tempvar sfga is_term is_sfga
qui {
egen double `sga' = classify_sga(`input'), ///
egen double `sfga' = classify_sfga(`input'), ///
gest_days(`gest_days') sex(`sex') sexcode(m="`male'", f="`female'")
gen `is_term' = `gest_days' >= 259 // 259 days = 37 weeks
gen `type' `return' = .
replace `return' = -4 if `is_term' == 0 & `sga' == -1
replace `return' = -3 if `is_term' == 0 & `sga' == 0
replace `return' = -2 if `is_term' == 0 & `sga' == 1
replace `return' = -1 if `is_term' == 1 & `sga' == -1
replace `return' = 0 if `is_term' == 1 & `sga' == 0
replace `return' = 1 if `is_term' == 1 & `sga' == 1
replace `return' = -4 if `is_term' == 0 & `sfga' == -1
replace `return' = -3 if `is_term' == 0 & `sfga' == 0
replace `return' = -2 if `is_term' == 0 & `sfga' == 1
replace `return' = -1 if `is_term' == 1 & `sfga' == -1
replace `return' = 0 if `is_term' == 1 & `sfga' == 0
replace `return' = 1 if `is_term' == 1 & `sfga' == 1
replace `return' = . if missing(`sga') | `touse' == 0
}
cap la de svn_labels -4 "Preterm SGA" -3 "Preterm AGA" -2 "Preterm LGA" ///
Expand Down
6 changes: 3 additions & 3 deletions _gclassify_wasting.ado
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
capture program drop _gclassify_wasting
*! version 0.3.2 (SJxx-x: dmxxxx)
*! version 0.4.0 (SJxx-x: dmxxxx)
program define _gclassify_wasting
version 16
preserve
Expand Down Expand Up @@ -80,9 +80,9 @@ program define _gclassify_wasting
*/ missing(`gest_days')
}
cap la def wasting_labs -2 "severe wasting" -1 "wasting" ///
0 "normal" 1 "overweight"
0 "not wasting" 1 "overweight"
cap la def wasting_labs_out -2 "severe wasting" -1 "wasting" ///
0 "normal" 1 "overweight" 999 "outlier"
0 "not wasting" 1 "overweight" 999 "outlier"

if "`outliers'"=="" {
la val `return' wasting_labs
Expand Down
6 changes: 3 additions & 3 deletions _gclassify_wfa.ado
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
capture program drop _gclassify_wfa
*! version 0.3.2 (SJxx-x: dmxxxx)
*! version 0.4.0 (SJxx-x: dmxxxx)
program define _gclassify_wfa
version 16
preserve
Expand Down Expand Up @@ -77,9 +77,9 @@ program define _gclassify_wfa
replace `return' = . if missing(`z') | `touse' == 0
}
cap la def wfa_labs -2 "severely underweight" -1 "underweight" ///
0 "normal" 1 "overweight"
0 "normal weight" 1 "overweight"
cap la def wfa_labs_out -2 "severely underweight" -1 "underweight" ///
0 "normal" 1 "overweight" 999 "outlier"
0 "normal weight" 1 "overweight" 999 "outlier"

if "`outliers'"=="" {
la val `return' wfa_labs
Expand Down
40 changes: 20 additions & 20 deletions classify_sga.sthlp → classify_sfga.sthlp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{smcl}
{* *! version 0.3.2 23 Nov 2023}{...}
{* *! version 0.4.0 23 Jan 2023}{...}
{vieweralsosee "" "--"}{...}
{vieweralsosee "gigs: Classification functions" "help classify_sga"}{...}
{viewerjumpto "Syntax" "classify_sga##syntax"}{...}
{viewerjumpto "Description" "classify_sga##description"}{...}
{viewerjumpto "Functions" "classify_sga##functions"}{...}
{viewerjumpto "Options" "classify_sga##options"}{...}
{viewerjumpto "Remarks" "classify_sga##remarks"}{...}
{viewerjumpto "Examples" "classify_sga##examples"}{...}

{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})}
{vieweralsosee "gigs: Classification functions" "help classify_sfga"}{...}
{viewerjumpto "Syntax" "classify_sfga##syntax"}{...}
{viewerjumpto "Description" "classify_sfga##description"}{...}
{viewerjumpto "Functions" "classify_sfga##functions"}{...}
{viewerjumpto "Options" "classify_sfga##options"}{...}
{viewerjumpto "Remarks" "classify_sfga##remarks"}{...}
{viewerjumpto "Examples" "classify_sfga##examples"}{...}

{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})}
{hline}

{title:Title}
Expand All @@ -21,7 +21,7 @@
{title:Syntax}

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

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

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

Expand Down Expand Up @@ -180,7 +180,7 @@
{dlgtab:Non-specific}

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

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

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

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

{pstd}Request that gigs classifies outlier/implasuible values with the {opt:outliers} option:{p_end}
{pstd}Request that gigs classifies outlier/implasuible values with the {cmd:outliers} option:{p_end}
{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}

{marker authors}{...}
Expand Down
2 changes: 1 addition & 1 deletion classify_stunting.sthlp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.h classify_sga
.h classify_sfga
2 changes: 1 addition & 1 deletion classify_svn.sthlp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.h classify_sga
.h classify_sfga
2 changes: 1 addition & 1 deletion classify_wasting.sthlp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.h classify_sga
.h classify_sfga
2 changes: 1 addition & 1 deletion classify_wfa.sthlp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.h classify_sga
.h classify_sfga
9 changes: 5 additions & 4 deletions gigs.pkg
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
v 0.4.0
d 'GIGS': Newborn and infant growth assessment using international growth standards
v 0.4.1
d 'GIGS': Fetal, neonatal, and infant growth assessment using international growth standards
d
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.
d
d Distribution-Date: 20240116
d License: GNU General Public License v3.0
d
F _gclassify_sga.ado
F _gclassify_sfga.ado
F _gclassify_stunting.ado
F _gclassify_svn.ado
F _gclassify_wasting.ado
Expand All @@ -16,7 +16,7 @@ F _gig_nbs.ado
F _gig_png.ado
F _gwho_gs.ado
F gigs_ipolate_coeffs.mo
F classify_sga.sthlp
F classify_sfga.sthlp
F classify_stunting.sthlp
F classify_svn.sthlp
F classify_wasting.sthlp
Expand All @@ -40,3 +40,4 @@ F whoLMS_wfl.dta
F who_gs.sthlp
f gigs_examples.do
f life6mo.dta
f life6mo.sthlp
6 changes: 3 additions & 3 deletions gigs.sthlp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{* *! version 0.4.0 07 Dec 2023}{...}
{vieweralsosee "" "--"}{...}
{vieweralsosee "gigs: Conversion functions" "help ig_nbs"}{...}
{vieweralsosee "gigs: Classification functions" "help classify_sga"}{...}
{vieweralsosee "gigs: Classification functions" "help classify_sfga"}{...}

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

{title:Title}
Expand Down Expand Up @@ -52,7 +52,7 @@

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

{p 4 14 2}Classification functions: {help classify_sga:documentation}
{p 4 14 2}Classification functions: {help classify_sfga:documentation}

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

Expand Down
Binary file modified gigs.stpr
Binary file not shown.
55 changes: 31 additions & 24 deletions gigs_examples.do
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
use life6mo
gen agedays = pma - gestage
use life6mo, clear
keep id gestage sex visitweek pma age_days weight_g
local 37weeks 7 * 37
list in f/10, noobs abbreviate(10) sep(10)
list in f/9, noobs abbreviate(10) sep(9)

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

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

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

gen double waz = waz_who if gestage > `37weeks'
replace waz = waz_png if gestage < `37weeks'
replace waz = waz_nbs if agedays == 0
replace waz = waz_nbs if age_days == 0

list visitweek gestage pma waz_* waz in f/10, noobs sep(10)
list visitweek gestage pma waz_* waz in f/9, noobs sep(9)
drop waz_*

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

use life6mo, clear
keep if (gestage - pma) == 0
egen sga = classify_sga(meaninfwgt/1000), ///
keep if (age_days) == 0
egen sfga = classify_sfga(weight_g/1000), ///
gest_days(gestage) sex(sex) sexcode(m=1, f=2)
graph bar, over(sfga) ///
title("Size-for-GA categorisations in the LIFE data extract") ///
note("") ///
ytitle("Percentage") ///
scheme(sj)
graph export "gigs_fig2.pdf"


egen svn = classify_svn(weight_g/1000), ///
gest_days(gestage) sex(sex) sexcode(m=1, f=2)
gen term_status = "Preterm" if gestage < `37weeks'
replace term_status = "Term" if gestage >= `37weeks'
graph bar, over(sga) by(term_status, ///
title("Percentage of each size-for-GA category by term status") ///
note("")) ///
graph bar, over(svn) ///
title("SVN categorisations in the LIFE data extract") ///
note("") ///
ytitle("Percentage") ///
scheme(sj)
graph export "gigs_fig2.pdf"
graph export "gigs_fig3.pdf"
4 changes: 2 additions & 2 deletions ig_nbs.sthlp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{smcl}
{* *! version 0.4.0 07 Dec 2023}{...}
{vieweralsosee "" "--"}{...}
{vieweralsosee "gigs: Classification functions" "help classify_sga"}{...}
{vieweralsosee "gigs: Classification functions" "help classify_sfga"}{...}
{viewerjumpto "Syntax" "ig_nbs##syntax"}{...}
{viewerjumpto "Description" "ig_nbs##description"}{...}
{viewerjumpto "Functions" "ig_nbs##functions"}{...}
Expand Down Expand Up @@ -310,7 +310,7 @@ also {it:fcn} dependent.

{title:Also see}

{p 4 14 2}Classification functions: {help classify_sga:documentation}
{p 4 14 2}Classification functions: {help classify_sfga:documentation}

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

Expand Down
Binary file modified life6mo.dta
Binary file not shown.
Loading

0 comments on commit 709e8f6

Please sign in to comment.