Skip to content

Commit

Permalink
Merge pull request #359 from worldbank/use-repkit
Browse files Browse the repository at this point in the history
Use repkit
  • Loading branch information
kbjarkefur authored Apr 4, 2024
2 parents d464261 + bbd8070 commit 63f2abe
Show file tree
Hide file tree
Showing 121 changed files with 575 additions and 5,202 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
!.gitattributes
#.io page
_config.yml
!reproot.yaml

# Keep markdown files used for documentation on GitHub
!README.md
Expand Down Expand Up @@ -74,3 +75,5 @@ test/

* Ignore the local dev env set up by repado
run/dev-env/

run/ieboilstart/ado-test/
Binary file removed ietoolkit.stpr
Binary file not shown.
2 changes: 2 additions & 0 deletions reproot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project_name : ietoolkit
root_name : clone
28 changes: 21 additions & 7 deletions run/iebaltab/iebaltab1.do
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@

* Set versson and seed
ieboilstart , version(13.1)
`r(version)'
************************
* Set up root paths if not already set, and set up dev environment

reproot, project("ietoolkit") roots("clone") prefix("ietk_")
global runfldr "${ietk_clone}/run"
global srcfldr "${ietk_clone}/src"

* Install the version of this package in
* the plus-ado folder in the test folder
cap mkdir "${runfldr}/dev-env"
repado using "${runfldr}/dev-env"

cap net uninstall ietoolkit
net install ietoolkit, from("${ietk_clone}/src") replace

* Set version to target version of ietoolkit
ieboilstart , version(13.1)
`r(version)'

* Load the command from file and utils
qui do "src/ado_files/iebaltab.ado"
qui do "run/iebaltab/iebaltab_run_utils.do"
qui do "run/run_utils.do"
qui do "${runfldr}/iebaltab/iebaltab_run_utils.do"
qui do "${runfldr}/run_utils.do"

* Folder local and make sure it is created
local out "run/iebaltab/outputs/iebaltab1"
local out "${runfldr}/iebaltab/outputs/iebaltab1"
ie_recurse_mkdir, folder("`out'")

************* Regular
Expand Down
319 changes: 169 additions & 150 deletions run/iebaltab/iebaltab2.do
Original file line number Diff line number Diff line change
@@ -1,154 +1,173 @@

ieboilstart , version(13.1)
`r(version)'
************************
* Set up root paths if not already set, and set up dev environment

sysuse auto, clear
reproot, project("ietoolkit") roots("clone") prefix("ietk_")
global runfldr "${ietk_clone}/run"
global srcfldr "${ietk_clone}/src"

set seed 232197 // obtained from bit.ly/stata-random on 2022-10-11 22:16:30 UTC
* Install the version of this package in
* the plus-ado folder in the test folder
cap mkdir "${runfldr}/dev-env"
repado using "${runfldr}/dev-env"

gen random = runiform()

gen tmt = (random > .33)
replace tmt = 2 if (random > .66)

split make, gen(strata)
encode strata1, gen(stratum)
drop strata*

local vars price mpg trunk headroom weight length turn displacement gear_ratio

qui do "src/ado_files/iebaltab.ado"
qui do "run/run_utils.do"

local out "run/iebaltab/outputs/iebaltab2"
ie_recurse_mkdir, folder("`out'")

**# Export options ---------------------------------------------------------------

preserve
iebaltab `vars', grpvar(foreign) browse
restore

iebaltab `vars', grpvar(foreign) ///
savexlsx("`out'/2g.xlsx") ///
savecsv("`out'/2g-control.csv") ///
savetex("`out'/2g.tex") ///
replace

iebaltab `vars', grpvar(tmt) ///
savetex("`out'/3g.tex") ///
replace

**# Column and row options -----------------------------------------------------

* Should throw error: file exists
cap iebaltab `vars', grpvar(foreign) ///
control(1) ///
savetex("`out'/2g.tex")

