Cookiecutter research project
This is an example, or 'cookiecutter', repository for a research project.
git clone the project and use it as a skeleton for your own research project. A full explanation may be found in this accompanying blog post. The idea is that this project structure should be as simple as possible, but no simpler.
Example project details
The code is in Python 3 and uses the ONS API to download some macroeconomic time series, process them into tidy data, and then use them within a dynamic factor model† inspired by Chad Fulton's tutorials/notebooks which you can find here and here.
The project here is very much a toy example and not intended to be accurate or say anything at all about the real world!
Note that paths, the series to download, and visualisation settings are all defined in config.yaml. The data processing steps are separated: raw data to file first, then cleaned data into tidy format in a csv, and finally the time series are used in a statistical model. The plots are similarly just examples.
Within the example project, there are latex templates for both slides and a working paper. These are based on Paul Goldsmith-Pinkham's excellent templates, the originals of which you can find here for slides and here for the working paper.
More on the example dynamic factor model found in
analysis.py in the blog post.
where capital Greek and Latin characters represent matrices, arrows over characters denote vectors, and it is assumed that the different components of the `innovations' in the error updating equation are uncorrelated so that $ \Sigma $ is a diagonal matrix. The model has one unobserved factor that follows an AR(2), and the errors similarly follow an AR(2).
Re-running the example project
To re-run the analysis part of the project with conda, first install the required packages in a new conda environment:
conda env create -f ccenv.yml
You then need to activate the environment to use in your IDE. The command for this is
conda activate ccenv. Note that, to try to ensure compatibility with all operating systems, the environment file is simplified. It only specifies the version of Python, conda is trusted to resolve dependencies and pick the right versions of other required packages.
Then run the files in this order to create the final PDF outputs:
- both Latex files*
* You may find that because the .eps files used for figures are not in a sub-directory of the main .tex folder, you must add a flag to the Latex compiler. In TexShop, the steps are:
- Go to Preferences
- Go to Tab "Engine"
- Go to the field "pdfTeX"
- In the LaTeX Input Field add
--shell-escapeat the end so that it changes from
pdflatex --file-line-error --synctex=1to
pdflatex --file-line-error --synctex=1 --shell-escape