Skip to content

Commit

Permalink
Merge pull request #18 from lshtm-gigs/dev
Browse files Browse the repository at this point in the history
gigs 0.3.1
  • Loading branch information
simpar1471 authored Nov 22, 2023
2 parents 1db68ce + 153fd55 commit 97dbc42
Show file tree
Hide file tree
Showing 24 changed files with 163 additions and 120 deletions.
2 changes: 1 addition & 1 deletion _gclassify_sga.ado
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
capture program drop _gclassify_sga
capture program drop SGA_Badsyntax
*! version 0.3.0 (SJxx-x: dmxxxx)
*! version 0.3.1 (SJxx-x: dmxxxx)
program define _gclassify_sga
version 16
preserve
Expand Down
20 changes: 12 additions & 8 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.0 (SJxx-x: dmxxxx)
*! version 0.3.1 (SJxx-x: dmxxxx)
program define _gclassify_stunting
version 16
preserve
Expand Down Expand Up @@ -50,18 +50,22 @@ program define _gclassify_stunting
else StuntingSex_Badsyntax

marksample touse
tempvar pma_weeks z_PNG z_WHO z
tempvar pma_weeks pma_wks_floored z_NBS z_PNG z_WHO z
qui {
gen double `pma_weeks' = floor((`age_days' + `gest_days') / 7)
gen double `pma_weeks' = (`age_days' + `gest_days') / 7
gen double `pma_wks_floored' = floor(`pma_weeks')

egen double `z_NBS' = ig_nbs(`input', "lfga", "v2z"), ///
gest_days(`gest_days') sex(`sex') sexcode(m="`male'", f="`female'")
egen double `z_PNG' = ig_png(`input', "lfa", "v2z"), ///
xvar(`pma_weeks') sex(`sex') sexcode(m="`male'", f="`female'")
xvar(`pma_wks_floored') sex(`sex') sexcode(m="`male'", f="`female'")
egen double `z_WHO' = who_gs(`input', "lhfa", "v2z"), ///
xvar(`age_days') sex(`sex') sexcode(m="`male'", f="`female'")

gen double `z' = `z_PNG' if ///
`gest_days' >= 182 & `gest_days' < 259 & ///
gen double `z' = `z_NBS' if `age_days' == 0
replace `z' = `z_PNG' if `age_days' > 0 & `gest_days' < 259 & ///
`pma_weeks' >= 27 & `pma_weeks' <= 64
replace `z' = `z_WHO' if `gest_days' >= 259 | ///
replace `z' = `z_WHO' if `age_days' > 0 & `gest_days' >= 259 | ///
(`gest_days' < 259 & `pma_weeks' > 64)

generate `type' `return' = .
Expand Down
2 changes: 1 addition & 1 deletion _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.0 (SJxx-x: dmxxxx)
*! version 0.3.1 (SJxx-x: dmxxxx)
program define _gclassify_svn
version 16
preserve
Expand Down
17 changes: 7 additions & 10 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.0 (SJxx-x: dmxxxx)
*! version 0.3.1 (SJxx-x: dmxxxx)
program define _gclassify_wasting
version 16
preserve
Expand Down Expand Up @@ -54,25 +54,22 @@ program define _gclassify_wasting

