An R project that replicates The Market Price of Risk and Macro-Financial Dynamics, by Tobias Adrian, Fernando Duarte and Tara Iyer.
You can install the project from GitHub with:
# install.packages("devtools")
devtools::install_github("VFCI/macro_dynamics")
Open the project macro_dynamics.Rproj
in R.
Run 0_main.R
to recreate all output of the project relying only upon
the raw data files in the data/
folder (and packages).
The folder output/baseline/
has the figures and tables in The Market
Price of Risk and Macro-Financial
Dynamics.
The folder output/appendix/
has figures and tables in the Appendix.
This project uses the R package
renv for package
version control. Running main.R
automatically reinstantiates the
project with the correct packages, but this can also be done manually
with renv::restore()
.
Note: 0_main.R
runs Monte Carlo simulations, so it takes a few minutes
to run to completion. To recreate all the results that do not require
Monte Carlo, run 0_main.R
up to this
line.
Running 0_main.R
pulls the latest data from
FRED and other sources. These latest data
may not be the exact vintage used in the paper. If you want to see the
exact data used in the paper, run
base::load("variables.RData")
before running 0_main.R
.
ALFRED, the archival version of FRED, can be used to retreive different vintages of FRED data.
You can also run this project using Github codespaces. which sets up an environment that is pre-configured to runs this repository’s code (has the right version of R, R studio, VSCode, etc.).
To create a codespace, see Creating a codespace for a repository. Then open the codespace. Both creating and opening take a few minutes the first time.
Upon opening the codespace, VSCode should open up in one of your browser’s tabs. Wait until the setup code finishes execution and all VSCode extensions are loaded.
Close any ports if any are open using the ports tab in VSCode. Then in Terminal, run
docker run --rm -ti -e PASSWORD=yourpassword -p 8787:8787 rocker/rstudio
Make sure you replace yourpassword
by a suitable password of your
choice. After some initial setting up, VSCode should prompt you to open
RStudio in a new tab in your browser. Use the username rstudio
and the
password you chose to log in to RStudio.
Now that you are in RStudio, you should be able to follow the steps outlined above to install and run the repository.