I am running a MCMC algorithm with Metropolis Hastings step in R, which requires accepting or rejecting a proposal sample according to a logical rule. Currently, I have implemented this as
if(sample meets condition){accept}
else{reject}
I heard that if statements are slow, but MCMC requires usually evaluating many proposal samples, certainly in the ten thousands. What are faster alternatives to improve the speed of this part of any MCMC algorithm?
Aucun commentaire:
Enregistrer un commentaire