tempvar z z_WHO_wfh z_WHO_wfl z_png
qui {
egen double `z_png' = ig_png(`weight_kg', "wfl", "v2z"), ///
xvar(`lenht_cm') sex(`sex') sexcode(m="`male'", f="`female'")
egen double `z_WHO_wfl' = who_gs(`weight_kg', "wfl", "v2z"), ///
xvar(`lenht_cm') sex(`sex') sexcode(m="`male'", f="`female'")
egen double `z_WHO_wfh' = who_gs(`weight_kg', "wfh", "v2z"), ///
xvar(`lenht_cm') sex(`sex') sexcode(m="`male'", f="`female'")
egen double `z_png' = ig_png(`weight_kg', "wfl", "v2z"), ///
xvar(`lenht_cm') sex(`sex') sexcode(m="`male'", f="`female'")

tempvar pma_weeks use_png use_who
gen double `pma_weeks' = floor((`age_days' + `gest_days') / 7)
gen byte `use_png' = 1 if `gest_days' >= 182 & `gest_days' < 259 & ///
gen double `pma_weeks' = (`age_days' + `gest_days') / 7
gen byte `use_png' = 1 if `gest_days' < 259 & ///
`pma_weeks' >= 27 & `pma_weeks' <= 64

gen double `z' = .
replace `z' = `z_png' if `use_png' == 1
replace `z' = `z_WHO_wfl' if `gest_days' >= 259 & ///
`age_days' < 731
replace `z' = `z_WHO_wfh' if `gest_days' >= 259 & ///
`age_days' >= 731

replace `z' = `z_WHO_wfl' if `use_png' != 1 & `age_days' < 731
replace `z' = `z_WHO_wfh' if `use_png' != 1 & `age_days' >= 731

gen `type' `return' = .
replace `return' = -1 if float(`z') <= -2
Expand Down
33 changes: 18 additions & 15 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.0 (SJxx-x: dmxxxx)
*! version 0.3.1 (SJxx-x: dmxxxx)
program define _gclassify_wfa
version 16
preserve
Expand All @@ -17,7 +17,7 @@ program define _gclassify_wfa
error 198
}

syntax [if] [in], GEST_days(varname numeric) age_days(varname) /*
syntax [if] [in], GEST_days(varname numeric) age_days(varname numeric) /*
*/ sex(varname) SEXCode(string) [OUTliers BY(string)]

if `"`by'"' != "" {
Expand All @@ -36,7 +36,7 @@ program define _gclassify_wfa
WFASex_Badsyntax
}
local male "`3'"
local female "`6'"
local female "`6'"
}
else if "`1'" == substr("female",1,length("`1'")) {
if "`2'" ~= "=" | "`5'" ~= "=" | /*
Expand All @@ -51,21 +51,24 @@ program define _gclassify_wfa

marksample touse

tempvar pma_weeks acronym z_WHO z_PNG z standard
tempvar pma_weeks pma_wks_floored z_NBS z_PNG z_WHO z
qui {
gen double `pma_weeks' = floor((`age_days' + `gest_days') / 7)
gen double `pma_weeks' = (`age_days' + `gest_days') / 7
gen double `pma_wks_floored' = floor(`pma_weeks')

egen double `z_NBS' = ig_nbs(`weight_kg', "wfga", "v2z"), ///
gest_days(`gest_days') sex(`sex') sexcode(m="`male'", f="`female'")
egen double `z_PNG' = ig_png(`weight_kg', "wfa", "v2z"), ///
xvar(`pma_weeks') sex(`sex') sexcode(m="`male'", f="`female'")
egen double `z_WHO' = who_gs(`weight_kg', "wfa", "v2z"), xvar(`age_days') ///
sex(`sex') sexcode(m="`male'", f="`female'")

gen double `z' = `z_PNG' if ///
`gest_days' >= 182 & `gest_days' < 259 & ///
`pma_weeks' >= 27 & `pma_weeks' < 64
replace `z' = `z_WHO' if ///
`gest_days' < 182 | `gest_days' >= 259 | `pma_weeks' < 27 | ///
`pma_weeks' >= 64
xvar(`pma_wks_floored') sex(`sex') sexcode(m="`male'", f="`female'")
egen double `z_WHO' = who_gs(`weight_kg', "wfa", "v2z"), ///
xvar(`age_days') sex(`sex') sexcode(m="`male'", f="`female'")

gen double `z' = `z_NBS' if `age_days' == 0
replace `z' = `z_PNG' if `age_days' > 0 & `gest_days' < 259 & ///
`pma_weeks' >= 27 & `pma_weeks' <= 64
replace `z' = `z_WHO' if `age_days' > 0 & `gest_days' >= 259 | ///
(`gest_days' < 259 & `pma_weeks' > 64)

generate `type' `return' = .
replace `return' = -1 if float(`z') <= -2
replace `return' = -2 if float(`z') <= -3
Expand Down
2 changes: 1 addition & 1 deletion _gig_nbs.ado
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
capture program drop _gig_nbs
capture program drop Badsexvar_nbs
capture program drop Badsyntax_nbs
*! version 0.3.0 (SJxx-x: dmxxxx)
*! version 0.3.1 (SJxx-x: dmxxxx)
program define _gig_nbs
version 16
preserve
Expand Down
2 changes: 1 addition & 1 deletion _gig_png.ado
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
capture program drop _gig_png
capture program drop Badsexvar_png
capture program drop Badsyntax_png
*! version 0.3.0 (SJxx-x: dmxxxx)
*! version 0.3.1 (SJxx-x: dmxxxx)
program define _gig_png
version 16
preserve
Expand Down
2 changes: 1 addition & 1 deletion _gwho_gs.ado
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
capture program drop _gwho_gs
capture program drop Badsexvar_who
capture program drop Badsyntax_who
*! version 0.3.0 (SJxx-x: dmxxxx)
*! version 0.3.1 (SJxx-x: dmxxxx)
program define _gwho_gs
version 16
preserve
Expand Down
68 changes: 50 additions & 18 deletions benchmarking/benchmark.do
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,47 @@
be checked out on the R package website in the benchmarking article
(https://lshtm-gigs.github.io/gigs/)
*/
clear all
foreach file in "_gclassify_sga.ado" "_gclassify_svn.ado" ///
"_gclassify_stunting.ado" "_gclassify_wasting.ado" ///
"_gclassify_wfa.ado" ///
"_gig_nbs.ado" "_gig_png.ado" "_gwho_gs.ado" ///
"gigs_ipolate_coeffs.ado" {
run "`file'"
}

// gigs 0.3.0:
// foreach i in 1 10 100 500 1000 5000 10000 25000 50000 75000 100000 {
// use "benchmarking/bench_dataset.dta", clear
// qui drop if _n > `i'
// di "Number of inputs: `i'"
// bench, reps(25) restore last: ///
// qui egen double z_gigs = who_gs(y, "wfa", "v2z"), ///
// xvar(x) sex(sex) sexcode(m=M, f=F)
// }
foreach i in 1 10 100 500 1000 5000 10000 25000 50000 75000 100000 {
use "benchmarking/bench_dataset.dta", clear
qui drop if _n > `i'
di "Number of inputs: `i'"
bench, reps(25) restore last: ///
qui egen double z_gigs = who_gs(y, "wfa", "v2z"), ///
xvar(x) sex(sex) sexcode(m=M, f=F)
}

// gigs 0.3.1:
// Number of inputs: 1
// Average over 25 runs: 0.008 seconds
// Number of inputs: 10
// Average over 25 runs: 0.010 seconds
// Average over 25 runs: 0.009 seconds
// Number of inputs: 100
// Average over 25 runs: 0.010 seconds
// Average over 25 runs: 0.009 seconds
// Number of inputs: 500
// Average over 25 runs: 0.011 seconds
// Average over 25 runs: 0.010 seconds
// Number of inputs: 1000
// Average over 25 runs: 0.013 seconds
// Average over 25 runs: 0.012 seconds
// Number of inputs: 5000
// Average over 25 runs: 0.028 seconds
// Number of inputs: 10000
// Average over 25 runs: 0.048 seconds
// Average over 25 runs: 0.047 seconds
// Number of inputs: 25000
// Average over 25 runs: 0.107 seconds
// Average over 25 runs: 0.106 seconds
// Number of inputs: 50000
// Average over 25 runs: 0.205 seconds
// Average over 25 runs: 0.204 seconds
// Number of inputs: 75000
// Average over 25 runs: 0.313 seconds
// Average over 25 runs: 0.310 seconds
// Number of inputs: 100000
// Average over 25 runs: 0.431 seconds
// Average over 25 runs: 0.410 seconds

// zanthro 1.0.2:
// foreach i in 1 10 100 500 1000 5000 10000 25000 50000 75000 100000 {
Expand Down Expand Up @@ -90,6 +98,30 @@ egen z_anthro = zanthro(y, wa, WHO), xvar(x) gender(sex) ///
// OLD VERSIONS OF GIGS --------------------------------------------------------
// Kept to note how development is progressing

// gigs 0.3.0:
// Number of inputs: 1
// Average over 25 runs: 0.008 seconds
// Number of inputs: 10
// Average over 25 runs: 0.010 seconds
// Number of inputs: 100
// Average over 25 runs: 0.010 seconds
// Number of inputs: 500
// Average over 25 runs: 0.011 seconds
// Number of inputs: 1000
// Average over 25 runs: 0.013 seconds
// Number of inputs: 5000
// Average over 25 runs: 0.028 seconds
// Number of inputs: 10000
// Average over 25 runs: 0.048 seconds
// Number of inputs: 25000
// Average over 25 runs: 0.107 seconds
// Number of inputs: 50000
// Average over 25 runs: 0.205 seconds
// Number of inputs: 75000
// Average over 25 runs: 0.313 seconds
// Number of inputs: 100000
// Average over 25 runs: 0.431 seconds

// gigs 0.2.4:
// Number of inputs: 1
// Average over 25 runs: 0.016 seconds
Expand Down
Loading

0 comments on commit 97dbc42

Please sign in to comment.