Waf

Documentation on the rationale, Waf, and more background is at http://hmgaudecker.github.io/econ-project-templates/ in the context of the Python version of this template.

For this project you need STATA as all estimation and data management steps were accomplished using this software.

Getting Started

This assumes you have completed the steps in the README.md file and everything worked.

The logic of the project works along the following steps:

  1. Data management

  2. Visualisation and results formatting

  3. Putting everything into the paper

Project Paths

A variety of project paths are defined in the top-level wscript file. These are exported to be used in header files in other languages. The following is taken from the top-level wscript file. Modify any project-wide path settings there.



def set_project_paths(ctx):
    """Return a dictionary with project paths represented by Waf nodes."""

    pp = {}
    pp["PROJECT_ROOT"] = "."
    pp["IN_OTHER_DATA"] = "src/other_data"
    pp["IN_IAB_PROG"] = "src/iab/prog"
    pp["IN_OCCUPATION_KEYS"] = "src/occupation_keys"
    pp["IN_SPECS"] = "src/specifications"
    pp["OUT_SPECS"] = "{}/src/specifications".format(out)
    pp["IN_MAPPINGS"] = "src/mappings"
    pp["IN_PLOTTING_SPECS"] = "src/figures"
    pp["IN_REMOTE_ESTIMATES"] = "src/remote_estimates"
    pp["OUT_MAPPINGS"] = "{}/src/mappings".format(out)
    pp["OUT_DATA"] = "{}/out/data".format(out)
    pp["OUT_MONTE_CARLO"] = "{}/out/monte_carlo".format(out)
    pp["OUT_BIBB_FINAL"] = "{}/out/bibb_final".format(out)
    pp["OUT_FIGURES"] = "{}/out/figures".format(out)
    pp["OUT_TABLES"] = "{}/out/tables".format(out)
    pp["RESULTS_FOR_PAPER"] = "results_for_paper"
    pp["MOCK_FDZ_IAB"] = "{}/mock_fdz_iab".format(out)
    # No need to distinguish between in/out for library (just Waf-internal)
    pp["LIBRARY"] = "src/library"

    # Stata's adopaths get special treatment.
    lib = pp["LIBRARY"]
    pp["ADO"] = {}
    pp["ADO"]["PERSONAL"] = os.path.join(lib, "stata/ado_ext/personal")
    pp["ADO"]["PLUS"] = os.path.join(lib, "stata/ado_ext/plus")
    pp["ADO"]["LOCAL"] = os.path.join(lib, "stata")

As should be evident from the similarity of the names, the paths follow the steps of the analysis in the src directory:

  1. data_management → OUT_DATA

  2. final → OUT_FIGURES, OUT_TABLES

These will re-appear in automatically generated header files by calling the write_project_paths task generator (just use an output file with the correct extension for the language you need – .py, .r, .m, .do).

By default, these header files are generated in the top-level build directory, i.e. bld. Since this is where Stata is launched, you can just get globals with the project paths by adding a line include project_paths at the top of you do-files.

To see what these variables are, here is the content of bld/project_paths.do:

//
// Header with path definitions for entire project.
//
// Automatically generated by Waf, do not change!
//
// If paths need adjustment, perform those in the root wscript file.
//
// Note that the paths are added to the top of the ado-path.
//


sysdir set PERSONAL "/mnt/iab-data/occupations-inequality-model/src/library/stata/ado_ext/personal/"
sysdir set PLUS "/mnt/iab-data/occupations-inequality-model/src/library/stata/ado_ext/plus/"
adopath ++ "/mnt/iab-data/occupations-inequality-model/src/library/stata/"
adopath ++ "/mnt/iab-data/occupations-inequality-model/bld/src/library/stata/"

global PATH_IN_IAB_PROG "/mnt/iab-data/occupations-inequality-model/src/iab/prog/"
global PATH_IN_MAPPINGS "/mnt/iab-data/occupations-inequality-model/src/mappings/"
global PATH_IN_OCCUPATION_KEYS "/mnt/iab-data/occupations-inequality-model/src/occupation_keys/"
global PATH_IN_OTHER_DATA "/mnt/iab-data/occupations-inequality-model/src/other_data/"
global PATH_IN_PLOTTING_SPECS "/mnt/iab-data/occupations-inequality-model/src/figures/"
global PATH_IN_REMOTE_ESTIMATES "/mnt/iab-data/occupations-inequality-model/src/remote_estimates/"
global PATH_IN_SPECS "/mnt/iab-data/occupations-inequality-model/src/specifications/"
global PATH_LIBRARY "/mnt/iab-data/occupations-inequality-model/src/library/"
global PATH_MOCK_FDZ_IAB "/mnt/iab-data/occupations-inequality-model/bld/mock_fdz_iab/"
global PATH_OUT_BIBB_FINAL "/mnt/iab-data/occupations-inequality-model/bld/out/bibb_final/"
global PATH_OUT_DATA "/mnt/iab-data/occupations-inequality-model/bld/out/data/"
global PATH_OUT_FIGURES "/mnt/iab-data/occupations-inequality-model/bld/out/figures/"
global PATH_OUT_MAPPINGS "/mnt/iab-data/occupations-inequality-model/bld/src/mappings/"
global PATH_OUT_MONTE_CARLO "/mnt/iab-data/occupations-inequality-model/bld/out/monte_carlo/"
global PATH_OUT_SPECS "/mnt/iab-data/occupations-inequality-model/bld/src/specifications/"
global PATH_OUT_TABLES "/mnt/iab-data/occupations-inequality-model/bld/out/tables/"
global PATH_PROJECT_ROOT "/mnt/iab-data/occupations-inequality-model/"
global PATH_RESULTS_FOR_PAPER "/mnt/iab-data/occupations-inequality-model/results_for_paper/"

Note

Note the changes to Stata’s built-in system pathse. These changes imply that Stata will not find any packages you installed system-wide anymore. It is desired behaviour to keep the project self-contained.