1. Using ModelFlow with World Bank models#

The ModelFlow python package has been developed to solve a wide range of models, see the ModelFlow github IbHansen/ModelFlow web site for working examples of the Solow Model, the United States’ Federal REserve FRB/US model and others.

The package has been substantially expanded to include special features that enable it to work with World Bank models originally developed in EViews using the EViews Model Object for simulation. Although derived from these EViews models, the models available on the World Bank web site and through the mechanisms outlined below are pure python models and use ModelFlow and various python libraries for solution visualization and data management.

This chapter illustrates how to access these models. Subsequent chapters explain how:

  • to load ModelFlow models into the Anaconda environment on your computer

  • to explore various features of these models (Chapter 9)

  • World Bank behavioural equations are designed and manipulated in ModelFlow (Chapter 10)

  • to perform a variety of simulations (Chapters 10,11 and 12)

  • to extract and compare results from your simulations (Chapter 13).

In this chapter - Using ModelFlow with World Bank Models

This chapter demonstrates how to access World Bank models that have been made publicly available using the ModelFlow python system.

  • Available Models:

    • Access a range of pre-built World Bank models tailored for macroeconomic analysis.

    • Publicly available models can be loaded and customized in ModelFlow.

1.1. Publicly available World Bank models for use with ModelFlow#

Several World Bank macrostructural models are currently available for download and use with ModelFlow (more will be added over time). The available models include:

  • Bolivia (Annual model)

  • Croatia (Quarterly model)

  • Iraq (Annual model)

  • Nepal (Annual model with Climate features)

  • Pakistan (Annual model with climate features)

  • Turkiye (Annual model with climate features)

Each of these models has been developed as part of the outreach work of the World Bank. The basic modeling framework of each of these models is outlined in Burns et al. [2019] with individual models having specific extensions reflecting features of the individual country and the questions for which the model was designed to respond. The approach for the models with climate features is laid out in Burns et al. [2021], although several additional features are included in some of these models that have not yet been documented.

As additional models are released they will be made available using the mechanism described below.

1.2. How to access the models the .Worldbank_Models() method#

The World Bank models can be downloaded on to a user’s computer using the model.Worldbank_Models() method, which downloads the models from the World Bank’s GitHub repository at worldbank/MFMod-ModelFlow.

By default, the models are downloaded to a directory on the user’s computer entitled WorldbankModels that is located just below the directory from which it is executed. The content of the downloaded folders will be displayed in a table of content, and the user can access the notebooks by clicking on them.

model.Worldbank_Models() 
Menu to start notebooks in subfolders

1.2.1. WorldbankModels() Options#

The model.Worldbank_Models() method includes several options, which affect the way the download of the models is executed.

1.2.1.1. The destinationoption#

To change the directory to which the files are downloaded the destination parameter can be set (by default it points to ./WorldBankModels).

model.Worldbank_Models('./mydirectory') (or equivalently model.Worldbank_Models(destination='./mydirectory')) would instead download the GitHub repository to a directory called mydirectory below the location from which the command was executed. Note: For security reasons, the destination option will not accept a location that is above the directory from which it is executed.

1.2.1.2. The silent option#

By default the silent option is set to True. Setting it to False generates a more verbose indication of the directories and files downloaded and erased (of any).

1.2.1.3. Options controlling the treatment of existing files in the download directory#

option

default

Level of aggression

Action

replace

False

\(\color{orange}{Medium}\)

replace=True will replace any file in the local store that also exists on the World Bank github site with the version on the World Bank site.

replace

False

\(\color{green}{Lowest}\)

replace=False will not change or delete any files on the user’s store. Only files that exist on the World Bank web site (and not on the local copy) will be downloaded.

To replace the all of the content first delete the destination directory (by default ./WorldBankModels). <to do this use the operation system.

1.2.1.4. Options to change the repository that is downloaded#

It is possible to choose a repository other than the World Bank site to be downloaded, although the use case for this option is limited. A user that wishes to do this can specify the repository to be downloaded by setting the following options

option

Default value

Explanation

owner

WorldBank

Name of the owner of the github repository to be downloaded

repo_name

MFMod-ModelFlow

The name of the repository

branch

main

The branch to downloaded.

1.3. .display_toc() method#

The .display_toc() method can be used to displays a list of the directories and files included in the subfolder to which the World Bank models were previously downloaded.

model.display_toc(folder='WorldbankModels');
Menu to start notebooks in subfolders

Help on the accessing World Bank models can be generated by using the help() function.

help(model.Worldbank_Models)
Help on function Worldbank_Models in module modelclass:

Worldbank_Models(owner: str = 'worldbank', repo_name: str = 'MFMod-ModelFlow', branch: str = 'main', destination='./WorldbankModels', go=True, silent=True, replace=False)
    Download an entire GitHub repository and extract it to a specified location.

    Parameters:
      owner: The owner of the GitHub repository.
      repo_name: The name of the repository.
      branch: The branch to download.
      destination: The local path where the repository should be extracted.
      go: display toc of notebooks
      silent: keep silent

    Returns:
      A message indicating whether the download was successful or not.