Term
Replication files for numerical solution in "Monetary Policy, Segmentation, and the Term Structure"
Install / Use
/learn @KekreLenel/TermREADME
term: preferred habitat with endogenous price of risk
Julia code for solving and simulating a term structure model with preferred habitat demand and an endogenous price of risk, and generating the paper’s tables/figures.
Repository layout
src/: core model code (solver, simulations, impulse responses, outputs).scripts/: entrypoint scripts and (optional) Slurm wrappers.data/: empirical inputs (CSV files used for figures/QE paths, etc.).output/: generated results, tables, and figures (default location).
Requirements
- Julia: this project is developed against Julia 1.9.x (see cluster scripts for the exact module used).
- Packages: managed via
Project.toml(aManifest.tomlmay be present locally, but is not required).
Setup
From the repository root:
julia --project=. -e 'using Pkg; Pkg.instantiate()'
Running locally
The main entrypoint is scripts/run.jl (it calls into the term module in src/term.jl).
Solve + simulate (default)
julia --project=. scripts/run.jl
Run a single calibration (or a list/range)
The first positional argument is a calibration index (1-based).
# single
julia --project=. scripts/run.jl 7
# comma-separated list
julia --project=. scripts/run.jl 1,3,7
# inclusive range
julia --project=. scripts/run.jl 3:9
Output only (tables/figures)
julia --project=. scripts/run.jl --mode=output
Configure output locations
scripts/run.jl supports both CLI flags and environment variables:
- Results folder (JLD2 files):
--results_dir PATHorTERM_RESULTS_DIR=PATH- default:
output/results
- Output folder (tables/figures):
--out_dir PATHorTERM_OUT_DIR=PATH- default:
output
- Mode:
--mode solve|output|bothorTERM_MODE=...
Examples:
julia --project=. scripts/run.jl --results_dir output/results --out_dir output --mode both
TERM_RESULTS_DIR=output/results TERM_OUT_DIR=output TERM_MODE=both julia --project=. scripts/run.jl
Reproducibility / runtime knobs
The driver script calls term.configure_runtime!() to make batch behavior explicit:
- Threads: set via Julia
-t N/JULIA_NUM_THREADS. - BLAS threads:
TERM_BLAS_THREADS=1(default is1). - Headless plotting:
TERM_HEADLESS=true(default istrue).
Run metadata (Julia version, threads, git commit when available, TOML SHA1s, etc.) is saved alongside solution_*.jld2 / results_*.jld2.
Data inputs
Most empirical inputs are CSV files in data/. The code resolves paths robustly via data_path(...) (independent of the working directory).
In particular, QE path inputs are loaded from:
data/Figure20_1.csv…data/Figure20_8.csv
If required data files are missing, ImportData() errors with a list of missing filenames.
Outputs
By default, outputs are written under:
- Results:
output/results/(JLD2) - Tables:
output/tables/ - Figures:
output/figures/
Citation
If you use this code, please cite it (see CITATION.cff).
Notes on HPC / Slurm
This repo includes Slurm wrapper scripts under scripts/ for the authors’ cluster setup.
If you are running on a different cluster, you will typically need to adjust module/depot paths, resource requests, and result/output directories.
