# Thread: How to apply MCMC/Metropolis Hastings with a constraint

1. ## How to apply MCMC/Metropolis Hastings with a constraint

I have 4 random variables, say A,B,C and D and some data X. I can obtain the conditional pdfs P(A|B,C,D,X),..., P(D|A,B,C,X) up to proportionality. I would like to sample from the joint pdf P(A,B,C,D|X).

This can easily be done via metropolis hastings. However I wish to also have the constraint that A+B=C+D.

The constraint can be wrote as D=A+B-C

My idea was to propose a value for A from a symmetric proposal distribution, and work out what D would have to be in order for the constraint to be satisfied. Then the acceptance probability would be as in the normal case (with no constraint) multiplied by P(Dnew|A,B,C,X)/P(Dold|A,B,C,X).

Does this seem reasonable? my results look roughly as expected.

Any advice/corrections would be greatly appreciated.

2. ## Re: How to apply MCMC/Metropolis Hastings with a constraint

No need to worry. I have solved my own problem using a proposal which automatically satisfies the constraint

 Tweet