Problem in Probability Ratio in M-H algorithm I attempt to sample the posterior distribution of parameters($\alpha,\alpha_1,\alpha_2,\lambda_1,\lambda_2$) using the Metropolis-Hastings within Gibbs.
Steps of Random Walk Metropolis-Hastings

*

*start with t=1 and the initial values {($\alpha=1,\alpha_1=1,\alpha_2=1,\lambda_1=1,\lambda_2$=1)}


*using the initial values generate candidate points from proposal densities
alpha.can<-abs(rnorm(1,alpha[t-1],0.5));  alpha1.can<-abs(rnorm(1,alpha1[t-1],0.5));
alpha2.can<-abs(rnorm(1,alpha2[t-1],0.5));
lamda1.can<-abs(rnorm(1,lamda1[t-1],0.5)); lamda2.can<-abs(rnorm(1,lamda2[t-1],0.005))


*Generate u.$\alpha$~$\mathscr U$[0,1],  u.$\alpha_1$~$\mathscr U$[0,1], u.$\alpha_2$~$\mathscr U$[0,1],      u.$\lambda_1$~$\mathscr U$[0,1],
u.$\lambda_2$~$\mathscr U$[0,1].


*Calculate the ratio of candidate point alpha.can and previous point alpha[t-1]
R1=$\frac{g(alpha.can \quad given \quad {\alpha_1[t-1],\alpha_2[t-1],\lambda_1[t-1],\lambda_2[t-1]})}{g(alpha[t-1] \quad given \quad {\alpha_1[t-1],\alpha_2[t-1],\lambda_1[t-1],\lambda_2[t-1]})}$
where g is the full conditional posterior of $\alpha$.


*If u.$\alpha \;$ <= min (R1,1), accept the candidate point, otherwise set alpha.can=alpha[t-1]


*Similarly from step 4, the ratio of candidate point alpha1.cand and previous point alpha1 [t-1] is
R2=$\frac{g(alpha1.can \quad given \quad {\alpha[t],\alpha_2[t-1],\lambda_1[t-1],\lambda_2[t-1]})}{g(alpha1[t-1] \quad given \quad {\alpha[t],\alpha_2[t-1],\lambda_1[t-1],\lambda_2[t-1]})}$
where g is the full conditional posterior of $\alpha_1$.


*If u.$\alpha_1 \;$ <= min (R2,1), accept the candidate point, otherwise set alpha1.can=alpha1[t-1]$\qquad$
and so on for $\alpha_2,\lambda_1,\lambda_2$.


*Repeat steps 2-7 (T=10000) times and obtain sample of {$\alpha,\alpha_1,\alpha_2,\lambda_1,\lambda_2 $}.
Thanks in Advance
 A: The proposal of an absolute Gaussian/Normal variate $|X|$ when $X\sim\mathcal{N}(\mu,\sigma^2)$ has density
$$\frac{1}{2}\varphi(x|\mu,\sigma^2)+\frac{1}{2}\varphi(-x|\mu,\sigma^2)$$
Hence, if you use the absolute value of a normal simulation for proposed move, your proposal density is no longer symmetric and it must appear in the Metropolis-Hastings acceptance ratio. Therefore, the Metropolis-Hastings ratios in your R code must be multiplied by the ratios
$$\dfrac{\varphi(\theta_i^t|\theta_i,\sigma^2)+\varphi(-\theta_i^t|\theta_i,\sigma^2)}{\varphi(\theta_i|\theta_i^t,\sigma^2)+\varphi(-\theta_i|\theta_i^t,\sigma^2)}$$
For instance,
 R1=Post.alpha(Data,alpha.can,alpha1t,alpha2t,lamda1t,lamda2t)/
     Post.alpha(Data,alphat,alpha1t,alpha2t,lamda1t,lamda2t)*
      sum(dnorm((-1)^(0:1)*alphat,alpha.can,sd.Normal))/
       sum(dnorm((-1)^(0:1)*alpha.can,alphat,sd.Normal))

As for the appearance of NaN in the outcome of the Post.alpha functions, it is no surprise as they involve powers and exponentials. For instance,
> Post.alpha(Data,.0001,.0002,.0001,.0002,.0003)
[1] 8.512619e-223

You should work with log posteriors to reduce the possibility of underflows.
