## 3 Markov Chain Monte Carlo Algorithms
### Delayed Rejection Adaptive Metropolis (DRAM)
#### 3.1.3 Combining DR and AM into DRAM  
The combination of DR and AM results in the DRAM algorithm. DRAM takes advantage of DR and AM to speed up convergence and enhance the acceptance rate of samples. The intuition in DRAM is to automatically learn information from the chain path and adaptively train the proposal to fit the target posterior. DR and AM in DRAM work jointly and have different functions. For instance, DR allows us to locally adapt the proposal based on rejected samples at each time step. AM allows us to globally adapt the proposal based on previously accepted samples. Given a non-adaptation period of \(\lambda_{0}\) and the initial covariance \(C_{0}\), a direct way to combine AM and DR is given as follows [18].  
1. _Proposal Covariance Adaptation_ The proposal covariance at DR's first stage is adapted using AM, such as \(C_{\lambda}^{1}\) computed by current samples in the chain using Equation (16), whenever samples are accepted.
2. _Scaling Parameter_ For the i-th DR stage, the covariance is always computed as a scaled version of that in the first stage: \(C_{\lambda}^{1}=\tau_{i}C_{\lambda}^{1}\), where the scaling parameter \(\tau_{i}\) can be freely selected. Larger scaling parameters are stored at earlier stages and gradually decrease. While DRAM incorporates the AM strategy, it can still be challenging to adapt the proposal if the initial covariance is too large, as this deviation prevents the AM process from starting. To address this, the covariance is progressively reduced at higher DR stages, allowing more samples to be accepted and enabling the proper activation of AM. Detailed explanations of DRAM and its hyper-parameters are provided in [PERSON] et al. [18]. For simplicity, this study considers a two-stage DR. The implementation of DRAM is described in Algorithm 1.  
```
Initialization \(N\): the No. of iterations; \(\lambda_{0}\): the length of non-adaptation period; \(x_{0}\), \(C_{0}\): initial value and covariance, respectively \(q(x_{0},C_{0})\): the proposal distribution \(\tau\): the scaling parameter; \(\mathcal{L}\): the parameter bounds; \(\mathcal{c}\): a trial constant \(I_{d}\): the \(d\)-dimensional identity matrix
```  
**For**\(i=\)1,2,\(\cdots\), \(N\):  
Draw the candidate sample \(x_{1}\)\(\sim\)\(q(x_{0},\mathcal{C}_{0})\) within \(\mathcal{L}\)  
Compute acceptance rate: \(\pi_{01}=\min\left\{1,\frac{p(x_{1})q_{x_{0}}(x_{1},\mathcal{C}_{0})}{p(x_{0}) q_{x_{1}}(x_{0},\mathcal{C}_{0})}\right\}\)  
Generate \(u\) from a uniform distribution \(U(0,1)\)  
If\(u<\pi_{01}\):  
\(x_{1}\) is accepted and stored  
Else:  
Draw the new candidate sample \(x_{2}\)\(\sim\)\(q(x_{0},\tau\mathcal{C}_{0})\) within \(\mathcal{L}\)  
Compute acceptance rate: \(\pi_{21}=\min\left\{1,\frac{p(x_{1})q_{x_{2}}(x_{1},\mathcal{C}_{0})}{p(x_{2}) q_{x_{1}}(x_{2},\mathcal{C}_{0})}\right\}\)  
\(\pi_{02}=\min\left\{1,\frac{p(x_{2})q_{x_{1}}(x_{2},\mathcal{C}_{0})q_{x_{0}}(x _{2},\mathcal{C}_{0})[1-\pi_{21}]}{p(x_{0})q_{x_{1}}(x_{0},\mathcal{C}_{0})q_{ x_{2}}(x_{0},\mathcal{C}_{0})[1-\pi_{01}]}\right\}\)  
If\(u<\pi_{02}\):  
\(x_{2}\) is accepted and stored  
End  
If\(i>\lambda_{0}\):  
Adapt sampling covariance \(C_{i}=\frac{2.\pi^{2}}{d}Cov(x_{0},x_{1},\cdots,x_{i-1})+\frac{2.\pi^{2}}{d} \varepsilon I_{d}\)  
End  
End