LogoLogo
JHU-IDDCOVID-19 Scenario Modeling hubCOVID-19 Forecast Hub
  • Home
  • 🦠gempyor: modeling infectious disease dynamics
    • Modeling infectious disease dynamics
    • Model Implementation
      • flepiMoP's configuration file
      • Specifying population structure
      • Specifying compartmental model
      • Specifying initial conditions
      • Specifying seeding
      • Specifying observational model
      • Distributions
      • Specifying time-varying parameter modifications
      • Other configuration options
      • Code structure
    • Model Output
  • πŸ“ˆModel Inference
    • Inference Description
    • Inference Implementation
      • Specifying data source and fitted variables
      • (OLD) Configuration options
      • (OLD) Configuration setup
      • Code structure
    • Inference Model Output
    • Inference with EMCEE
  • πŸ–₯️More
    • Setting up the model and post-processing
      • Config writer
      • Diagnostic plotting scripts
      • Create a post-processing script
      • Reporting
    • Advanced
      • File descriptions
      • Numerical methods
      • Additional parameter options
      • Swapping model modules
      • Using plug-ins 🧩[experimental]
  • πŸ› οΈHow To Run
    • Before any run
    • Quick Start Guide
    • Multiple Configuration Files
    • Synchronizing Files
    • Advanced run guides
      • Running with Docker locally πŸ›³
      • Running locally in a conda environment 🐍
      • Running on AWS 🌳
      • Running On A HPC With Slurm
    • Common errors
    • Useful commands
    • Tips, tricks, FAQ
  • πŸ—œοΈDevelopment
    • Git and GitHub Usage
    • Guidelines for contributors
  • Deprecated pages
    • Module specification
  • JHU Internal
    • US specific How to Run
      • Running with Docker locally (outdated/US specific) πŸ›³
      • Running on Rockfish/MARCC - JHU πŸͺ¨πŸ 
      • Running with docker on AWS - OLD probably outdated
        • Provisioning AWS EC2 instance
        • AWS Submission Instructions: Influenza
        • AWS Submission Instructions: COVID-19
      • Running with RStudio Server on AWS EC2
    • Inference scratch
Powered by GitBook
On this page
  • Current inference algorithm
  • Making chimeric decision first
Edit on GitHub
Export as PDF
  1. JHU Internal

Inference scratch

This is just a place to play around with different inference algorithms. Gitbook markdown is very application-specific so can't copy this algorithm text into other apps to play around with!

PreviousRunning with RStudio Server on AWS EC2

Last updated 7 months ago

