-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from worldbank/develop
Merging of version 6.1 to the master branch. Part of checklist in #174
- Loading branch information
Showing
24 changed files
with
117 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
capture program drop iebaltab | ||
program iebaltab | ||
|
||
syntax varlist(numeric) [if] [in], /// | ||
syntax varlist(numeric) [if] [in] [aw fw pw iw], /// | ||
/// | ||
/*Group variable*/ /// | ||
GRPVar(varname) /// | ||
|
@@ -33,7 +33,7 @@ | |
COVMISS(string) /// | ||
COVMISSReg(string) /// | ||
MISSMINmean(numlist min=1 max=1 >0) /// | ||
weight(string) /// | ||
WEIGHTold(string) /// | ||
/// | ||
/*F-test*/ /// | ||
FTest /// | ||
|
@@ -82,7 +82,14 @@ qui { | |
*Set minimum version for this command | ||
version 11 | ||
|
||
*Remove observations excluded by if and in | ||
* Backwards compatibility for weight option | ||
if "`weightold'" != "" & "`exp'" == "" { | ||
tokenize `weightold', parse(=) | ||
local weight "`1'" | ||
local exp = "= `3'" | ||
} | ||
|
||
*Remove observations excluded by if and in | ||
marksample touse, novarlist | ||
keep if `touse' | ||
|
||
|
@@ -692,13 +699,13 @@ qui { | |
if `WEIGHT_USED' == 1 { | ||
|
||
* Parsing weight options | ||
gettoken weight_type weight_var : weight, parse("=") | ||
local weight_type = "`weight'" | ||
|
||
* Parsing keeps the separating character | ||
local weight_var : subinstr local weight_var "=" "" | ||
local weight_var = subinstr("`exp'","=","",.) | ||
|
||
* Test is weight type specified is valie | ||
local weight_options "fweights pweights aweights iweights fw freq weight pw aw iw" | ||
local weight_options "fweights pweights aweights iweights fweight pweight aweight iweight fw freq weight pw aw iw" | ||
|
||
if `:list weight_type in weight_options' == 0 { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
capture program drop ieboilsave | ||
program ieboilsave , rclass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
capture program drop ieboilstart | ||
program ieboilstart , rclass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
capture program drop iecompdup | ||
program iecompdup , rclass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
cap program drop ieddtab | ||
program define ieddtab, rclass | ||
|
||
syntax varlist(numeric) [if] [in], /// | ||
syntax varlist(numeric) [if] [in] [aw fw iw pw], /// | ||
/// | ||
Time(varname numeric) TREATment(varname numeric) /// | ||
[ /// | ||
|
@@ -13,6 +13,7 @@ cap program drop ieddtab | |
/// | ||
/* Output display */ /// | ||
STARLevels(numlist descending min=3 max=3 >0 <1) /// | ||
stardrop /// | ||
ROWLabtype(string) /// | ||
rowlabtext(string) /// | ||
ERRortype(string) /// | ||
|
@@ -29,6 +30,7 @@ cap program drop ieddtab | |
TEXLabel(string) /// | ||
TEXNotewidth(numlist min=1 max=1) /// | ||
texvspace(string) /// | ||
nonumbers /// | ||
] | ||
|
||
*Set minimum version for this command | ||
|
@@ -250,7 +252,7 @@ cap program drop ieddtab | |
gen `interactionvar' = `treatment' * `time' | ||
|
||
*Run the regression to get the double difference | ||
qui reg `var' `treatment' `time' `interactionvar' `covariates', `error_estm' | ||
qui reg `var' `treatment' `time' `interactionvar' `covariates' [`weight'`exp'], `error_estm' | ||
mat resTable = r(table) | ||
|
||
**This is why this is done first. All other calculations | ||
|
@@ -274,7 +276,7 @@ cap program drop ieddtab | |
*Get the number of stars using sub-command countStars | ||
local ++colindex | ||
local pvalue = el(resTable,4,3) | ||
countStars `pvalue' `starlevels' | ||
countStars `pvalue' `starlevels' `stardrop' | ||
mat `var'[1,`colindex'] = `r(stars)' | ||
|
||
*Get the N of second difference regression | ||
|
@@ -297,7 +299,7 @@ cap program drop ieddtab | |
forvalues tmt01 = 0/1 { | ||
|
||
*Regress time against the outcome var one tmt group at the time | ||
qui reg `var' `time' `covariates' if `treatment' == `tmt01' & `regsample' == 1, `error_estm' | ||
qui reg `var' `time' `covariates' if `treatment' == `tmt01' & `regsample' == 1 [`weight'`exp'], `error_estm' | ||
mat resTable = r(table) | ||
|
||
//Get the 1st diff | ||
|
@@ -312,7 +314,7 @@ cap program drop ieddtab | |
*Get the number of stars using sub-command countStars | ||
local ++colindex | ||
local pvalue = el(resTable,4,1) | ||
countStars `pvalue' `starlevels' | ||
countStars `pvalue' `starlevels' `stardrop' | ||
mat `var'[1,`colindex'] = `r(stars)' | ||
|
||
*Get the N of first difference regression | ||
|
@@ -338,7 +340,7 @@ cap program drop ieddtab | |
forvalues t01 = 0/1 { | ||
|
||
*Summary stats on this group | ||
qui mean `var' if `treatment' == `t01' & `time' == `tmt01' & `regsample' == 1, `error_estm_mean' | ||
qui mean `var' if `treatment' == `t01' & `time' == `tmt01' & `regsample' == 1 [`weight'`exp'], `error_estm_mean' | ||
|
||
mat resTable = r(table) | ||
|
||
|
@@ -405,11 +407,13 @@ cap program drop ieddtab | |
|
||
local note_obs "The baseline means only include observations not omitted in the 1st and 2nd differences. The number of observations in the 1st and 2nd differences includes both baseline and follow-up observations." | ||
|
||
*Show stars levels | ||
local star1_value : word 1 of `starlevels' | ||
local star2_value : word 2 of `starlevels' | ||
local star3_value : word 3 of `starlevels' | ||
local note_stars "***, **, and * indicate significance at the `star3_value', `star2_value', and `star1_value' percent critical level." | ||
*Only include note on stars levels if stardrop was NOT used | ||
if "`stardrop'" == "" { | ||
local star1_value : word 1 of `starlevels' | ||
local star2_value : word 2 of `starlevels' | ||
local star3_value : word 3 of `starlevels' | ||
local note_stars "***, **, and * indicate significance at the `star3_value', `star2_value', and `star1_value' percent critical level." | ||
} | ||
|
||
*Only include note on covariates if covariates were used | ||
if "`covariates'" != "" { | ||
|
@@ -433,7 +437,21 @@ cap program drop ieddtab | |
if "`vce_type'" == "bootstrap" local note_error "All columns display `variance_type_name' estimated using bootstrap. " | ||
} | ||
|
||
local note `"`note_obs' `note_stars' `note_cov' `note_error'"' | ||
* Add note on weights | ||
if "`weight'" != "" { | ||
local weightvar = subinstr("`exp'", "=", "", .) | ||
local weightvar = stritrim(strtrim(`"`weightvar'"')) | ||
|
||
noi di "`weight'" | ||
if "`weight'" == "aweight" local weightopt analytical | ||
else if "`weight'" == "fweight" local weightopt frequency | ||
else if "`weight'" == "pweight" local weightopt probability | ||
else if "`weight'" == "iweight" local weightopt importance | ||
|
||
local note_weight "Variable `weightvar' used as `weightopt' weight. " | ||
} | ||
|
||
local note `"`note_obs' `note_stars' `note_cov' `note_error' `note_weight'"' | ||
|
||
} | ||
|
||
|
@@ -454,7 +472,7 @@ cap program drop ieddtab | |
*************/ | ||
|
||
outputwindow `varlist' , ddtab_resultMap(ddtab_resultMap) labmaxlen(`labmaxlen') rwlbls(`rowlabels') /// | ||
starlevels("`starlevels'") covariates(`covariates') `errortype' format(`format') note(`note') `cluster' | ||
`errortype' format(`format') note(`note') `cluster' | ||
|
||
/************* | ||
|
@@ -466,8 +484,8 @@ cap program drop ieddtab | |
outputtex `varlist', ddtab_resultMap(ddtab_resultMap) /// | ||
savetex(`savetex') `replace' /// | ||
`texdocument' texcaption("`texcaption'") texlabel("`texlabel'") texnotewidth(`texnotewidth') /// | ||
`onerow' starlevels("`starlevels'") format(`format') rwlbls("`rowlabels'") errortype(`errortype') /// | ||
note(`note') texvspace("`texvspace'") `cluster' | ||
`onerow' format(`format') rwlbls("`rowlabels'") errortype(`errortype') /// | ||
note(`note') texvspace("`texvspace'") `cluster' `numbers' | ||
|
||
} | ||
|
||
|
@@ -673,12 +691,16 @@ end | |
cap program drop countStars | ||
program define countStars, rclass | ||
|
||
args pvalue star1 star2 star3 | ||
args pvalue star1 star2 star3 stardrop | ||
|
||
local stars 0 | ||
foreach star_p_level in `star1' `star2' `star3' { | ||
|
||
if `pvalue' < `star_p_level' local ++stars | ||
*Option to suppress all stars | ||
if "`stardrop'" == "" { | ||
foreach star_p_level in `star1' `star2' `star3' { | ||
|
||
if `pvalue' < `star_p_level' local ++stars | ||
} | ||
} | ||
|
||
return local stars `stars' | ||
|
@@ -833,8 +855,8 @@ end | |
cap program drop outputwindow | ||
program define outputwindow | ||
|
||
syntax varlist , ddtab_resultMap(name) labmaxlen(numlist) rwlbls(string) starlevels(string) format(string) /// | ||
[covariates(string) errhide sd se note(string) cluster] | ||
syntax varlist , ddtab_resultMap(name) labmaxlen(numlist) rwlbls(string) format(string) /// | ||
[errhide sd se note(string) cluster] | ||
|
||
*Prepare lables for the erorrs to be displayed (in case any) | ||
if "`sd'" != "" local errlabel "SD" | ||
|
@@ -977,8 +999,6 @@ end | |
|
||
************************* | ||
* Write notes below the table | ||
|
||
*List covariates used | ||
if (`"`note'"' != "") { | ||
noi di as text `"{pstd}`note'{p_end}"' | ||
} | ||
|
@@ -1088,7 +1108,7 @@ cap program drop outputtex | |
|
||
syntax varlist, ddtab_resultMap(name) savetex(string) note(string) /// | ||
[replace onerow starlevels(string) format(string) rwlbls(string) errortype(string) /// | ||
texdocument texcaption(string) texlabel(string) texnotewidth(numlist) texvspace(string) cluster] | ||
texdocument texcaption(string) texlabel(string) texnotewidth(numlist) texvspace(string) cluster nonumbers] | ||
|
||
* Replace tex file? | ||
if "`replace'" != "" local texreplace replace | ||
|
@@ -1110,7 +1130,7 @@ cap program drop outputtex | |
texpreamble , texname("`texname'") texfile("`texfile'") texcaption("`texcaption'") texlabel("`texlabel'") `texdocument' | ||
|
||
* Write table header | ||
texheader , texname("`texname'") texfile("`texfile'") `onerow' errortype(`errortype') `cluster' | ||
texheader , texname("`texname'") texfile("`texfile'") `onerow' errortype(`errortype') `cluster' `numbers' | ||
|
||
* Write results | ||
texresults `varlist', ddtab_resultMap(ddtab_resultMap) /// | ||
|
@@ -1406,7 +1426,7 @@ end | |
cap program drop texheader | ||
program define texheader | ||
|
||
syntax , texname(string) texfile(string) errortype(string) [onerow cluster] | ||
syntax , texname(string) texfile(string) errortype(string) [onerow cluster nonumbers] | ||
|
||
** Calculate number of rows | ||
|
||
|
@@ -1429,6 +1449,17 @@ cap program drop texheader | |
} | ||
} | ||
|
||
*Unless option nonumbers is used, number all columns in tex output | ||
local colnorow = "" | ||
if "`numbers'" != "nonumbers" { | ||
local colnomax = strlen("`colstring'") - 1 | ||
forvalues colno = 1/`colnomax' { | ||
local colnorow = `"`colnorow' & (`colno')"' | ||
} | ||
local colnorow = `"`colnorow' \\"' | ||
} | ||
|
||
*Write part of header that explains which type of errors are displayed | ||
if "`errortype'" == "errhide" { | ||
if "`onerow'" != "" { | ||
local errortitle "" | ||
|
@@ -1451,7 +1482,8 @@ cap program drop texheader | |
"\hline \hline \\[-1.8ex]" _n /// | ||
"& \multicolumn{`toprowcols'}{c}{Control} & \multicolumn{`toprowcols'}{c}{Treatment} & \multicolumn{`bottomrowcols'}{c}{Difference-in-differences} \\" _n /// | ||
"& \multicolumn{`bottomrowcols'}{c}{Baseline} & \multicolumn{`bottomrowcols'}{c}{Difference} & \multicolumn{`bottomrowcols'}{c}{Baseline} & \multicolumn{`bottomrowcols'}{c}{Difference} & \multicolumn{`bottomrowcols'}{c}{} \\" _n /// | ||
"Variable `ncol' & Mean`errortitle' `ncol' & Coef`errortitle' `ncol' & Mean`errortitle' `ncol' & Coef`errortitle' `ncol' & Coef`errortitle' \\ \hline" _n | ||
"Variable `ncol' & Mean`errortitle' `ncol' & Coef`errortitle' `ncol' & Mean`errortitle' `ncol' & Coef`errortitle' `ncol' & Coef`errortitle' \\" _n /// | ||
"`colnorow' \hline" _n | ||
file close `texname' | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
capture program drop iedropone | ||
program define iedropone , | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
capture program drop ieduplicates | ||
program ieduplicates , rclass | ||
|
@@ -167,7 +167,7 @@ | |
*Test that the ID variable is in the imported report | ||
if `:list idvar in existingExcelVars' == 0 { | ||
|
||
noi display as error "{phang}The ID variable `idvar' does not exist in the previously exported Excle file. If you renamed the ID variable you need to rename it manually in the Excel report or start a new Excel report by renaming or moving the original report, then run the command again and create a new file and manually copy any corrections from the old file to the new. If you changed the ID varaible you need to start with a new report.{p_end}" | ||
noi display as error "{phang}The ID variable `idvar' does not exist in the previously exported Excle file. If you renamed the ID variable you need to rename it manually in the Excel report or start a new Excel report by renaming or moving the original report, then run the command again and create a new file and manually copy any corrections from the old file to the new. If you changed the ID variable you need to start with a new report.{p_end}" | ||
noi di "" | ||
error 111 | ||
exit | ||
|
@@ -333,6 +333,8 @@ | |
} | ||
|
||
*Same error for any incorrect input | ||
|
||
di as error "{phang}Since there was at least one error in the Excel report no corrections have been made to the duplicates in the data set. Please address the errors above and then run the command again.{p_end}" | ||
error 198 | ||
exit | ||
} | ||
|
@@ -613,7 +615,7 @@ | |
levelsof newID if missing(real(newID)), local(NaN_values) clean | ||
|
||
* Output error message | ||
di as error "{phang}The ID varaible `idvar' is numeric but newID has thes non-numeric values: `NaN_values'. Update newID to only contain numeric values or see option tostringok.{p_end}" | ||
di as error "{phang}The ID variable `idvar' is numeric but newID has these non-numeric values: `NaN_values'. Update newID to only contain numeric values or see option tostringok.{p_end}" | ||
error 109 | ||
exit | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
cap program drop iefolder | ||
program define iefolder | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
cap program drop iegitaddmd | ||
program define iegitaddmd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
cap program drop iegraph | ||
program define iegraph, rclass | ||
|
@@ -21,7 +21,7 @@ cap program drop iegraph | |
ignoredummytest /// | ||
norestore /// | ||
save(string) *] | ||
|
||
if "`restore'" == "" preserve | ||
|
||
qui { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
cap program drop iematch | ||
program define iematch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
*! version 6.0 19OCT2018 DIME Analytics [email protected] | ||
*! version 6.1 09112018 DIME Analytics [email protected] | ||
|
||
capture program drop ietoolkit | ||
program ietoolkit, rclass | ||
|
||
* UPDATE THESE LOCALS FOR EACH NEW VERSION PUBLISHED | ||
local version "6.0" | ||
local versionDate "19OCT2018" | ||
local version "6.1" | ||
local versionDate "11NOV2018" | ||
|
||
|
||
syntax [anything] | ||
|
Oops, something went wrong.