Hidden Markov Model Estimated with MCMC in Julia with option for parallel estimation.
This repo contains code to estimate the implementation of the Hidden Markov Chain model. Code was written against julia 1.0
To download the needed packages do the following
]
activate .
to activate projectinstantiate
to download needed packagesFrom now one start julia with the project flag from the root directory,julia --project=.
to load the needed packages.
code
contains scripts to run stuff. Some of these are softlinked into the project root directory to
make it easier to run on the cluster
src
contains the code for the module Hmc.jl
which contains all the functions used in the estimation
test
contains unit test code
data
contains the data for the project
— raw
contains the raw inflation data
— output
contains output files from the estimation scripts
thoughts
contains latex code outline various procedures
slurmscripts
contains the slurm shell files to run the commands on the cluster
The estimation code outputs the results from each Gibbs draw for the various parameters in the model.
If 1000 samples are drawn in the estimation for each date then the csv files will have 1000 lines for the
samples drawn for date range estimated. Each line starts with the end date of the estimation. For each
of these csv’s there is also a second csv with the mean of the samples for each date. In this csv there is
exactly one line for each date. These csv’s will have _summary
as suffix.
The directory structure should make clear what’s being estimated
A[:]
to transform the matrix to a vector and need to be reshaped in column major order (default in Julia and Matlab but not Python)run_hmm.jl
is the main script which estimates the HMM model. It takes a command line argument
to determine which inflation series to use in the estimation. Call the script as eitherjulia --project=. -p <number of cores to use> run_hmm.jl official
orjulia --project=. -p <number of cores to use> run_hmm.jl alter
aggregate.jl
is a secondary script that calculates aggregate statistics