Skip to content

Parsing EpiFusion Outputs

Ciara Judge edited this page Jun 6, 2024 · 12 revisions

What is in the output?

For each MCMC chain, EpiFusion will give you the following output files:

  • betas: csv file where each row is a trajectory of rate beta sampled from the MCMC
  • trajectories: csv file where each row is a daily infection trajectory sampled from the MCMC
  • rt: csv file where each row is a daily Rt trajectory sampled from the MCMC
  • params: txt file where each column is an MCMC parameter, and each row is an MCMC sample
  • likelihoods: txt file of the posterior likelihoods from each MCMC step
  • acceptance: txt file where each line logs the acceptance rate of steps between MCMC samples
  • completed: txt file where each line logs if the particle filter step was completed or quit due to particle depletion
  • positivetests (only for combined or epi-only analyses): csv file where each row is simulated case incidence by the model which was compared to the observed case incidence

EpiFusion will also save a copy of the parameter file used to the output folder, so you can remember exactly what parameters were used, and a file called 'timings.txt' with the runtime in nanoseconds.

How do I interpret the output?

We have an R package on GitHub called 'EpiFusionUtilities' which can be useful for interpreting the output. It can be installed via devtools with the following command in R:

devtools::install_github("https://github.com/ciarajudge/EpiFusionUtilities")

For more on EpiFusionUtilities, visit the project wiki.

Main EpiFusionUtilities Functions for Parsing Outputs

load_raw_epifusion("path_to_outputfolder")

  • Description: Loads an R list with the full posterior trajectory samples, parameter samples, likelihoods and acceptance rates for all chains.
  • Input: A filepath to an EpiFusion outputs folder
  • Output: A large list with the full EpiFusion output in an R compatible format.
raw_epifusion_output <- load_raw_epifusion('epifusionoutputs/')

plot_likelihood_trace(raw_epifusion_output)

  • Description: Plots the likelihood trace for all chains in an EpiFusion analysis
  • Input: Raw epifusion output object generated by load_raw_epifusion()
  • Output: A plot of the likelihood trace coloured by chain.
plot_likelihood_trace(raw_epifusion_output)

extract_posterior_epifusion(raw_epifusion_output, burn_in)

  • Description: Extracts the final epifusion posterior samples, discarding a certain proportion at the beginning of each chain as burn-in
  • Input: Raw epifusion output object generated by load_raw_epifusion() and proportion of each chain to discard as burn-in
  • Output: A large list with the EpiFusion posterior samples aggregated across chains (with burn-in discarded). Also has trajectory means and HPDs, and parameter convergence statistics.
extract_posterior_epifusion(raw_epifusion_output, 0.1)