assert _rc == 602

* control
iebaltab `vars', grpvar(foreign) ///
control(0) ///
savetex("`out'/2g-control.tex") ///
replace

* Three groups
iebaltab `vars', grpvar(tmt) ///
savetex("`out'/3g.tex") ///
replace

iebaltab `vars', grpvar(tmt) ///
control(0) ///
savetex("`out'/3g-control.tex") ///
replace

* order(groupcodelist)
iebaltab `vars', grpvar(tmt) ///
order(2) ///
savetex("`out'/3g-order.tex") ///
replace

iebaltab `vars', grpvar(tmt) ///
control(0) order(2 1) ///
savetex("`out'/3g-control-order.tex") ///
replace

* total
iebaltab `vars', grpvar(tmt) ///
total ///
savetex("`out'/3g-total.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
total ///
savetex("`out'/2g-total.tex") ///
replace

* onerow
iebaltab `vars', grpvar(foreign) ///
onerow ///
savetex("`out'/2g-onerow.tex") ///
replace

**# Estimation options ---------------------------------------------------------
iebaltab `vars', grpvar(foreign) ///
fixedeffect(stratum) ///
savetex("`out'/2g-fe.tex") ///
replace

iebaltab `vars', grpvar(tmt) ///
covariates(foreign) ///
stats(pair(p)) ///
savetex("`out'/3g-cov.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
fixedeffect(stratum) ///
ftest ///
savetex("`out'/2g-ftest.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
fixedeffect(stratum) ///
feqtest ///
savetex("`out'/2g-feqtest.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
stats(pair(p)) ///
savetex("`out'/2g-pair.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
vce(cluster stratum) ///
stats(pair(p)) ///
savetex("`out'/2g-cluster.tex") ///
replace

**# Stat display options -------------------------------------------------------

iebaltab `vars', grpvar(foreign) ///
format("%9.2f") ///
savetex("`out'/2g-fmt.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
starsnoadd ///
savetex("`out'/2g-nostars.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
starlevels(.05 .01 .001) ///
savetex("`out'/2g-stars.tex") ///
replace


/* This should work at some point, but is not yet implemented
iebaltab `vars', grpvar(foreign) ///
stats(pair(diff se)) ///
savetex("`out'/2g-diff-se.tex") ///
replace
*/
exit
cap net uninstall ietoolkit
net install ietoolkit, from("${ietk_clone}/src") replace

* Set version to target version of ietoolkit
ieboilstart , version(13.1)
`r(version)'

* Load utils commands
qui do "${runfldr}/run_utils.do"

************************
* Run tests

sysuse auto, clear

set seed 232197 // obtained from bit.ly/stata-random on 2022-10-11 22:16:30 UTC

gen random = runiform()

gen tmt = (random > .33)
replace tmt = 2 if (random > .66)

split make, gen(strata)
encode strata1, gen(stratum)
drop strata*

local vars price mpg trunk headroom weight length turn displacement gear_ratio

local out "${runfldr}/iebaltab/outputs/iebaltab2"
ie_recurse_mkdir, folder("`out'")

**# Export options ---------------------------------------------------------------

preserve
iebaltab `vars', grpvar(foreign) browse
restore

iebaltab `vars', grpvar(foreign) ///
savexlsx("`out'/2g.xlsx") ///
savecsv("`out'/2g-control.csv") ///
savetex("`out'/2g.tex") ///
replace

iebaltab `vars', grpvar(tmt) ///
savetex("`out'/3g.tex") ///
replace

**# Column and row options -----------------------------------------------------

* Should throw error: file exists
cap iebaltab `vars', grpvar(foreign) ///
control(1) ///
savetex("`out'/2g.tex")

assert _rc == 602

* control
iebaltab `vars', grpvar(foreign) ///
control(0) ///
savetex("`out'/2g-control.tex") ///
replace

* Three groups
iebaltab `vars', grpvar(tmt) ///
savetex("`out'/3g.tex") ///
replace

iebaltab `vars', grpvar(tmt) ///
control(0) ///
savetex("`out'/3g-control.tex") ///
replace

* order(groupcodelist)
iebaltab `vars', grpvar(tmt) ///
order(2) ///
savetex("`out'/3g-order.tex") ///
replace

iebaltab `vars', grpvar(tmt) ///
control(0) order(2 1) ///
savetex("`out'/3g-control-order.tex") ///
replace

* total
iebaltab `vars', grpvar(tmt) ///
total ///
savetex("`out'/3g-total.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
total ///
savetex("`out'/2g-total.tex") ///
replace

* onerow
iebaltab `vars', grpvar(foreign) ///
onerow ///
savetex("`out'/2g-onerow.tex") ///
replace

**# Estimation options ---------------------------------------------------------
iebaltab `vars', grpvar(foreign) ///
fixedeffect(stratum) ///
savetex("`out'/2g-fe.tex") ///
replace

iebaltab `vars', grpvar(tmt) ///
covariates(foreign) ///
stats(pair(p)) ///
savetex("`out'/3g-cov.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
fixedeffect(stratum) ///
ftest ///
savetex("`out'/2g-ftest.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
fixedeffect(stratum) ///
feqtest ///
savetex("`out'/2g-feqtest.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
stats(pair(p)) ///
savetex("`out'/2g-pair.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
vce(cluster stratum) ///
stats(pair(p)) ///
savetex("`out'/2g-cluster.tex") ///
replace

**# Stat display options -------------------------------------------------------

iebaltab `vars', grpvar(foreign) ///
format("%9.2f") ///
savetex("`out'/2g-fmt.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
starsnoadd ///
savetex("`out'/2g-nostars.tex") ///
replace

iebaltab `vars', grpvar(foreign) ///
starlevels(.05 .01 .001) ///
savetex("`out'/2g-stars.tex") ///
replace


/* This should work at some point, but is not yet implemented
iebaltab `vars', grpvar(foreign) ///
stats(pair(diff se)) ///
savetex("`out'/2g-diff-se.tex") ///
replace
*/
exit
2 changes: 1 addition & 1 deletion run/iebaltab/outputs/iebaltab1/iebt-csv1.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"","","(486.238)","","(470.476)","","0.339","",""
"F-test of joint significance (F-stat)","","","","","","","","1.325"
"F-test, number of observations","","","","","","","","74"
"If the table includes missing values (.n, .o, .v etc.) see the Missing values section in the help file for the Stata command iebaltab for definitions of these values. Covariate(s) used in pairwise and f-test regressions: [mpg]. Fixed effect used in pairwise and f-test regressions: [foreign]. Significance: ***=.01, **=.05, *=.1. Full user input as written by user: [iebaltab weight price , savecsv(""run/iebaltab/outputs/iebaltab1/iebt-csv1"") savexlsx(""run/iebaltab/outputs/iebaltab1/iebt-xlsx1"") savetex(""run/iebaltab/outputs/iebaltab1/iebt-tex1"") texnotefile(""run/iebaltab/outputs/iebaltab1/iebt-tex1-note"") groupvar(tmt_cl) replace ftest feqtest control(1) cov(mpg) fixed(foreign)] ","","","","","","","",""
"If the table includes missing values (.n, .o, .v etc.) see the Missing values section in the help file for the Stata command iebaltab for definitions of these values. Covariate(s) used in pairwise and f-test regressions: [mpg]. Fixed effect used in pairwise and f-test regressions: [foreign]. Significance: ***=.01, **=.05, *=.1. Full user input as written by user: [iebaltab weight price , savecsv(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-csv1"") savexlsx(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-xlsx1"") savetex(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-tex1"") texnotefile(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-tex1-note"") groupvar(tmt_cl) replace ftest feqtest control(1) cov(mpg) fixed(foreign)] ","","","","","","","",""
2 changes: 1 addition & 1 deletion run/iebaltab/outputs/iebaltab1/iebt-csv10.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"F-test of joint significance (F-stat)","","","","","","","","","","1.128"
"F-test, number of observations","","","","","","","","","","74"
"F-test, number of clusters","","","","","","","","","","4"
"If the table includes missing values (.n, .o, .v etc.) see the Missing values section in the help file for the Stata command iebaltab for definitions of these values. Covariate(s) used in pairwise and f-test regressions: [mpg]. Fixed effect used in pairwise and f-test regressions: [foreign]. Significance: ***=.01, **=.05, *=.1. Errors are clustered at variable: [test_cluster_var]. Full user input as written by user: [iebaltab weight price , savecsv(""run/iebaltab/outputs/iebaltab1/iebt-csv10"") savexlsx(""run/iebaltab/outputs/iebaltab1/iebt-xlsx10"") savetex(""run/iebaltab/outputs/iebaltab1/iebt-tex10"") texnotefile(""run/iebaltab/outputs/iebaltab1/iebt-tex10-note"") groupvar(tmt_cl) replace vce(cluster test_cluster_var) ftest feqtest total cov(mpg) fixed(foreign) addnote(""added cluster"")] added cluster","","","","","","","","","",""
"If the table includes missing values (.n, .o, .v etc.) see the Missing values section in the help file for the Stata command iebaltab for definitions of these values. Covariate(s) used in pairwise and f-test regressions: [mpg]. Fixed effect used in pairwise and f-test regressions: [foreign]. Significance: ***=.01, **=.05, *=.1. Errors are clustered at variable: [test_cluster_var]. Full user input as written by user: [iebaltab weight price , savecsv(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-csv10"") savexlsx(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-xlsx10"") savetex(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-tex10"") texnotefile(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-tex10-note"") groupvar(tmt_cl) replace vce(cluster test_cluster_var) ftest feqtest total cov(mpg) fixed(foreign) addnote(""added cluster"")] added cluster","","","","","","","","","",""
2 changes: 1 addition & 1 deletion run/iebaltab/outputs/iebaltab1/iebt-csv11.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"price","5961.065","6312.465","-351.401"
"","(470.476)","(486.238)",""
"Number of observations","31","43","74"
"If the table includes missing values (.n, .o, .v etc.) see the Missing values section in the help file for the Stata command iebaltab for definitions of these values. Covariate(s) used in pairwise regressions: [mpg]. Fixed effect used in pairwise regressions: [foreign]. Significance: ***=.01, **=.05, *=.1. Full user input as written by user: [iebaltab weight price , savecsv(""run/iebaltab/outputs/iebaltab1/iebt-csv11"") savexlsx(""run/iebaltab/outputs/iebaltab1/iebt-xlsx11"") savetex(""run/iebaltab/outputs/iebaltab1/iebt-tex11"") texnotefile(""run/iebaltab/outputs/iebaltab1/iebt-tex11-note"") groupvar(tmt_cl) replace onerow cov(mpg) fixed(foreign) addnote(""added onerow"")] added onerow","","",""
"If the table includes missing values (.n, .o, .v etc.) see the Missing values section in the help file for the Stata command iebaltab for definitions of these values. Covariate(s) used in pairwise regressions: [mpg]. Fixed effect used in pairwise regressions: [foreign]. Significance: ***=.01, **=.05, *=.1. Full user input as written by user: [iebaltab weight price , savecsv(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-csv11"") savexlsx(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-xlsx11"") savetex(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-tex11"") texnotefile(""C:/Users/wb462869/github/ietoolkit/run/iebaltab/outputs/iebaltab1/iebt-tex11-note"") groupvar(tmt_cl) replace onerow cov(mpg) fixed(foreign) addnote(""added onerow"")] added onerow","","",""
Loading

0 comments on commit 63f2abe

Please sign in to comment.