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!
Last updated
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!
For m=1…M, where Mis the number of parallel MCMC chains (also known as slots)
Generate initial state
Generate an initial set of parameters Θm,0, and copy this to both the global (Θm,0G) and chimeric (Θm,0C) parameter chain (sequence ;
Generate an initial epidemic trajectory 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...K where K is the length of the MCMC chain, add to the sequence of parameter values :
Generate a proposed set of parameters Θ∗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(Θ∗)
Calculate the likelihood of the data given the proposed parameters for each subpopulation, Li(Di∣Zi(Θ∗))
Calculate the overall likelihood with the proposed parameters, L(D∣Z(Θ∗))
Make "global" decision about proposed parameters
Generate a uniform random number uG∼U[0,1]
Calculate the overall likelihood with the current global parameters, L(D∣Z(Θm,k−1G))
Calculate the acceptance ratio αG=min(1,L(D∣Z(Θm,k−1G))p(Θm,k−1G)L(D∣Z(Θ∗))p(Θ∗))
If αG>uG: ACCEPT the proposed parameters to the global and chimeric parameter chains
Set
Set Θ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
Make "chimeric" decision:
For i=1…N
Generate a uniform random number uiC∼U[0,1]
Calculate the acceptance ratio αiC=Li(Di∣Zi(Θm,k−1C))p(Θm,k−1)Li(Di∣Zi(Θ∗))p(Θ∗)
If αiC>uiC: ACCEPT the proposed parameters to the chimeric parameter chain for this location
Set Θm,k,iC=Θi∗
Update the recorded chimeric likelihood value for subpopulation i 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
`End if ;
End for Nsubpopulations
End making chimeric decisions
End if
End making global decision
End for K iterations of each MCMC chain
End for M parallel MCMC chains
Collect the final global parameter values for each parallel chain θm={Θm,KG}m
Last updated