Current inference algorithm

  • For m=1…Mm=1 \dots Mm=1…M, where MMMis the number of parallel MCMC chains (also known as slots)

    • Generate initial state

      • Generate an initial set of parameters Θm,0\Theta_{m,0}Θm,0​, and copy this to both the global (Θm,0G\Theta^G_{m,0}Θm,0G​) and chimeric (Θm,0C\Theta^C_{m,0}Θm,0C​) parameter chain (sequence ;

      • Generate an initial epidemic trajectory Z(Θm,0)Z(\Theta_{m,0})Z(Θm,0​)

      • Calculate and record the initial likelihood for each subpopulation, $$\mathcal{L_i}(D_i|Z_i(\Theta_{m,0}))$ ;

    • For k=1...Kk= 1 ... Kk=1...K where KKK is the length of the MCMC chain, add to the sequence of parameter values :

      • Generate a proposed set of parameters Ξ˜βˆ—\Theta^*Ξ˜βˆ—from the current chimeric parameters using the proposal distribution $$g(\Theta^*|\Theta^C_{m,k-1})$ ;

      • Generate an epidemic trajectory with these proposed parameters, Z(Ξ˜βˆ—)Z(\Theta^*)Z(Ξ˜βˆ—)

      • Calculate the likelihood of the data given the proposed parameters for each subpopulation, Li(Di∣Zi(Ξ˜βˆ—))\mathcal{L}_i(D_i|Z_i(\Theta^*))Li​(Diβ€‹βˆ£Zi​(Ξ˜βˆ—))

      • Calculate the overall likelihood with the proposed parameters, L(D∣Z(Ξ˜βˆ—))\mathcal{L}(D|Z(\Theta^*))L(D∣Z(Ξ˜βˆ—))

      • Make "global" decision about proposed parameters

        • Generate a uniform random number uG∼U[0,1]u^G \sim \mathcal{U}[0,1]uG∼U[0,1]

        • Calculate the overall likelihood with the current global parameters, L(D∣Z(Θm,kβˆ’1G))\mathcal{L}(D|Z(\Theta^G_{m,k-1}))L(D∣Z(Θm,kβˆ’1G​))

        • Calculate the acceptance ratio Ξ±G=min⁑(1,L(D∣Z(Ξ˜βˆ—))p(Ξ˜βˆ—)L(D∣Z(Θm,kβˆ’1G))p(Θm,kβˆ’1G))\alpha^G=\min \left(1, \frac{\mathcal{L}(D|Z(\Theta^*)) p(\Theta^*) }{\mathcal{L}(D|Z(\Theta^G_{m,k-1})) p(\Theta^G_{m,k-1}) } \right)Ξ±G=min(1,L(D∣Z(Θm,kβˆ’1G​))p(Θm,kβˆ’1G​)L(D∣Z(Ξ˜βˆ—))p(Ξ˜βˆ—)​)​

        • If Ξ±G>uG\alpha^G > u^GΞ±G>uG: ACCEPT the proposed parameters to the global and chimeric parameter chains

          • Set \Theta^G_{m,k} =$$$$\Theta^*

          • Set Θm,kC=Ξ˜βˆ—\Theta_{m,k}^C=\Theta^*Θm,kC​=Ξ˜βˆ—

          • Update the recorded subpopulation-specific likelihood values (chimeric and global) with the likelihoods calculated using the proposed parameter ;

        • Else: REJECT the proposed parameters for the global chain and make subpopulation-specific decisions for the chimeric chain

          • Set Θm,kG=Θm,kβˆ’1G\Theta^G_{m,k} = \Theta^G_{m,k-1}Θm,kG​=Θm,kβˆ’1G​

          • Make "chimeric" decision:

            • For i=1…Ni = 1 \dots Ni=1…N

              • Generate a uniform random number uiC∼U[0,1]u_i^C \sim \mathcal{U}[0,1]uiCβ€‹βˆΌU[0,1]

              • Calculate the acceptance ratio Ξ±iC=Li(Di∣Zi(Ξ˜βˆ—))p(Ξ˜βˆ—)Li(Di∣Zi(Θm,kβˆ’1C))p(Θm,kβˆ’1)\alpha_i^C=\frac{\mathcal{L}_i(D_i|Z_i(\Theta^*)) p(\Theta^*) }{\mathcal{L}i(D_i|Z_i(\Theta^C_{m,k-1})) p(\Theta_{m,k-1}) }Ξ±iC​=Li(Diβ€‹βˆ£Zi​(Θm,kβˆ’1C​))p(Θm,kβˆ’1​)Li​(Diβ€‹βˆ£Zi​(Ξ˜βˆ—))p(Ξ˜βˆ—)​

              • If Ξ±iC>uiC\alpha_i^C > u_i^CΞ±iC​>uiC​: ACCEPT the proposed parameters to the chimeric parameter chain for this location

                • Set Θm,k,iC=Θiβˆ—\Theta_{m,k,i}^C = \Theta^*_{i}Θm,k,iC​=Θiβˆ—β€‹

                • Update the recorded chimeric likelihood value for subpopulation iii to that calculated with the proposed parameter​

              • Else: REJECT the proposed parameters for the chimeric parameter chain for this location

                • Set Θm,k,iC=Θm,kβˆ’1,i\Theta_{m,k,i}^C=\Theta_{m,k-1,i}Θm,k,iC​=Θm,kβˆ’1,i​​

              • `End if ;

            • End for NNNsubpopulations

          • End making chimeric decisions

        • End if

      • End making global decision

    • End for KKK iterations of each MCMC chain

  • End for MMM parallel MCMC chains

  • Collect the final global parameter values for each parallel chain ΞΈm={Θm,KG}m\theta_m = \{\Theta^G_{m,K}\}_mΞΈm​={Θm,KG​}m​

Making chimeric decision first