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!

Current inference algorithm

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

    • Generate initial state

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

      • Generate an initial epidemic trajectory Z(Θm,0)Z(\Theta_{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 ... K where KK 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^*)

      • Calculate the likelihood of the data given the proposed parameters for each subpopulation, Li(DiZi(Θ))\mathcal{L}_i(D_i|Z_i(\Theta^*))

      • Calculate the overall likelihood with the proposed parameters, L(DZ(Θ))\mathcal{L}(D|Z(\Theta^*))

      • Make "global" decision about proposed parameters

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

        • Calculate the overall likelihood with the current global parameters, L(DZ(Θm,k1G))\mathcal{L}(D|Z(\Theta^G_{m,k-1}))

        • Calculate the acceptance ratio αG=min(1,L(DZ(Θ))p(Θ)L(DZ(Θm,k1G))p(Θm,k1G))\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)

        • If αG>uG\alpha^G > u^G: 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^*

          • 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,k1G\Theta^G_{m,k} = \Theta^G_{m,k-1}

          • Make "chimeric" decision:

            • For i=1Ni = 1 \dots N

              • Generate a uniform random number uiCU[0,1]u_i^C \sim \mathcal{U}[0,1]

              • Calculate the acceptance ratio αiC=Li(DiZi(Θ))p(Θ)Li(DiZi(Θm,k1C))p(Θm,k1)\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}) }

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

                • Set Θm,k,iC=Θi\Theta_{m,k,i}^C = \Theta^*_{i}

                • Update the recorded chimeric likelihood value for subpopulation ii 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,k1,i\Theta_{m,k,i}^C=\Theta_{m,k-1,i}

              • `End if ;

            • End for NNsubpopulations

          • End making chimeric decisions

        • End if

      • End making global decision

    • End for KK iterations of each MCMC chain

  • End for MM parallel MCMC chains

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

Making chimeric decision first

Last updated