0
$\begingroup$

I am working on a Gibbs sampler of three parameters and we know the full conditional distribution of three parameters.

$\endgroup$
0
$\begingroup$

Note: This is just a comment but to quote a long code, I put it here.

for (ite in 2:NSim){
#Full conditional for pi

 pi[ite]=rbeta(1, sum(delta[ite-1,])+0.5, sum(1-delta[ite-1,])+0.5)

 #Full conditional for delta
 for(j in 1:4){
  p1=pi[ite]*exp(-beta[ite-1,j]^2/(20))
  p0=((1-pi[ite])*10^3)*exp(-500*beta[ite-1,j]^2)
  cat('\n',ite,j,(p1/(p0+p1)))
  delta[ite,j]=rbinom(1, 1,prob=(p1/(p0+p1)))
  }

The error says that maybe $p1$ and $p0$ are NAs. My experience when checking this type of error is that. Instead of for loop, just give $ite=2$ and $j=1$. Compute p1 and p0 as your formulas. Check carefully if they are NAs or not. If the codes are symmetric with regard to $iter$ and $j$, and if you can correct the error for this case, it will pass this.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.