arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

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!

hashtag
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 , and copy this to both the global () and chimeric () parameter chain (sequence ;

      • Generate an initial epidemic trajectory

  • End for parallel MCMC chains

  • Collect the final global parameter values for each parallel chain

hashtag
Making chimeric decision first

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,

    • Calculate the overall likelihood with the proposed parameters,

    • Make "global" decision about proposed parameters

      • Generate a uniform random number

      • Calculate the overall likelihood with the current global parameters,

    • End making global decision

  • End for KKK iterations of each MCMC chain

  • Θm,0\Theta_{m,0}Θm,0​
    Θm,0G\Theta^G_{m,0}Θm,0G​
    Θm,0C\Theta^C_{m,0}Θm,0C​
    Z(Θm,0)Z(\Theta_{m,0})Z(Θm,0​)
    MMM
    θm={Θm,KG}m\theta_m = \{\Theta^G_{m,K}\}_mθm​={Θm,KG​}m​
    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

        • Generate a uniform random number

        • Calculate the acceptance ratio

        • If

      • End for subpopulations

    • End making chimeric decisions

  • End if

  • Li(Di∣Zi(Θ∗))\mathcal{L}_i(D_i|Z_i(\Theta^*))Li​(Di​∣Zi​(Θ∗))
    L(D∣Z(Θ∗))\mathcal{L}(D|Z(\Theta^*))L(D∣Z(Θ∗))
    uG∼U[0,1]u^G \sim \mathcal{U}[0,1]uG∼U[0,1]
    L(D∣Z(Θm,k−1G))\mathcal{L}(D|Z(\Theta^G_{m,k-1}))L(D∣Z(Θm,k−1G​))
    : ACCEPT the proposed parameters to the chimeric parameter chain for this location
    • Set

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

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

    • Set ​

  • `End if ;

  • i=1…Ni = 1 \dots Ni=1…N
    uiC∼U[0,1]u_i^C \sim \mathcal{U}[0,1]uiC​∼U[0,1]
    α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(Θ∗)​
    NNN
    αiC>uiC\alpha_i^C > u_i^CαiC​>uiC​
    Θm,k,iC=Θi∗\Theta_{m,k,i}^C = \Theta^*_{i}Θm,k,iC​=Θi∗​
    iii
    Θm,k,iC=Θm,k−1,i\Theta_{m,k,i}^C=\Theta_{m,k-1,i}Θm,k,iC​=Θm,k−1,i​