Density Forecasts in Panel Data Models: A Semiparametric Bayesian Perspective
Laura Liu

Replication package


Software
--------
MATLAB R2018a with the Statistics and Machine Learning Toolbox and
the Parallel Computing Toolbox.

Two MEX functions make the experiments much faster. Each ships as an Apple
silicon binary (.mexmaca64) and as the source it was built from, so other
platforms rebuild it with the script named next to it. Neither one is required:
each has a MATLAB stand-in that runs the same algorithm more slowly.

    invChol_mex, which most of the general model samplers call, compiles from
    invChol_mex.c through tools/invChol/run_to_compile_and_test.m. That needs a C
    compiler but no toolbox. Until it exists the samplers fall back on invChol.m
    in the same folder.

    np_mcmc_mex speeds up the Heterosk-NP-disc and Heterosk-NP-R samplers and
    needs MATLAB Coder: run build_np_mcmc_mex.m in general_model/heterosk_np_disc,
    then in general_model/heterosk_np_r. Until it exists np_link.m calls np_mcmc.m
    directly.


Folders
-------
baseline_model/         Monte Carlo for the baseline model with random effects
                        and cross-sectional homoskedasticity
general_model/          Monte Carlo for the general model with correlated
                        random coefficients and cross-sectional
                        heteroskedasticity
empirical_application/  Young firm dynamics, Kauffman Firm Survey
tools/                  Helpers shared by the above
illustration/           Figures that require no estimation output

Each folder has its own README.txt, including the files a run writes. Run
every script from inside its own folder; output goes to a results/ subfolder
created on the first run, except for the illustration scripts, which write
their .png files next to themselves.


Running the experiments
-----------------------
Each driver has an is_par switch near the top.

    is_par = 1  the full experiment over a parallel pool, reporting the
                forecast evaluation tables. The paper uses n_sim = 1000
                repetitions for the baseline model and n_sim = 100 for the
                general model, which is what the drivers set.
    is_par = 0  a single repetition and no pool, which is what the two
                robustness tables report, and what run_baseline_mc.m needs to
                draw the f0 against posterior figures

The pool opens one worker per physical core.

Every output file starts with the modrun tag set at the top of its driver: 101
for the baseline model, 201 to 204 for the general model, 301 for the empirical
application.


Where the paper's exhibits come from
------------------------------------
Baseline model, density and point forecast evaluation, and the f0 against
posterior figures
    baseline_model/run_baseline_mc.m

General model, density and point forecast evaluation
    normal v_it  general_model/run_general_mc.m
    skewed v_it  general_model/run_general_mc_skewed_shocks.m

Convergence diagnostics
    general_model/plot_mcmc_diagnostics.m

Robustness checks, Monte Carlo column
    general_model/run_general_mc_joint_lambda_sigma.m
    general_model/run_general_mc_heterogeneous_ar1.m

Alternative predictors, and the density panels of the general model setup
    illustration/

Young firm dynamics
    empirical_application/run_kfs_application.m, which needs the Kauffman Firm
    Survey. The survey is confidential, so those exhibits cannot be reproduced
    from this package. See empirical_application/README.txt.


Third-party code
----------------
tools/jbfill.m, tools/patchline.m, tools/invChol/ and the logdet function
inlined in the general_model samplers are redistributed under the licenses in
tools/.
